Rev 5243 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5225 | alpine | 1 | #ifndef RSGAME_H_INCLUDED |
2 | #define RSGAME_H_INCLUDED |
||
3 | |||
4 | /* |
||
5 | |||
6 | Heliothryx |
||
7 | Game by Roman Shuvalov |
||
8 | |||
9 | */ |
||
10 | |||
11 | |||
12 | #include "rskos.h" |
||
13 | #include "rs/rsplatform.h" |
||
14 | //#include "rs/rstexture.h" |
||
15 | //#include "rs/rsshader.h" |
||
16 | //#include "rs/rsgl.h" |
||
17 | #include "rs/rsdebug.h" |
||
18 | #include "rs/rsbits.h" |
||
19 | |||
20 | //#include "rs/rskeyboard.h" |
||
21 | |||
22 | //#include "rs/rsaudio.h" |
||
23 | |||
24 | //#include "rs/rsfile.h" |
||
25 | |||
26 | //#include "rs/rsvbo.h" |
||
27 | //#include "rs/rsfbo.h" |
||
28 | |||
29 | //#include "rs/rsthread.h" |
||
30 | |||
31 | #include "rs/rsmx.h" |
||
32 | |||
33 | |||
34 | |||
35 | |||
36 | #define GAME_LANG_EN 0 |
||
37 | #define GAME_LANG_RU 1 |
||
38 | |||
39 | #define GAME_WIDTH 320 |
||
40 | #define GAME_HEIGHT 180 |
||
41 | |||
42 | |||
43 | typedef struct { |
||
44 | unsigned int status; |
||
45 | int w; |
||
46 | int h; |
||
47 | unsigned char *data; // BGRA BGRA |
||
48 | } rs_texture_t; |
||
49 | |||
50 | |||
51 | // for little-endian |
||
52 | typedef union color_t { |
||
53 | int d; // 0x44332211 (ARGB) |
||
54 | struct { |
||
55 | unsigned char b; // 0x11 |
||
56 | unsigned char g; // 0x22 |
||
57 | unsigned char r; // 0x33 |
||
58 | unsigned char a; // 0x44 |
||
59 | }; |
||
60 | } color_t; |
||
61 | |||
62 | // for little-endian (ARGB) |
||
63 | #define COLOR_BLACK 0xFF000000 |
||
64 | #define COLOR_TRANSPARENT 0x00000000 |
||
65 | #define COLOR_DARK_RED 0xFF660000 |
||
66 | |||
67 | |||
68 | |||
69 | void texture_init(rs_texture_t *tex, int w, int h); |
||
70 | void texture_free(rs_texture_t *tex); |
||
71 | void texture_clear(rs_texture_t *tex, unsigned int color); |
||
72 | void texture_draw(rs_texture_t *dest, rs_texture_t *src, int x, int y, int mode); |
||
73 | void texture_draw_vline(rs_texture_t *tex, int x, int y, int l, unsigned int color); |
||
74 | void texture_draw_hline(rs_texture_t *tex, int x, int y, int l, unsigned int color); |
||
75 | void texture_set_pixel(rs_texture_t *tex, int x, int y, unsigned int color); |
||
76 | |||
77 | unsigned char clamp_byte(int value); |
||
78 | |||
79 | #define DRAW_MODE_REPLACE 0 |
||
80 | #define DRAW_MODE_ADDITIVE 1 |
||
81 | #define DRAW_MODE_ALPHA 2 |
||
82 | |||
83 | #define DRAW_MODE_MASK 0x0000FFFF |
||
84 | #define DRAW_TILED_FLAG 0x00010000 |
||
85 | |||
86 | |||
87 | |||
88 | typedef struct { |
||
89 | unsigned int status; |
||
90 | int length_samples; |
||
91 | SNDBUF hbuf; |
||
92 | signed short *data; |
||
93 | } rs_soundbuf_t; |
||
94 | |||
95 | void soundbuf_init(rs_soundbuf_t *snd, int length); |
||
96 | void soundbuf_free(rs_soundbuf_t *snd); |
||
97 | void soundbuf_fill(rs_soundbuf_t *snd, int amp, int freq_div); |
||
98 | void soundbuf_sin(rs_soundbuf_t *snd, float freq); |
||
99 | void soundbuf_sin_fade(rs_soundbuf_t *snd, float freq); |
||
100 | void soundbuf_play(rs_soundbuf_t *snd); |
||
101 | void soundbuf_stop(rs_soundbuf_t *snd); |
||
102 | |||
103 | // Game Registry |
||
104 | |||
105 | #define ROCKS_COUNT 3 |
||
106 | #define FONTS_COUNT 4 |
||
107 | |||
108 | #define STATUS_MENU 0 |
||
109 | #define STATUS_PLAYING 1 |
||
110 | #define STATUS_PAUSED 2 |
||
111 | |||
112 | |||
113 | #define RS_ARROW_LEFT_MASK 0x01 |
||
114 | #define RS_ARROW_DOWN_MASK 0x02 |
||
115 | #define RS_ARROW_UP_MASK 0x04 |
||
116 | #define RS_ARROW_RIGHT_MASK 0x08 |
||
117 | #define RS_ATTACK_KEY_MASK 0x10 |
||
118 | |||
119 | #define BULLETS_COUNT 8 |
||
120 | |||
121 | #define GAME_SHOOT_PERIOD 3 |
||
122 | |||
123 | typedef struct rs_game_t { |
||
124 | rs_texture_t framebuffer; |
||
125 | unsigned char *scaled_framebuffer; // 24-bit BGRBGRBGR... for direct drawing |
||
126 | |||
127 | rs_texture_t tex; |
||
128 | |||
129 | rs_texture_t tex_clouds; |
||
130 | rs_texture_t tex_ground; |
||
131 | |||
132 | rs_texture_t tex_ship[4]; |
||
133 | rs_texture_t tex_rocks[ROCKS_COUNT]; |
||
134 | |||
135 | rs_texture_t tex_font[64*FONTS_COUNT]; |
||
136 | |||
137 | rs_texture_t tex_gui_line; |
||
138 | |||
139 | |||
140 | rs_soundbuf_t sound_test1; |
||
141 | rs_soundbuf_t sound_test2; |
||
142 | rs_soundbuf_t sound_test3; |
||
143 | |||
144 | int status; |
||
145 | |||
146 | unsigned int keyboard_state; |
||
147 | |||
148 | int menu_index; |
||
149 | int menu_item_index; |
||
150 | |||
151 | int window_scale; |
||
152 | |||
153 | int tx; |
||
154 | int ty; |
||
155 | int tz; |
||
156 | |||
157 | int bullet_x[BULLETS_COUNT]; |
||
158 | int bullet_y[BULLETS_COUNT]; |
||
159 | int bullet_index; |
||
160 | int shoot_delay; |
||
161 | int shoot_keypressed; |
||
162 | |||
163 | } rs_game_t; |
||
164 | |||
165 | extern rs_game_t game; |
||
166 | void game_reg_init(); |
||
167 | |||
168 | /* __ |
||
169 | /cc\ |
||
170 | /aaaa\ |
||
171 | |kkkkkk| <-- Easter Egg |
||
172 | \eeee/ |
||
173 | ------------------------------- */ |
||
174 | |||
175 | void GameProcess(); |
||
176 | |||
177 | void game_ding(int i); |
||
178 | |||
179 | void GameInit(); |
||
180 | void GameTerm(); |
||
181 | |||
182 | void GameKeyDown(int key, int first); |
||
183 | void GameKeyUp(int key); |
||
184 | |||
185 | void game_change_window_scale(int d); |
||
186 | |||
187 | #endif // RSGAME_H_INCLUDED--> |