Player state and animations.  
 More...
#include <Player.hpp>
|  | 
| glm::mat4 | modelHead = glm::mat4(1.0f) | 
|  | The snake head model matrix. 
 | 
|  | 
| std::vector< glm::mat4 > | modelsBody | 
|  | The snake body elements model matrices. 
 | 
|  | 
| std::vector< glm::mat4 > | modelsItem | 
|  | The edible items model matrices. 
 | 
|  | 
| std::vector< int > | looksBody | 
|  | The snake body elements material IDs. 
 | 
|  | 
| std::vector< int > | looksItem | 
|  | The edible items material IDs. 
 | 
|  | 
|  | 
| glm::vec3 | _momentum = glm::vec3(0.0f, 1.0f, 0.0f) | 
|  | The snake momentum. 
 | 
|  | 
| glm::vec3 | _position = glm::vec3(0.0f) | 
|  | The snake position. 
 | 
|  | 
| float | _angle = 0.0f | 
|  | The snake head orientation. 
 | 
|  | 
| std::vector< glm::vec2 > | _positions | 
|  | The snake body elements positions. 
 | 
|  | 
| std::vector< float > | _angles | 
|  | The snake body elements orientations. 
 | 
|  | 
| std::vector< glm::vec2 > | _items | 
|  | The items positions. 
 | 
|  | 
| std::vector< PathPoint > | _path | 
|  | Ring buffer containing samples along the snake path. 
 | 
|  | 
| unsigned int | _currentSample = 0 | 
|  | The current sample in the ring buffer. 
 | 
|  | 
| unsigned int | _currentFrame = 0 | 
|  | Current frame (modulo sampling period). 
 | 
|  | 
| double | _lastSpawn = 0.0 | 
|  | Time since the last item spawn. 
 | 
|  | 
| float | _invicibility = 0.0f | 
|  | Invicibility time buffer after boucning off a wall. 
 | 
|  | 
| int | _score = 0 | 
|  | Player score. 
 | 
|  | 
| bool | _alive = true | 
|  | Player status. 
 | 
|  | 
| const glm::vec3 | _maxPos = glm::vec3(8.6f, 5.0f, 0.0f) | 
|  | Terrain bounding box. 
 | 
|  | 
| const double | _spawnPeriod = 1.5 | 
|  | Time betweeen two item spawns. 
 | 
|  | 
| const size_t | _numSamplesPath = 512 | 
|  | Size of the samples ring buffer. 
 | 
|  | 
| const size_t | _samplingPeriod = 15 | 
|  | Frame count between two samples. 
 | 
|  | 
| const float | _radius = 0.5f | 
|  | Items and elements radius. 
 | 
|  | 
| const float | _headAccel = 4.0f | 
|  | Head speed. 
 | 
|  | 
| const float | _angleSpeed = 6.0f | 
|  | Head angular speed. 
 | 
|  | 
| const float | _minSamplingDistance = 0.02f | 
|  | Minimum distance between two samples. 
 | 
|  | 
| const float | _invicibilityIncrease = 0.5f | 
|  | Amount of time added to invicibility at each bounce. 
 | 
|  | 
| const float | _eatingDistance = 1.5f | 
|  | Distance below which an item can be eaten. 
 | 
|  | 
| const float | _minSpawnDistance = 3.0f | 
|  | Minimum distance with the snake head when spawning a new item. 
 | 
|  | 
| const float | _collisionDistance = 1.5f | 
|  | Distance below which a collision is registered. 
 | 
|  | 
| const int | _spawnTentatives = 50 | 
|  | Ho many spawn attempts should be made at each spawn event. 
 | 
|  | 
| const int | _maxItems = 20 | 
|  | Max number of items on the terrain. 
 | 
|  | 
| const int | _itemValue = 1 | 
|  | Score gained when eating an item. 
 | 
|  | 
Player state and animations. 
◆ Player()
◆ alive()
  
  | 
        
          | bool Player::alive | ( |  | ) | const |  | inline | 
 
Status of the player. 
- Returns
- true if the player is alive. 
 
 
◆ physics()
      
        
          | bool Player::physics | ( | double | fullTime, | 
        
          |  |  | double | frameTime | 
        
          |  | ) |  |  | 
      
 
Update the physic state of the player snake and items 
- Parameters
- 
  
    | fullTime | time elapsed since the beginning of the game |  | frameTime | delta time since last physics update |  
 
- Returns
- a boolean denoting if any item has been eaten. 
 
 
◆ score()
  
  | 
        
          | int Player::score | ( |  | ) | const |  | inline | 
 
Score of the player. 
- Returns
- the score. 
 
 
◆ update()
Update logical state, once per frame 
 
 
◆ updateModels()
      
        
          | void Player::updateModels | ( |  | ) |  | 
      
 
Update the model matrices of all items This is so that we avoid updating them at each physics step. 
 
 
The documentation for this class was generated from the following files:
- src/apps/snakegame/Player.hpp
- src/apps/snakegame/Player.cpp