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