Tinman  1.0
powerup.h
Go to the documentation of this file.
1 // Copyright (C) 2014 ISAAC LACOBA MOLINA
2 // Tinman author: Isaac Lacoba Molina
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef POWER_UP_H
18 #define POWER_UP_H
19 
20 #include <chrono>
21 #include <thread>
22 #include <future>
23 
24 #include "scene.h"
25 #include "physics.h"
26 #include "animation.h"
27 #include "meshstrider.h"
28 #include "parser.h"
29 
30 class PowerUp {
31  std::string file_;
35 
36  Ogre::SceneNode* node_;
37  Ogre::Entity* entity_;
38  btCollisionShape* shape_;
39 
40  public:
41  typedef float seconds;
42  typedef btVector3 Position;
43  typedef std::pair<Position, seconds> Location;
44  enum class Type {Nitro, MoneyBag};
45  typedef std::shared_ptr<PowerUp> shared;
46 
47  btRigidBody* body_;
48 
49  PowerUp(Scene::shared scene, Physics::shared physics,
50  Animation::shared animation);
51  virtual ~PowerUp();
52 
53  void realize(Type object);
54  void update(float delta);
55  void pick_up();
56  void reset();
57 
58  void active_animation(std::string animation_name);
59 
60  private:
61  std::vector<Location> locations_;
62  Location last_location_;
63 
64  void read_locations(std::string file);
65 
66  float start_;
67  bool removed_;
68 
69  void replace(btVector3 new_position);
70  void add_to_scene();
71  void remove_from_scene();
72 };
73 #endif
std::shared_ptr< Animation > shared
Definition: animation.h:27
btRigidBody * body_
Definition: powerup.h:47
Ogre::SceneNode * node_
Definition: powerup.h:36
void update(float delta)
Definition: powerup.cpp:70
void reset()
Definition: powerup.cpp:115
std::vector< Location > locations_
Definition: powerup.h:61
float seconds
Definition: powerup.h:41
bool removed_
Definition: powerup.h:67
void add_to_scene()
Definition: powerup.cpp:103
std::shared_ptr< Physics > shared
Definition: physics.h:33
void replace(btVector3 new_position)
Definition: powerup.cpp:94
Ogre::Entity * entity_
Definition: powerup.h:37
btCollisionShape * shape_
Definition: powerup.h:38
std::shared_ptr< Scene > shared
Definition: scene.h:43
Physics::shared physics_
Definition: powerup.h:34
std::shared_ptr< PowerUp > shared
Definition: powerup.h:45
virtual ~PowerUp()
Definition: powerup.cpp:13
void remove_from_scene()
Definition: powerup.cpp:109
void active_animation(std::string animation_name)
Definition: powerup.cpp:123
Scene::shared scene_
Definition: powerup.h:33
Definition: powerup.h:30
btVector3 Position
Definition: powerup.h:42
Location last_location_
Definition: powerup.h:62
void read_locations(std::string file)
Definition: powerup.cpp:54
std::pair< Position, seconds > Location
Definition: powerup.h:43
void pick_up()
Definition: powerup.cpp:85
float start_
Definition: powerup.h:66
Animation::shared animation_
Definition: powerup.h:32
void realize(Type object)
Definition: powerup.cpp:21
Type
Definition: powerup.h:44
std::string file_
Definition: powerup.h:31
PowerUp(Scene::shared scene, Physics::shared physics, Animation::shared animation)
Definition: powerup.cpp:4