Subversion Repositories Kolibri OS

Rev

Rev 5310 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5310 Rev 5315
Line 94... Line 94...
94
 
94
 
95
    
95
    
96
    if (game.health < 1) {
96
    if (game.health < 1) {
-
 
97
        game.status = STATUS_MENU;
-
 
98
        menu_open( MENU_GAME_OVER );
-
 
99
        
-
 
100
        level_passed_score_str[1] = '0' + (game.score / 1000) % 10;
-
 
101
        level_passed_score_str[2] = '0' + (game.score / 100) % 10;
-
 
102
        level_passed_score_str[3] = '0' + (game.score / 10) % 10;
97
        game.status = STATUS_MENU;
103
        level_passed_score_str[4] = '0' + (game.score / 1) % 10;
Line 98... Line 104...
98
        menu_open( MENU_GAME_OVER );
104
        
Line 99... Line 105...
99
    };
105
    };
Line 100... Line 106...
100
    
106
    
Line -... Line 107...
-
 
107
};
-
 
108
 
-
 
109
 
101
};
110
void GameProcess() {
Line 102... Line 111...
102
 
111
    
Line 103... Line 112...
103
 
112
    if (game.status == STATUS_PLAYING) {
Line 115... Line 124...
115
        
124
        
Line 116... Line 125...
116
//                if (game.ammo > 0) {
125
//                if (game.ammo > 0) {
117
                    
126
                    
118
                    game.shoot_restore_delay = 0;
127
                    game.shoot_restore_delay = 0;
119
                    game.ammo--;
128
                    game.ammo--;
Line 120... Line 129...
120
                    soundbuf_play(&game.sound_test1, 0);
129
                    soundbuf_play(&game.sound_shoot, 0);
Line 121... Line 130...
121
                    game_obj_add( game_obj( OBJ_BULLET, 0, 0, 0, game.player_x+5, game.player_y, 0, 0.0) );
130
                    game_obj_add( game_obj( OBJ_BULLET, 0, 0, 0, game.player_x+5, game.player_y, 0, 0.0) );
-
 
131
                    
-
 
132
//                };
-
 
133
                
122
                    
134
                game.shoot_delay = 1; // -= GAME_SHOOT_PERIOD;
Line 123... Line 135...
123
//                };
135
                
124
                
136
                
125
                game.shoot_delay -= GAME_SHOOT_PERIOD;
137
                
Line 126... Line 138...
126
                game.shoot_keypressed = 0;
138
                game.shoot_keypressed = 0;
127
            
139
            
Line 128... Line 140...
128
            };
140
            };
Line 129... Line 141...
129
        }
141
        }
