OpenMiner/include/player.h

69 lines
2.0 KiB
C
Raw Normal View History

2013-02-25 21:52:03 +01:00
/*---------------------------------------------------------------------------------
KubKraft
Copyright (C) 2012 Quent42340 <quent42340@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------------*/
2013-02-11 21:58:34 +01:00
#ifndef PLAYER_H
#define PLAYER_H
2013-02-17 20:46:59 +01:00
#define RADIANS_PER_DEGREES 0.0174532925199
2013-02-11 21:58:34 +01:00
class Player {
public:
Player(float x, float y, float z, float angle);
void move(float distance, float direction);
2013-05-16 00:12:11 +02:00
void update();
2013-05-01 21:36:09 +02:00
void jump();
2013-02-11 21:58:34 +01:00
void fly();
void land();
2013-05-16 00:12:11 +02:00
void turnH(float angle);
void turnV(float angle);
2013-02-11 21:58:34 +01:00
void watch();
2013-02-17 20:46:59 +01:00
float x() const { return m_x; }
float y() const { return m_y; }
float z() const { return m_eyeheight; }
2013-05-01 21:36:09 +02:00
bool isJumping() const { return m_isJumping; }
2013-05-16 00:12:11 +02:00
void setJumpSpeed(float jumpSpeed) { m_speed.z = jumpSpeed; }
2013-05-01 21:36:09 +02:00
void setJumping(bool isJumping) { m_isJumping = isJumping; }
2013-02-17 22:20:26 +01:00
2013-02-25 21:52:03 +01:00
float pointTargetedx() { return m_x + cos(m_angleH * RADIANS_PER_DEGREES) * cos(m_angleV * RADIANS_PER_DEGREES); }
float pointTargetedy() { return m_y + sin(m_angleH * RADIANS_PER_DEGREES) * cos(m_angleV * RADIANS_PER_DEGREES); }
2013-02-17 22:20:26 +01:00
float pointTargetedz() { return m_eyeheight + sin(m_angleV * RADIANS_PER_DEGREES); }
2013-02-17 20:46:59 +01:00
2013-02-11 21:58:34 +01:00
private:
float m_x;
float m_y;
2013-02-17 22:20:26 +01:00
float m_eyeheight;
2013-02-11 21:58:34 +01:00
float m_angleH;
float m_angleV;
2013-05-01 21:36:09 +02:00
bool m_isJumping;
2013-05-16 00:12:11 +02:00
vect3D m_speed;
2013-05-16 22:12:49 +02:00
void testPoint(vect3D pos, vect3D *speed, bool playerFoots = false);
2013-02-11 21:58:34 +01:00
};
#endif // PLAYER_H