-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconstants.h
113 lines (99 loc) · 2.15 KB
/
constants.h
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
107
108
109
110
111
112
113
#ifndef CONSTANTS_H
#define CONSTANTS_H
#include <Gamebuino-Meta.h>
enum State {
MAINMENU,
FADEOUT,
PLAYING
};
enum Type
{
platform,
ice,
spring,
fake_wall,
player_spawn,
fall_floor,
player,
room_title,
balloon,
big_chest,
orb,
fruit,
fly_fruit,
life_up,
key,
chest,
message,
flag
};
typedef uint8_t u8;
#define MAP_SIDE 16
#define MAP_SIZE MAP_SIDE*8
#define MAX_OBJECTS 300
#define SCREEN_H_OFFSET 16
template <typename T>
struct Vec2
{
T x {};
T y {};
};
typedef Vec2<int> Point;
typedef Vec2<float> Vec2d;
typedef Vec2<bool> Bools;
struct Hitbox {
int x = 0;
int y = 0;
int w = 8;
int h = 8;
};
void draw_time(int x, int y);
bool spikes_at(int x, int y, int w, int h, int xspd, int yspd);
int tile_at(int x, int y);
bool tile_flag_at(int x, int y, int w, int h, u8 flag);
bool ice_at(int x, int y, int w, int h);
bool solid_at(int x, int y, int w, int h);
bool maybe();
int sign(int v);
float sign(float v);
int clamp(int val, int a, int b);
float clamp(float val, float a, float b);
int appr(int val, int target, int amount);
float appr(float val, float target, float amount);
void rectfill(int x1, int y1, int x2, int y2, int c);
void circfill(int x, int y, int r, int c);
void print(const char* txt, int x, int y, int c);
void drawSprite(int spr, int x, int y, bool flip_x = false, bool flip_y = false);
bool btn(Button bouton);
bool fget(int tile_id, u8 flag);
int level_index();
bool is_title();
void next_room();
float rnd(int x);
const Button k_left = BUTTON_LEFT;
const Button k_right = BUTTON_RIGHT;
const Button k_up = BUTTON_UP;
const Button k_down = BUTTON_DOWN;
const Button k_jump = BUTTON_A;
const Button k_dash = BUTTON_B;
// extern variables
extern int max_djump;
extern bool has_dashed;
extern bool has_key;
extern int freeze;
extern int frames;
extern bool pause_player;
extern int deaths;
class Object;
class Player;
class FallFloor;
class Spring;
extern Object * objects[];
extern int objects_count;
extern bool got_fruit[];
void add_object(Object * obj);
void destroy_object(Object * obj);
void kill_player(Player * player);
void init_object(Object * object, int x, int y);
void draw_time(int x, int y);
#endif