Line 130... Line 142...
130
        else {
142
        else {
131
            
143
            
132
            if (game.ammo < GAME_AMMO_MAX) {
144
            if (game.ammo < GAME_AMMO_MAX) {
133
                game.shoot_restore_delay++;
145
                game.shoot_restore_delay++;
Line 134... Line 146...
134
                
146
                
Line 135... Line 147...
135
                if (game.shoot_restore_delay > GAME_SHOOT_PERIOD * 2) {
147
                if (game.shoot_restore_delay > c_shoot_restore_delay) {
Line 156... Line 168...
156
        int rock_speed = 6;
168
        int rock_speed = 6;
Line 157... Line 169...
157
        
169
        
158
        game.player_x += speed * ( is_key_pressed(RS_ARROW_RIGHT_MASK) - is_key_pressed(RS_ARROW_LEFT_MASK) );
170
        game.player_x += speed * ( is_key_pressed(RS_ARROW_RIGHT_MASK) - is_key_pressed(RS_ARROW_LEFT_MASK) );
Line 159... Line 171...
159
        game.player_y += speed * ( is_key_pressed(RS_ARROW_DOWN_MASK) - is_key_pressed(RS_ARROW_UP_MASK) );
171
        game.player_y += speed * ( is_key_pressed(RS_ARROW_DOWN_MASK) - is_key_pressed(RS_ARROW_UP_MASK) );
160
        
172
        
Line 161... Line 173...
161
        game.player_x = rs_clamp_i(game.player_x, 5, GAME_WIDTH-25);
173
        game.player_x = rs_clamp_i(game.player_x, 15, GAME_WIDTH - 45);
Line -... Line 174...
-
 
174
        game.player_y = rs_clamp_i(game.player_y, 15, GAME_HEIGHT - 45);
-
 
175
        
Line 162... Line 176...
162
        game.player_y = rs_clamp_i(game.player_y, 5, GAME_HEIGHT - 25);
176
        game.tz += 1;
Line 183... Line 197...
183
//            game.stage = 4;
197
//            game.stage = 4;
Line 184... Line 198...
184
            
198
            
185
            // rocks
199
            // rocks
186
            next_rock_timer--;
200
            next_rock_timer--;
187
            if (next_rock_timer < 1) {
201
            if (next_rock_timer < 1) {
188
                next_rock_timer = 9 + rs_rand()%16;
202
                next_rock_timer = c_rocktimer_const + rs_rand()%c_rocktimer_var;
-
 
203
                //game_obj_add( game_obj( ((rs_rand() % 512) > 256) ? OBJ_ROCK : OBJ_MINIROCK, 0, rs_rand() % ROCKS_COUNT , 32, GAME_WIDTH + 100, 30 + rs_rand()%(GAME_HEIGHT-60), 0, 0.0 ) );
-
 
204
                
-
 
205
                int flagsin = 0;
-
 
206
                if ( game.stage_level > 4 ) {
-
 
207
                    if ( rs_rand()%1024 < (16*game.stage_level) ) {
-
 
208
                        flagsin = OBJ_FLAG_SIN;
-
 
209
                    };
-
 
210
                };
189
                //game_obj_add( game_obj( ((rs_rand() % 512) > 256) ? OBJ_ROCK : OBJ_MINIROCK, 0, rs_rand() % ROCKS_COUNT , 32, GAME_WIDTH + 100, 30 + rs_rand()%(GAME_HEIGHT-60), 0, 0.0 ) );
211
                
190
                game_obj_add( game_obj( OBJ_ROCK, OBJ_FLAG_ENEMY, rs_rand() % ROCKS_COUNT , game.tex_rocks[0].w/2, GAME_WIDTH + 50, 30 + rs_rand()%(GAME_HEIGHT-90), 0, 0.0 ) );
212
                game_obj_add( game_obj( OBJ_ROCK, OBJ_FLAG_ENEMY | flagsin, rs_rand() % ROCKS_COUNT , game.tex_rocks[0].w/2, GAME_WIDTH + 50, 30 + rs_rand()%(GAME_HEIGHT-90), 0, 0.0 ) );
Line 191... Line 213...
191
            };
213
            };
Line 192... Line 214...
192
        
214
        
Line 193... Line 215...
193
            next_stage_after_sec(12);
215
            next_stage_after_sec(12);
Line -... Line 216...
-
 
216
            
-
 
217
        }
194
            
218
        
Line 195... Line 219...
195
        }
219
        if (game.stage == 2) {
Line 196... Line 220...
196
        
220
                
Line 197... Line 221...
197
        if (game.stage == 2) {
221
            BIT_SET (game.flags, GAME_FLAG_INSTRUCTIONS_PASSED);
198
            
222
            
199
            next_stage_after_sec(4);
223
            next_stage_after_sec(4);
200
            
224
            
201
        }
225
        }
-
 
226
        
-
 
227
        else if (game.stage == 3) {
-
 
228
            
-
 
229
            // rocks
-
 
230
            next_rock_timer--;
-
 
231
            if (next_rock_timer < 1) {
-
 
232
                next_rock_timer = c_rocktimer_const + 1 + rs_rand()%c_rocktimer_var;
-
 
233
                //game_obj_add( game_obj( ((rs_rand() % 512) > 256) ? OBJ_ROCK : OBJ_MINIROCK, 0, rs_rand() % ROCKS_COUNT , 32, GAME_WIDTH + 100, 30 + rs_rand()%(GAME_HEIGHT-60), 0, 0.0 ) );
202
        
234
 
203
        else if (game.stage == 3) {
235
                int flagsin = 0;
Line 204... Line 236...
204
            
236
                if ( game.stage_level > 2 ) {
Line 205... Line 237...
205
            // rocks
237
                    if ( rs_rand()%1024 < (16*game.stage_level) ) {
Line 237... Line 269...
237
        else if (game.stage == 6) {
269
        else if (game.stage == 6) {
Line 238... Line 270...
238
            
270
            
239
            // mix rocks
271
            // mix rocks
240
            next_rock_timer--;
272
            next_rock_timer--;
241
            if (next_rock_timer < 1) {
273
            if (next_rock_timer < 1) {
-
 
274
                next_rock_timer = c_rocktimer_const + rs_rand()%(c_rocktimer_var-3);
-
 
275
                
-
 
276
                int flagsin = 0;
-
 
277
                if ( game.stage_level > 3 ) {
-
 
278
                    if ( rs_rand()%1024 < (16*game.stage_level) ) {
-
 
279
                        flagsin = OBJ_FLAG_SIN;
-
 
280
                    };
-
 
281
                };
242
                next_rock_timer = 9 + rs_rand()%12;
282
                
243
                //game_obj_add( game_obj( ((rs_rand() % 512) > 256) ? OBJ_ROCK : OBJ_MINIROCK, 0, rs_rand() % ROCKS_COUNT , 32, GAME_WIDTH + 100, 30 + rs_rand()%(GAME_HEIGHT-60), 0, 0.0 ) );
283
                //game_obj_add( game_obj( ((rs_rand() % 512) > 256) ? OBJ_ROCK : OBJ_MINIROCK, 0, rs_rand() % ROCKS_COUNT , 32, GAME_WIDTH + 100, 30 + rs_rand()%(GAME_HEIGHT-60), 0, 0.0 ) );
244
                game_obj_add( game_obj( rs_rand()%1024 < 768 ? OBJ_MINIROCK : OBJ_ROCK, OBJ_FLAG_ENEMY, rs_rand() % ROCKS_COUNT , 
284
                game_obj_add( game_obj( rs_rand()%1024 < 768 ? OBJ_MINIROCK : OBJ_ROCK, OBJ_FLAG_ENEMY | flagsin, rs_rand() % ROCKS_COUNT , 
245
                                       rs_rand()%1024 < 768 ? game.tex_minirocks[0].w/2 : game.tex_rocks[0].w/2, GAME_WIDTH + 100, 30 + rs_rand()%(GAME_HEIGHT-90), 0, 0.0 ) );
285
                                       rs_rand()%1024 < 768 ? game.tex_minirocks[0].w/2 : game.tex_rocks[0].w/2, GAME_WIDTH + 100, 30 + rs_rand()%(GAME_HEIGHT-90), 0, 0.0 ) );
Line 246... Line 286...
246
            };
286
            };
Line 253... Line 293...
253
            
293
            
254
            
294
            
Line -... Line 295...
-
 
295
            if (game.stage_timer > 3*25) {
-
 
296
                next_stage_now();
255
            if (game.stage_timer > 3*25) {
297
                
Line 256... Line 298...
256
                next_stage_now();
298
                BIT_CLEAR(game.flags, GAME_FLAG_BOSS_DESTROYED);
Line 257... Line 299...
257
                
299
                
Line 272... Line 314...
272
        else if (game.stage == 9) {
314
        else if (game.stage == 9) {
273
            next_stage_after_sec(2);
315
            next_stage_after_sec(2);
274
        }                
316
        }                
275
        else if (game.stage == 10) {
317
        else if (game.stage == 10) {
Line -... Line 318...
-
 
318
            
276
            
319
            /*
277
            game.status = STATUS_MENU;
320
            game.status = STATUS_MENU;
Line 278... Line 321...
278
            menu_open( MENU_LEVEL_PASSED );
321
            menu_open( MENU_LEVEL_PASSED );
279
        
322
        
280
            level_passed_score_str[1] = '0' + (game.score / 100) % 10;
323
            level_passed_score_str[1] = '0' + (game.score / 100) % 10;
-
 
324
            level_passed_score_str[2] = '0' + (game.score / 10) % 10;
-
 
325
            level_passed_score_str[3] = '0' + (game.score / 1) % 10;
-
 
326
            */
-
 
327
            
-
 
328
            game.stage_level++;
-
 
329
            
Line 281... Line 330...
281
            level_passed_score_str[2] = '0' + (game.score / 10) % 10;
330
            game.stage = 0;
Line 387... Line 436...
387
                else {
436
                else {
388
                    obj->f += 0.03;
437
                    obj->f += 0.03;
389
                    obj->y = GAME_HEIGHT * ( 0.5 + 0.3*sin(obj->f) );
438
                    obj->y = GAME_HEIGHT * ( 0.5 + 0.3*sin(obj->f) );
390
                };
439
                };
Line -... Line 440...
-
 
440
                
-
 
441
                if ( obj->x < GAME_WIDTH*4/5 ) {
391
                
442
                    // turret shoot
392
                obj->t--;
443
                    obj->t--;
-
 
444
                    if (obj->t < 1) {
393
                if (obj->t < 1) {
445
                        soundbuf_play(&game.sound_turret_shoot, 0);
-
 
446
                        game_obj_add( game_obj( OBJ_RED_BULLET, 0, 0, 3, obj->x - 30, obj->y, 0, 0) );
-
 
447
                        
-
 
448
                        int c_const = (game.stage_level < 4) ? (10 - 2*game.stage_level) : 3;
-
 
449
                        int c_var = (game.stage_level < 6) ? (20 - 3*game.stage_level) : 3;
394
                    game_obj_add( game_obj( OBJ_RED_BULLET, 0, 0, 3, obj->x - 30, obj->y, 0, 0) );
450
                        
-
 
451
                        obj->t = c_const + rs_rand() % c_var;
-
 
452
                        
-
 
453
                        if ( (rs_rand()%1024) < 80 ) {
-
 
454
                            obj->t += 18;
-
 
455
                        };
-
 
456
                        
395
                    obj->t = 10 + rs_rand() % 20;
457
                    };
Line 396... Line 458...
396
                };
458
                };
Line 397... Line 459...
397
                
459