blob: fca108d52cf3264b6504a270cb5e754a0f138d8e (
plain)
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
|
#ifndef WORLD_H
#define WORLD_H
#include <common.h>
// Total amount of entities that can be bound to a layer
#define MAX_ENTITIES 16
// Easy shortcuts used in UIClass
#define goWorldLeft(w) if(w->toLeft){w=w->toLeft;}
#define goWorldRight(w) if(w->toRight){w=w->toRight;}
class World {
private:
struct line_t {
double start; // Where land begins, going down (i.e. y)
unsigned char color;
} __attribute__ ((packed)) *line;
unsigned int lineCount; // Size of line array, calculated in the constructor
unsigned int entCount; // Count of currently bound entities
void *entity[MAX_ENTITIES];
public:
World *behind,*infront; // As in layers
World *toLeft,*toRight; // 'new' worlds (off screen)
World(void); // Creates an empty world
World(const float width,World *l,World *r); // Creates a legit world
void draw(void); // Draws the world as well as any bound entities
void detect(vec2 *v,vec2 *vel,const float width); // Object / gravity detection
float getWidth(void); // Get coordinate width of world
void addLayer(const float width); // Creates a layer of said width behind the current one
void addEntity(void *e); // Adds (binds) an entity to the world
};
#endif // WORLD_H
|