-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobals.h
More file actions
100 lines (85 loc) · 2.23 KB
/
globals.h
File metadata and controls
100 lines (85 loc) · 2.23 KB
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
/*
* Licensed under GNU GPL v2
* Author(s): Emil Österlund, Christofer Oden,
* Created on: 09102?
*/
#ifndef GLOBALS_H
#define GLOBALS_H
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_ttf.h>
#include <cstdio>
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600
#define SCREEN_BPP 32
#define UPDATES_PER_SECOND 999
#define PANEL_WIDTH 160
#define TILE_SIZE 32
#define NW 1
#define N 2
#define NE 3
#define E 4
#define SE 5
#define S 6
#define SW 7
#define W 8
// Returns a random value between 0.0 and 1.0
#define CHANCE(p) ((rand() / (double)RAND_MAX) < p ? true : false)
enum UnitType {
UNIT_DRAGON,
UNIT_INFANTRY,
UNIT_ARMOR,
UNIT_HOWITZER,
UNIT_MGUNNERORC,
UNIT_BEHOLDER
};
enum BattleOutcome {
OUTCOME_NONE,
OUTCOME_VICTORY,
OUTCOME_DRAW,
OUTCOME_DEFEAT
};
// Terrain sprites
extern SDL_Rect RECT_GRASS;
extern SDL_Rect RECT_CLIFF_NW;
extern SDL_Rect RECT_CLIFF_N;
extern SDL_Rect RECT_CLIFF_NE;
extern SDL_Rect RECT_CLIFF_W;
extern SDL_Rect RECT_WATER;
extern SDL_Rect RECT_CLIFF_E;
extern SDL_Rect RECT_CLIFF_SW;
extern SDL_Rect RECT_CLIFF_S;
extern SDL_Rect RECT_CLIFF_SE;
extern SDL_Rect RECT_OUTER_CLIFF_SE;
extern SDL_Rect RECT_OUTER_CLIFF_SW;
extern SDL_Rect RECT_OUTER_CLIFF_NE;
extern SDL_Rect RECT_OUTER_CLIFF_NW;
extern SDL_Rect RECT_TREES_NW;
extern SDL_Rect RECT_TREES_N;
extern SDL_Rect RECT_TREES_NE;
extern SDL_Rect RECT_TREES_W;
extern SDL_Rect RECT_TREES;
extern SDL_Rect RECT_TREES_E;
extern SDL_Rect RECT_TREES_SW;
extern SDL_Rect RECT_TREES_S;
extern SDL_Rect RECT_TREES_SE;
// Unit sprites;
extern SDL_Rect RECT_DRAGON;
extern SDL_Rect RECT_INFANTRY;
extern SDL_Rect RECT_ARMOR;
extern SDL_Rect RECT_HOWITZER;
extern SDL_Rect RECT_MGUNNERORC;
extern SDL_Rect RECT_BEHOLDER;
extern SDL_Rect RECT_FACTORY;
// Interface sprites
extern SDL_Rect RECT_MARKER;
extern SDL_Rect RECT_SHROUD;
SDL_Surface *load_image(const char* filename);
TTF_Font *load_font(const char* fontname, int size);
void apply_surface(int x, int y, SDL_Surface* source,
SDL_Surface* canvas, SDL_Rect* clip = NULL);
SDL_Rect *rectcpy(SDL_Rect *dest, SDL_Rect *source);
void blit_string(int x, int y, const char *str,
SDL_Surface *dest, SDL_Surface *fontMap);
void put_pixel(int x, int y, Uint32 pixel, SDL_Surface *dest);
#endif