Rev 5291 | Rev 5315 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5225 | alpine | 1 | #include "rsgamedraw.h" |
2 | #include "rsgametext.h" |
||
3 | #include "rsgamemenu.h" |
||
4 | |||
5 | #include "rskos.h" |
||
6 | |||
7 | #include "rsnoise.h" |
||
8 | |||
5243 | alpine | 9 | #include "strings.h" |
5225 | alpine | 10 | |
11 | |||
12 | void game_draw() { |
||
13 | |||
14 | int w = 320; |
||
15 | int h = 180; |
||
16 | |||
17 | |||
18 | int kk = 20; // (rskos_get_time()/1) % 160; |
||
19 | // |
||
20 | // unsigned char *c = game.framebuffer.data; |
||
21 | // |
||
22 | // int i; |
||
23 | // for (i = 0; i < w*h*4; i+=4) { |
||
24 | // c[i+0] = 10; // i/w/3; |
||
25 | // c[i+1] = (( (1*i)*(i + kk)/70) & 5) ? 70 : 0; |
||
26 | // c[i+2] = 50; |
||
27 | // c[i+3] = i % 128; |
||
28 | // }; |
||
29 | |||
30 | |||
5298 | alpine | 31 | texture_clear(&game.framebuffer, game.bg_color ); |
32 | |||
33 | game.bg_color = COLOR_BLACK; |
||
34 | |||
5225 | alpine | 35 | // texture_clear(&game.tex); |
36 | |||
37 | // texture_draw(&game.framebuffer, &game.tex, 40, 40, DRAW_MODE_ADDITIVE); |
||
38 | // texture_draw(&game.framebuffer, &game.tex, 70, 50, DRAW_MODE_ADDITIVE); |
||
39 | // texture_draw(&game.framebuffer, &game.tex, 20, 60, DRAW_MODE_ADDITIVE); |
||
40 | // texture_draw(&game.framebuffer, &game.tex, 60, 70, DRAW_MODE_ADDITIVE); |
||
41 | // |
||
42 | // texture_draw(&game.framebuffer, &game.tex, 111, 150, DRAW_MODE_ADDITIVE); |
||
43 | |||
44 | int i, c, c2, c3; |
||
45 | for (i = 0; i < 100; i++) { |
||
46 | // DEBUG10f("i = %d, v1 = %.4f, v2 = %.4f \n", i, rs_noise(kk+100, kk+i)*10, rs_noise(kk+200, kk+i+300)*10); |
||
47 | c = (0.5+0.45*rs_noise(kk+150, kk+i))*255; |
||
48 | c2 = c + 0.05*rs_noise(kk+150, kk+i)*255; |
||
49 | c3 = c2; // (0.5+0.49*rs_noise(kk+150, kk+i+2))*255; |
||
50 | texture_set_pixel(&game.framebuffer, (0.5+0.49*rs_noise(kk+1100, kk+i))*GAME_WIDTH, (0.5+0.49*rs_noise(kk+1200, kk+i+1300))*GAME_HEIGHT, |
||
51 | c + (c2<<8) + (c3<<16) + 0xFF000000); |
||
52 | }; |
||
53 | |||
54 | texture_clear(&game.tex_ground, COLOR_TRANSPARENT); |
||
55 | rs_perlin_configure(47, 4, 0.5, 1000, 256); |
||
56 | for (i = 0; i < game.tex_ground.w; i++) { |
||
57 | texture_draw_vline(&game.tex_ground, i, 25 + rs_perlin(0,i+game.tz)*25, 2, 0xFF113300); |
||
58 | texture_draw_vline(&game.tex_ground, i, 25 + rs_perlin(0,i+game.tz)*25 + 2, 999, 0xFF000000); |
||
59 | }; |
||
60 | |||
61 | |||
62 | |||
63 | if (game.status == STATUS_MENU) { |
||
64 | |||
65 | char **title = menu_titles[game.menu_index]; |
||
66 | int y = (game.menu_index == MENU_MAIN) ? 80 : 50; |
||
67 | texture_draw(&game.framebuffer, &game.tex_gui_line, 0, y+15*game.menu_item_index, DRAW_MODE_ALPHA); |
||
68 | while (*title) { |
||
69 | game_textout(20, y, (*(title))[0]==' ' ? 3 : 0 , (*(title))+1 ); // first (zero) char defines action, title starts from second (1st) char |
||
70 | title++; |
||
71 | y+=15; |
||
72 | }; |
||
73 | |||
74 | if (game.menu_index == MENU_MAIN) { |
||
75 | |||
5291 | alpine | 76 | for (i = 0; i < 3; i++) { |
5225 | alpine | 77 | texture_draw(&game.framebuffer, &game.tex_rocks[i], 250+80*rs_noise(i,150), 60+60*rs_noise(i,1110), DRAW_MODE_ADDITIVE ); |
78 | }; |
||
79 | |||
5243 | alpine | 80 | game_textout( GAME_WIDTH/2 - 100, 40, 1, "HELI0THRYX"); |
5291 | alpine | 81 | // game_textout( GAME_WIDTH/2 - 8, 58, 3, "TECHDEM0"); |
5243 | alpine | 82 | game_textout( 2, GAME_HEIGHT-10, 2, L_BOTTOM_LINE_DEVELOPER_INFO); |
5225 | alpine | 83 | }; |
84 | |||
85 | } |
||
86 | else { |
||
87 | |||
5291 | alpine | 88 | int i, j; |
89 | game_obj_t *obj; |
||
90 | for (i = 0; i < game.objs_count; i++) { |
||
91 | obj = &(game.objs[i]); |
||
92 | |||
93 | if (obj->obj_type == OBJ_BULLET) { |
||
94 | |||
95 | texture_set_pixel(&game.framebuffer, obj->x-4, obj->y, 0xFF00BB00); |
||
96 | texture_set_pixel(&game.framebuffer, obj->x-3, obj->y, 0xFF00CC00); |
||
97 | texture_set_pixel(&game.framebuffer, obj->x-2, obj->y, 0xFF00DD00); |
||
98 | texture_set_pixel(&game.framebuffer, obj->x-1, obj->y, 0xFF00EE00); |
||
99 | texture_set_pixel(&game.framebuffer, obj->x-0, obj->y, 0xFF00FF00); |
||
100 | |||
101 | } |
||
102 | else if (obj->obj_type == OBJ_RED_BULLET) { |
||
103 | |||
104 | texture_set_pixel(&game.framebuffer, obj->x-1, obj->y-0, 0xFFFF0000); |
||
105 | texture_set_pixel(&game.framebuffer, obj->x-1, obj->y-1, 0xFFFF6600); |
||
106 | texture_set_pixel(&game.framebuffer, obj->x-1, obj->y-0, 0xFFFF0000); |
||
107 | texture_set_pixel(&game.framebuffer, obj->x-0, obj->y-1, 0xFFFF0000); |
||
108 | texture_set_pixel(&game.framebuffer, obj->x-0, obj->y-0, 0xFFFF6600); |
||
109 | texture_set_pixel(&game.framebuffer, obj->x+1, obj->y-1, 0xFFFF0000); |
||
110 | texture_set_pixel(&game.framebuffer, obj->x+1, obj->y-0, 0xFFFF6600); |
||
111 | |||
112 | } |
||
113 | else if (obj->obj_type == OBJ_EXPLOSION) { |
||
114 | |||
115 | // char s[] = "00 "; |
||
116 | // s[0] += obj->t / 10; |
||
117 | // s[1] += obj->t % 10; |
||
118 | // game_textout( obj->x, obj->y, 0, s ); |
||
119 | |||
120 | texture_draw( &game.framebuffer, &game.tex_explosions[ obj->t ], obj->x - obj->radius, obj->y - obj->radius, DRAW_MODE_ALPHA ); |
||
121 | |||
122 | } |
||
123 | else if (obj->obj_type == OBJ_ROCK) { |
||
124 | texture_draw( &game.framebuffer, &game.tex_rocks[ obj->tag ], obj->x - obj->radius, obj->y - obj->radius, DRAW_MODE_ALPHA ); |
||
125 | } |
||
126 | else if (obj->obj_type == OBJ_MINIROCK) { |
||
127 | texture_draw( &game.framebuffer, &game.tex_minirocks[ obj->tag ], obj->x - obj->radius, obj->y - obj->radius, DRAW_MODE_ALPHA ); |
||
128 | } |
||
129 | else if (obj->obj_type == OBJ_TURRET) { |
||
130 | texture_draw( &game.framebuffer, &game.tex_rocks[ 0 ], obj->x - obj->radius, obj->y - obj->radius, DRAW_MODE_ALPHA ); |
||
131 | texture_draw( &game.framebuffer, &game.tex_rocks[ 0 ], obj->x - obj->radius, obj->y - obj->radius, DRAW_MODE_ADDITIVE ); |
||
132 | |||
133 | for (j = 0; j < 1 + (obj->tag)/6; j++) { |
||
134 | texture_draw_vline(&game.framebuffer, obj->x - obj->radius + j*4 + 0, obj->y - obj->radius - 16, 8, 0xFF993333 ); |
||
135 | texture_draw_vline(&game.framebuffer, obj->x - obj->radius + j*4 + 1, obj->y - obj->radius - 16, 8, 0xFF993333 ); |
||
136 | texture_draw_vline(&game.framebuffer, obj->x - obj->radius + j*4 + 2, obj->y - obj->radius - 16, 8, 0xFF993333 ); |
||
137 | }; |
||
138 | |||
139 | } |
||
140 | |||
141 | }; |
||
5225 | alpine | 142 | |
5291 | alpine | 143 | |
144 | texture_draw(&game.framebuffer, &game.tex_ship[0], game.player_x-8, game.player_y-4, DRAW_MODE_ALPHA); |
||
145 | texture_draw(&game.framebuffer, &game.tex_ship[1], game.player_x-8, game.player_y-4, DRAW_MODE_ALPHA); |
||
146 | texture_draw(&game.framebuffer, &game.tex_ship[2], game.player_x, game.player_y-4, DRAW_MODE_ALPHA); |
||
147 | texture_draw(&game.framebuffer, &game.tex_ship[3], game.player_x, game.player_y-4, DRAW_MODE_ALPHA); |
||
148 | |||
149 | |||
150 | if ( game.stage == 0 ) { |
||
151 | game_textout_at_center( 0, GAME_HEIGHT + 50 - game.stage_timer*(GAME_HEIGHT+50)/50, 1, "LEVEL 1" ); |
||
152 | game_textout_at_center( 0, GAME_HEIGHT*2/3, 2, L_TECHDEMO_LINE1 ); |
||
153 | } |
||
154 | else { |
||
155 | |||
156 | char s_score[] = "000"; |
||
157 | s_score[0] += game.score / 100; |
||
158 | s_score[1] += (game.score / 10) % 10; |
||
159 | s_score[2] += (game.score / 1) % 10; |
||
160 | |||
161 | game_textout_at_center(0, 10, 3, s_score); |
||
162 | |||
163 | |||
5225 | alpine | 164 | }; |
165 | |||
166 | |||
5291 | alpine | 167 | |
168 | |||
169 | char s_health[] = "HEALTH: 0 "; |
||
170 | char s_ammo[] = "AMM0: 00 "; |
||
171 | |||
172 | s_health[8] += game.health; |
||
173 | s_ammo[6] += game.ammo / 10; |
||
174 | s_ammo[7] += game.ammo % 10; |
||
175 | |||
176 | game_textout(8, 8, 2, s_health); |
||
177 | game_textout(GAME_WIDTH - 12 - GAME_AMMO_MAX*2 - 1, 8, 2, s_ammo); |
||
178 | |||
179 | for (i = 0; i < game.ammo; i++) { |
||
180 | texture_draw_vline(&game.framebuffer, GAME_WIDTH - 12 - GAME_AMMO_MAX*2 + i*2, 20, 8, 0xFF3366FF ); |
||
181 | }; |
||
182 | |||
183 | int health_color = 0xFF339933; |
||
184 | if (game.health < 5) { |
||
185 | health_color = 0xFF808010; |
||
186 | }; |
||
187 | if (game.health < 3) { |
||
188 | health_color = 0xFFFF3300; |
||
189 | }; |
||
190 | |||
191 | for (i = 0; i < game.health; i++) { |
||
192 | texture_draw_vline(&game.framebuffer, 8 + i*4 + 0, 20, 8, health_color ); |
||
193 | texture_draw_vline(&game.framebuffer, 8 + i*4 + 1, 20, 8, health_color ); |
||
194 | texture_draw_vline(&game.framebuffer, 8 + i*4 + 2, 20, 8, health_color ); |
||
195 | }; |
||
196 | |||
197 | |||
198 | |||
199 | |||
200 | // game_textout( 2, 12, 2, L_TECHDEMO_LINE2 ); |
||
201 | |||
5225 | alpine | 202 | }; |
203 | |||
5291 | alpine | 204 | texture_draw(&game.tex_ground, &game.tex_clouds, game.tz, 0, /* game.tx, game.ty, */ DRAW_MODE_ADDITIVE | DRAW_TILED_FLAG ); |
205 | texture_draw(&game.framebuffer, &game.tex_ground, 0, GAME_HEIGHT-50, DRAW_MODE_ALPHA); |
||
5225 | alpine | 206 | |
5291 | alpine | 207 | |
5225 | alpine | 208 | rskos_draw_area(0, 0, w, h, game.window_scale, game.framebuffer.data, game.scaled_framebuffer); |
209 | |||
210 | };>>>>>>>>16)><16)>8)><8)>>> |
||
211 |