Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
planet.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
25 #pragma once
26 
27 
28 #include "common/event.h"
29 
30 #include "math/point.h"
31 
32 #include <vector>
33 
34 
35 
36 // Graphics module namespace
37 namespace Gfx {
38 
39 class CEngine;
40 
45 struct Planet
46 {
52  float dim;
54  float speed;
56  float dir;
58  std::string name;
61 
62  // TODO: make all textures transparent?
65 
66  Planet()
67  {
68  dim = speed = dir = 0.0f;
69  transparent = false;
70  }
71 };
72 
73 
82 class CPlanet
83 {
84 public:
85  CPlanet(CEngine* engine);
86  ~CPlanet();
87 
89  void Flush();
91  bool EventProcess(const Event &event);
93  void Create(int mode, Math::Point start, float dim, float speed, float dir,
94  const std::string& name, Math::Point uv1, Math::Point uv2,
95  bool transparent);
97  bool PlanetExist();
99  void LoadTexture();
101  void Draw();
103  void SetMode(int mode);
105  int GetMode();
107 
108 protected:
110  bool EventFrame(const Event &event);
111 
112 protected:
113  CEngine* m_engine;
114 
115  float m_time;
116  int m_mode;
117  std::vector<Planet> m_planet[2];
118  bool m_planetExist;
119 };
120 
121 
122 } // namespace Gfx
123 
float dir
Direction in the sky.
Definition: planet.h:56
std::string name
Name of the texture.
Definition: planet.h:58
bool EventProcess(const Event &event)
Management of an event.
Definition: planet.cpp:58
Math::Point start
Initial position in degrees.
Definition: planet.h:48
float speed
Speed.
Definition: planet.h:54
Point struct and related functions.
void Draw()
Draws all the planets.
Definition: planet.cpp:96
Math::Point uv1
Texture mapping.
Definition: planet.h:60
Planet manager.
Definition: planet.h:82
void Create(int mode, Math::Point start, float dim, float speed, float dir, const std::string &name, Math::Point uv1, Math::Point uv2, bool transparent)
Creates a new planet.
Definition: planet.cpp:145
Planet texture definition.
Definition: planet.h:45
2D point
Definition: point.h:49
bool transparent
Transparent texture.
Definition: planet.h:64
Math::Point angle
Current position in degrees.
Definition: planet.h:50
Namespace for (new) graphics code.
Definition: app.h:49
void Flush()
Removes all the planets.
Definition: planet.cpp:48
The graphics engine.
Definition: engine.h:684
Event types, structs and event queue.
bool EventFrame(const Event &event)
Makes the planets evolve.
Definition: planet.cpp:66
bool PlanetExist()
Indicates if there is at least one planet.
Definition: planet.cpp:171
Event sent by system, interface or game.
Definition: event.h:678
void LoadTexture()
Load all the textures for the planets.
Definition: planet.cpp:85
void SetMode(int mode)
Choice of mode.
Definition: planet.cpp:176
float dim
Dimensions (0..1)
Definition: planet.h:52