File: planets.h

package info (click to toggle)
qonk 0.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,076 kB
  • ctags: 2,026
  • sloc: cpp: 14,978; sh: 3,464; makefile: 200
file content (106 lines) | stat: -rw-r--r-- 2,347 bytes parent folder | download | duplicates (3)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright 2005 by Anthony Liekens anthony@liekens.net

#ifndef PLANETS_H
#define PLANETS_H

#include <list>

#include "actions.h"
#include "coordinate.h"

class Ship;
class Universe;
class Player;
class Selection;

class Planet {
private:
	Universe* universe;
	Player* owner;
	int rotationSpeed, rotationOffset;
	double rotationDistance;
	int shipCreationSpeed;
	int size;
	bool isAMoon, selected, sourceSelected, nearestPlanet;
	Planet* mother;
	std::list< Ship* > residentShips;
	Uint32 buildStartTime, buildEndTime;
  
  Coordinate locationVector;
	
public:
	Planet(); // make a planet
  
	void makeMoon( Planet* );
  Coordinate getLocation() const;
	
	void addResident( Ship* ship, Uint32 time );
	void createShip( const Uint32& time);
	void removeResident( Ship* ship );
	
	void render(Uint32) const;
	void renderOrbit( ) const;
	void renderBuildProgress(Uint32) const;

  void update(Uint32);	
	void updateShipLocations(Uint32);
	
	double distance( Planet* planet );
	
	int numberOfResidentShips() { return residentShips.size(); }
	void setSourceSelected( bool selected );
	bool isSourceSelected() { return sourceSelected; }

	void setNearestPlanet(bool b);
	bool isNearestPlanet() { return nearestPlanet; }

  void moveResidentsTo(Uint32, Planet *, int);
	
	void setSelected( bool selected );
	void setUniverse( Universe* universe );
	bool getMoon() const { return isAMoon; }

  
  void setOwner(Player *);
  Player* getOwner() const { return owner; } 

};

class Planets : public std::list< Planet *> { 
public:
	Planets();
	Planets( int numberOfPlanets, int numberOfMoons );
  ~Planets();
	
	void addPlanets( int numberOfPlanets );
	void addMoons( int numberOfMoons );

	void render(Uint32) const;
	void renderOrbits( ) const;
	
	Planet* closestToCoordinate( const Coordinate& c );
	Planet* closestToCoordinate( const Coordinate& c, double treshold );
	
	void select( Selection selection );
	void sourceSelect( Selection *selection, Player *owner );
	
	void update(Uint32);
	
	void setUniverse( Universe* universe );
	
	Planet* getRandomPlanet();
	Planet* getRandomEnemyPlanet( Player* );
	Planet* getRandomFriendlyPlanet( Player* );
	Planet* getRandomNearbyPlanet( Planet* );
	
};

class CreateShipAction : public Action {
private:
	Planet *planet;
public:
	CreateShipAction(Planet *);
	void execute( const Uint32& time );
};

#endif