| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #define _USE_MATH_DEFINES
- #include <cmath>
- #include "Player.h"
- #include <GL/freeglut.h>
- #include <string>
- #include <iostream>
- #include <fstream>
- Player* Player::instance = NULL;
- Player::Player()
- {
- }
- Player* Player::getInstance()
- {
- if (instance == nullptr)
- instance = new Player();
- return instance;
- }
- void Player::init()
- {
- instance = new Player();
- }
- Player::~Player()
- {
- }
- void Player::setCamera()
- {
- glRotatef(rotation.x, 1, 0, 0);
- glRotatef(rotation.y, 0, 1, 0);
- 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;
- position.z -= (float)sin((rotation.y + angle) / 180 * M_PI) * fac;
- }
- }
- void Player::draw() {
- }
|