-
Notifications
You must be signed in to change notification settings - Fork 0
/
tile.hpp
98 lines (84 loc) · 2.19 KB
/
tile.hpp
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
#include <vector>
#include <string>
#include <stdint.h>
#include "v2d.h"
#pragma once
enum class mutationType;
enum class TileType;
// class v2d;
class SDL_Renderer;
struct Gene{
std::vector<uint8_t> bases;
std::string toString();
};
class Level;
// Represents a single tile on the world grid
class Tile{
public:
Tile(int x, int y, uint32_t color);
virtual void update(uint8_t *pixels);
// virtual void update(std::vector<Tile*> *tiles);
int x, y;
// int width, height;
TileType type;
uint32_t color;
};
class Thing{
public:
Thing(int x, int y, TileType type);
~Thing();
void randomize();
// int x;
// int y;
v2d pos;
uint32_t color;
TileType type;
std::vector<Tile> tiles;
virtual bool update(uint8_t *pixels, Level* lvl);
};
class Resource : public Thing{
public:
Resource(int x, int y, bool food);
// void draw(uint8_t *pixels);
bool update(uint8_t *pixels, Level* lvl);
// void randomize();
bool food;
uint32_t color = 0xFF6E9055;
};
class Creature : public Thing{
private:
void pSub();
void pIns();
int digitConcat(std::vector<int> digits);
int transcribeIndex;
std::vector<int> transcribedProteins;
// int distance = RAND_MAX;
bool wander;
v2d wanderDirection;
long wanderTime;
Resource *closest_food = nullptr;
bool found_food = false;
v2d distance = v2d(999999, 999999);
v2d foodPos = v2d(0, 0);
protected:
uint32_t geneIndex;
public:
std::vector<Gene> genome;
int mutate(int count, mutationType mutation);
Creature(int x, int y, int species);
~Creature();
bool update(uint8_t *pixels, Level* lvl);
int readNext();
void reset();
int species;
uint32_t size;
// uint32_t color = 0x3C4CE7;
uint32_t color = 0xa879fd;
float energy = 400;
};
class Border : public Thing{
public:
Border(int x, int y);
bool update(uint8_t *pixels, Level* lvl);
uint32_t color = 0xFF926E5F;
};