, last(SDL_GetTicks())
, running(false)
, paused(false) {
-
+ univ.AddResource(Resource("Liquid Hydrogen", 70));
+ univ.AddResource(Resource("Liquid Qxygen", 1141));
+ univ.AddResource(Resource("Water", 999));
}
namespace space {
Resource::Resource()
-: id(-1)
-, name(nullptr) {
+: Resource("Nullpointerium", 1) {
}
-Resource::Resource(int id, const char *name)
-: id(id)
-, name(name) {
+Resource::Resource(const char *name, float dens)
+: id(-1)
+, name(name)
+, density(dens) {
}
public:
Resource();
- Resource(int id, const char *name);
+ Resource(const char *name, float density);
public:
- int ID() const { return id; }
- const char *Name() const { return name; }
-
-private:
int id;
const char *name;
+ float density;
};
return &ships.back();
}
+int Universe::AddResource(const Resource &r) {
+ resources.emplace_back(r);
+ resources.back().id = resources.size();
+ return resources.back();
+}
+
void Universe::Update(float delta) {
for (Ship &s : ships) {
#include "../graphics/Vector.h"
#include <list>
+#include <vector>
namespace space {
Ship *AddShip(const Ship &);
const std::list<Ship> &Ships() const { return ships; }
+ int AddResource(const Resource &);
+ const Resource &GetResource(int id) const { return resources[id]; }
+
public:
void Update(float deltaT);
private:
std::list<Ship> ships;
+ std::vector<Resource> resources;
};