Colobot
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-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.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 #include "graphics/engine/planet_type.h"
28 
29 #include "math/point.h"
30 
31 #include <vector>
32 
33 struct Event;
34 
35 // Graphics module namespace
36 namespace Gfx
37 {
38 
39 class CEngine;
40 
49 class CPlanet
50 {
51 public:
52  CPlanet(CEngine* engine);
53  ~CPlanet();
54 
56  void Flush();
58  bool EventProcess(const Event &event);
60  void Create(PlanetType type, Math::Point start, float dim, float speed, float dir,
61  const std::string& name, Math::Point uv1, Math::Point uv2,
62  bool transparent);
64  bool PlanetExist();
66  void LoadTexture();
68  void Draw();
69 
72 
73 protected:
75  bool EventFrame(const Event &event);
76 
77 protected:
78  CEngine* m_engine = nullptr;
79  float m_time = 0.0f;
80  PlanetType m_visibleType = PlanetType::Sky;
81 
86  struct Planet
87  {
89  PlanetType type = PlanetType::Sky;
95  float dim = 0.0f;
97  float speed = 0.0f;
99  float dir = 0.0f;
101  std::string name;
104 
105  // TODO: make all textures transparent?
107  bool transparent = false;
108  };
109  std::vector<Planet> m_planets;
110 };
111 
112 
113 } // namespace Gfx
114 
bool EventProcess(const Event &event)
Management of an event.
Definition: planet.cpp:57
Point struct and related functions.
void SetVisiblePlanetType(PlanetType type)
Set which planet types to display.
Definition: planet.cpp:174
void Draw()
Draws all the planets.
Definition: planet.cpp:95
std::string name
Name of the texture.
Definition: planet.h:101
void Create(PlanetType type, 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:147
Planet manager.
Definition: planet.h:49
2D point
Definition: point.h:50
Namespace for (new) graphics code.
Definition: app.h:49
Planet texture definition.
Definition: planet.h:86
void Flush()
Removes all the planets.
Definition: planet.cpp:50
The graphics engine.
Definition: engine.h:585
Math::Point angle
Current position in degrees.
Definition: planet.h:93
bool EventFrame(const Event &event)
Makes the planets evolve.
Definition: planet.cpp:65
Math::Point start
Initial position in degrees.
Definition: planet.h:91
bool PlanetExist()
Indicates if there is at least one planet.
Definition: planet.cpp:169
Event sent by system, interface or game.
Definition: event.h:735
void LoadTexture()
Load all the textures for the planets.
Definition: planet.cpp:87
PlanetType
Type of planet which determines when it is displayed.
Definition: planet_type.h:29
Math::Point uv1
Texture mapping.
Definition: planet.h:103