aboutsummaryrefslogtreecommitdiff
path: root/sons_of_sol/Projectile.hpp
blob: 5f298a761c488097d1737ce5e4537cbfd76ca5e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef PROJECTILE_HPP_
#define PROJECTILE_HPP_

/*
 * Author: jrahm
 * created: 2013/12/08
 * Projectile.hpp: <description>
 */

#include "glox/GloxCommon.hpp"
#include "glox/GloxPoint.hpp"
#include "glox/GloxState.hpp"
#include "glox/objects/GloxCube.hpp"

#include <iostream>

#define TTL 50

class Projectile {
 public:
  Projectile(const glox::GloxPoint<>& position,
             const glox::GloxPoint<>& vector);

  inline void update() {
    if (m_ttl == 0 || --m_ttl == 0) {
      return;
    }
    m_position += m_dpos;
  }

  inline bool isDead() { return m_ttl == 0; }

  void draw();

  static void loadModel();

 private:
  uint8_t m_ttl;
  float m_roty;
  float m_rotz;
  glox::GloxPoint<> m_position;
  glox::GloxPoint<> m_dpos;
  static glox::GloxCube* m_model;
};

#endif /* PROJECTILE_HPP_ */