]> git.localhorst.tv Git - blobs.git/blob - src/world/world.cpp
more stolen stuff
[blobs.git] / src / world / world.cpp
1 #include "Planet.hpp"
2 #include "Tile.hpp"
3
4 #include <algorithm>
5
6
7 namespace blobs {
8 namespace world {
9
10 Planet::Planet(int radius)
11 : radius(radius)
12 , tiles(new Tile[TotalArea()]) {
13
14 }
15
16 Planet::~Planet() {
17 }
18
19 Planet::Planet(Planet &&other)
20 : radius(other.radius)
21 , tiles(other.tiles.release()) {
22 }
23
24 Planet &Planet::operator =(Planet &&other) {
25         radius = other.radius;
26         std::swap(tiles, other.tiles);
27         return *this;
28 }
29
30
31 void GenerateTest(Planet &p) {
32         for (int surface = 0; surface <= 5; ++surface) {
33                 for (int y = -p.Radius(); y <= p.Radius(); ++y) {
34                         for (int x = -p.Radius(); x <= p.Radius(); ++x) {
35                                 p.TileAt(surface, x, y).type = (x == 0) + (y == 0);
36                         }
37                 }
38         }
39 }
40
41 }
42 }