21 bool physics(
double fullTime,
double frameTime);
81 const glm::vec3
_maxPos = glm::vec3(8.6f, 5.0f, 0.0f);
Player state and animations.
Definition: Player.hpp:8
unsigned int _currentSample
The current sample in the ring buffer.
Definition: Player.hpp:67
float _invicibility
Invicibility time buffer after boucning off a wall.
Definition: Player.hpp:73
const int _itemValue
Score gained when eating an item.
Definition: Player.hpp:109
const float _eatingDistance
Distance below which an item can be eaten.
Definition: Player.hpp:99
glm::mat4 modelHead
The snake head model matrix.
Definition: Player.hpp:38
bool physics(double fullTime, double frameTime)
Definition: Player.cpp:25
const int _spawnTentatives
Ho many spawn attempts should be made at each spawn event.
Definition: Player.hpp:105
const size_t _numSamplesPath
Size of the samples ring buffer.
Definition: Player.hpp:85
std::vector< glm::vec2 > _items
The items positions.
Definition: Player.hpp:63
const float _radius
Items and elements radius.
Definition: Player.hpp:89
bool _alive
Player status.
Definition: Player.hpp:77
const float _angleSpeed
Head angular speed.
Definition: Player.hpp:93
const int _maxItems
Max number of items on the terrain.
Definition: Player.hpp:107
glm::vec3 _position
The snake position.
Definition: Player.hpp:55
void updateModels()
Definition: Player.cpp:198
int score() const
Definition: Player.hpp:36
const glm::vec3 _maxPos
Terrain bounding box.
Definition: Player.hpp:81
unsigned int _currentFrame
Current frame (modulo sampling period).
Definition: Player.hpp:69
std::vector< PathPoint > _path
Ring buffer containing samples along the snake path.
Definition: Player.hpp:65
glm::vec3 _momentum
The snake momentum.
Definition: Player.hpp:53
float _angle
The snake head orientation.
Definition: Player.hpp:57
void update()
Definition: Player.cpp:9
double _lastSpawn
Time since the last item spawn.
Definition: Player.hpp:71
bool alive() const
Definition: Player.hpp:31
const double _spawnPeriod
Time betweeen two item spawns.
Definition: Player.hpp:83
const size_t _samplingPeriod
Frame count between two samples.
Definition: Player.hpp:87
const float _minSamplingDistance
Minimum distance between two samples.
Definition: Player.hpp:95
int _score
Player score.
Definition: Player.hpp:75
const float _invicibilityIncrease
Amount of time added to invicibility at each bounce.
Definition: Player.hpp:97
std::vector< int > looksItem
The edible items material IDs.
Definition: Player.hpp:42
std::vector< glm::vec2 > _positions
The snake body elements positions.
Definition: Player.hpp:59
const float _collisionDistance
Distance below which a collision is registered.
Definition: Player.hpp:103
std::vector< int > looksBody
The snake body elements material IDs.
Definition: Player.hpp:41
std::vector< glm::mat4 > modelsBody
The snake body elements model matrices.
Definition: Player.hpp:39
const float _minSpawnDistance
Minimum distance with the snake head when spawning a new item.
Definition: Player.hpp:101
std::vector< float > _angles
The snake body elements orientations.
Definition: Player.hpp:61
const float _headAccel
Head speed.
Definition: Player.hpp:91
std::vector< glm::mat4 > modelsItem
The edible items model matrices.
Definition: Player.hpp:40
Player()
Definition: Player.cpp:5
A sample along the snake path.
Definition: Player.hpp:47
glm::vec2 pos
Sample position on screen.
Definition: Player.hpp:48
float dist
Distance to the previous sample.
Definition: Player.hpp:49