예제 #1
0
파일: Camera.cpp 프로젝트: YunHsiao/RTR
bool TDCamera::onTick(float fElapsedTime, CTerrain* terrain)
{
	static float fTime(0.f);
	KeyboardInput(fElapsedTime);
	if (m_bDragging || m_bFollowing) MouseInput();
	UpdateAxis();
	if (m_bFollowing) {
		if (m_bGravity) m_pvPos.y = terrain->GetHeight(m_pvPos.x, m_pvPos.z); 
		m_vecEyePosition = m_pvPos - m_vecDirection * m_fFollowDist 
			+ m_vOffset - m_vecRight * (.5f * m_fFollowDist + .5f);
		D3DXMatrixRotationY(m_pTransform, m_fYaw - D3DX_PI);
		m_pTransform->_41 = m_pvPos.x; m_pTransform->_42 = m_pvPos.y; m_pTransform->_43 = m_pvPos.z;
	}
	ApplyCamera();
	if (m_bFollowing) {
		std::string action;
		if (m_bMoving) {
			if (m_bRunning) action = "run";
			else action = "walk";
		} else action = "stand";
		if (GetAsyncKeyState(VK_LBUTTON) & 0x8000) {
			action = "attack";
			fTime += fElapsedTime;
			// Animation Specific Parameters
			if (fTime > 1.2f) {
				fTime = 0.f;
				return true;
			}
		} else fTime = .6f;
		m_pPlayer->SetAction(action.c_str(), true, 5.f, .5f);
	}
	return false;
}
예제 #2
0
파일: Square.cpp 프로젝트: PCNohbdy/GSP281
//Draw Function
void Square::Render(void)
{
	if(CollisionManager::GetDebug())
	{
		if(CollisionType != NOCOLLISION)
		{
			Circle c(Pt,CollisionManager::FindSquareRadius(size),RGB(255,255,255));
			c.Render();
		}
	}
	UpdateAxis();
	//top bar
	Vector2 pt1,pt2;
	//The Orgion of the 2 points
	pt1.x = -(size.x/2);
	pt1.y = (size.y/2);
	pt2.x = (size.x/2);
	pt2.y = pt1.y;
	//rot.RotDeg(this->TextureAngle);
	//scale.Scale(this->Scale.x,this->Scale.y);
	//pt1 = rot * scale * pt1;
	//pt1 = trans * pt1;
	//pt2 = rot*scale*pt2;
	//pt2 = trans * pt2;
	Line ln(PointMath(pt1),PointMath(pt2),color);
	ln.Render();
	//right bar
	pt1.x = pt2.x;
	pt1.y = -(size.y)/2;
	//pt1 = rot*scale*pt1;
	//pt2 = rot*scale*pt2;
	ln.SetPoints(PointMath(pt1),PointMath(pt2));
	ln.Render();
	//bottom bar
	pt2.x = -size.x/2;
	pt2.y = pt1.y;
	//pt1 = rot*scale*pt1;
	//pt2 = rot*scale*pt2;
	ln.SetPoints(PointMath(pt1),PointMath(pt2));
	ln.Render();
	//left bar
	pt1.x = pt2.x;
	pt1.y =size.y/2;
	//pt1 = rot*scale*pt1;
	//pt2 = rot*scale*pt2;
	ln.SetPoints(PointMath(pt1),PointMath(pt2));
	ln.Render();
}
예제 #3
0
void AxisPlot::DatasetChanged(Dataset *dataset)
{
	UpdateAxis(dataset);
	FirePlotNeedRedraw();
}
예제 #4
0
void OnAxisTimerOverflow ()
{
	PORTE.OUTSET = 0x01;
	
	if (time == 0)
	{
		// Nothing to do
		if (!buffer_lock && !RingBufferIsEmpty(&location_buffer))
		{
			Location_t next = RingBufferGet(&location_buffer);
			x_axis.delta = next.x - x_axis.location;
			y_axis.delta = next.y - y_axis.location;
			z_axis.delta = next.z - z_axis.location;
			time = next.time;
			ovf_count = 0;
		}
		//if(location_buffer_size > 0)
		//{
		//	x_axis.delta = nextLocation.x - x_axis.location;
		//	y_axis.delta = nextLocation.y - y_axis.location;
		//	z_axis.delta = nextLocation.z - z_axis.location;
		//	time = nextLocation.time;
		//	ovf_count = 1;
		//	location_buffer_size--;
		//}
		
		//else
		//{
		//	x_axis.delta = 0;
		//	y_axis.delta = 0;
		//	z_axis.delta = 0;
		//}
	}
	else
	{
		UpdateAxis (&x_axis);
		UpdateAxis (&y_axis);
		UpdateAxis (&z_axis);
	
		if (ovf_count >= time)
		{
			time = 0;
			if (!buffer_lock && !RingBufferIsEmpty(&location_buffer))
			{
				Location_t next = RingBufferGet(&location_buffer);
				x_axis.delta = next.x - x_axis.location;
				y_axis.delta = next.y - y_axis.location;
				z_axis.delta = next.z - z_axis.location;
				time = next.time;
				ovf_count = 0;
			}
			//if(location_buffer_size > 0)
			//{
			//	x_axis.delta = nextLocation.x - x_axis.location;
			//	y_axis.delta = nextLocation.y - y_axis.location;
			//	z_axis.delta = nextLocation.z - z_axis.location;
			//	time = nextLocation.time;
			//	ovf_count = 0;
			//	location_buffer_size--;
			//}
			//else
			//{
			//	// TODO: If there's a buffer of positions, move to the next one here
			//	// (set delta, time, and count accordingly)
			//	x_axis.delta = 0;
			//	y_axis.delta = 0;
			//	z_axis.delta = 0;
			//	time = 0;
			//	ovf_count = 0;
			//}
			PORTE.OUTTGL = 0x02;
		}
		else
		{
			ovf_count++;
		}
	}	

	PORTE.OUTCLR = 0x01;
}