Example #1
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);
	}	// Á¾·á
}