Beispiel #1
0
	void Update(Ball ball) {
		bb.SetBB(m_pt, {m_size,0,m_size/2});
		m_wheel_angle -= dir*speed;
		

		if(!bb.CollisionCheck(ball.GetBB()))
			m_pt.x += dir*speed;
		if(bb.CollisionCheck(ball.GetBB()))
			m_pt.x -= dir*speed*1.1;

		if (m_pt.x-m_size < -floor_size)
		{
			dir *= -1;
			m_pt.x = -floor_size+m_size;
		}
		if (m_pt.x+ m_size > floor_size)
		{
			dir *= -1;
			m_pt.x = floor_size-m_size;
		}
	}
Beispiel #2
0
void Keyboard(unsigned char key, int x, int y)
{
	{
		if (key == 'd' || key == 'D') {
			Ball temp;
			temp.SetPt(ball.GetPt());
			temp.Move(-1, Rotate_Speed, { 1,0,0 });
			temp.Update();
			if(!temp.GetBB().CollisionCheck(crane.GetBB()))
			ball.Move(-1, Rotate_Speed, { 1,0,0 });
		}
		if (key == 'a' || key == 'A') {
			Ball temp;
			temp.SetPt(ball.GetPt());
			temp.Move(1, Rotate_Speed, { 1,0,0 });
			temp.Update();
			if (!temp.GetBB().CollisionCheck(crane.GetBB()))
			ball.Move(1, Rotate_Speed, { 1,0,0 });
		}
		if (key == 'q' || key == 'Q') {
			Ball temp;
			temp.SetPt(ball.GetPt());
			temp.Move(-1, Rotate_Speed, { 0,1,0 });
			temp.Update();
			if (!temp.GetBB().CollisionCheck(crane.GetBB()))
			ball.Move(-1, Rotate_Speed, { 0,1,0 });
		}
		if (key == 'e' || key == 'E') {
			Ball temp;
			temp.SetPt(ball.GetPt());
			temp.Move(1, Rotate_Speed, { 0,1,0 });
			temp.Update();
			if (!temp.GetBB().CollisionCheck(crane.GetBB()))
			ball.Move(1, Rotate_Speed, { 0,1,0 });
		}
		if (key == 's' || key == 'S') {
			Ball temp;
			temp.SetPt(ball.GetPt());
			temp.Move(-1, Rotate_Speed, { 0,0,1 });
			temp.Update();
			if (!temp.GetBB().CollisionCheck(crane.GetBB()))
			ball.Move(-1, Rotate_Speed, { 0,0,1 });
		}
		if (key == 'w' || key == 'W') {
			Ball temp;
			temp.SetPt(ball.GetPt());
			temp.Move(1, Rotate_Speed, { 0,0,1 });
			temp.Update();
			if (!temp.GetBB().CollisionCheck(crane.GetBB()))
			ball.Move(1, Rotate_Speed, { 0,0,1 });
		}

		if (key == 'l' || key == 'L') {
			camera.HandleAngle(Camera_Speed, { 1,0,0 });
		}
		if (key == 'j' || key == 'J') {
			camera.HandleAngle(-Camera_Speed, { 1,0,0 });
		}
		if (key == 'i' || key == 'I') {
			camera.HandleAngle(Camera_Speed, { 0,1,0 });
		}
		if (key == 'k' || key == 'K') {
			camera.HandleAngle(-Camera_Speed, { 0,1,0 });
		}
		if (key == 'u' || key == 'U') {
			camera.HandleAngle(Camera_Speed, { 0,0,1 });
		}
		if (key == 'o' || key == 'O') {
			camera.HandleAngle(-Camera_Speed, { 0,0,1 });
		}




		if (key == '+') {
			camera.HandleDistance(10);
		}
		if (key == '-') {
			camera.HandleDistance(-10);
		}
		if (key == 'r' || key == 'R') {
			camera.init();
			ball.init();
		}
	}



	if (key == 'p' || key == 'P') {
		exit(0);
	}	// Á¾·á
}