Added new Johan Code
This commit is contained in:
+14
-1
@@ -1,9 +1,11 @@
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
#include "Player.h"
|
||||
#include <GL/freeglut.h>
|
||||
|
||||
Player::Player()
|
||||
{
|
||||
|
||||
speed = 10;
|
||||
}
|
||||
|
||||
void Player::setCamera()
|
||||
@@ -13,3 +15,14 @@ void Player::setCamera()
|
||||
glTranslatef(-position.x, -position.y, -position.z);
|
||||
|
||||
}
|
||||
|
||||
void Player::setPosition(float angle, float fac, bool height)
|
||||
{
|
||||
if (height)
|
||||
position.y += angle*fac;
|
||||
else
|
||||
{
|
||||
position.x -= (float)cos((rotation.y + angle) / 180 * M_PI) * fac*speed;
|
||||
position.z -= (float)sin((rotation.y + angle) / 180 * M_PI) * fac*speed;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user