-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.c
636 lines (572 loc) · 21.8 KB
/
game.c
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
#include "game.h"
#include "end.h"
#include "functions.h"
#include "threading/thread.h"
#include "threading/input.h"
#include "threading/scheduler.h"
#include "threading/sleeper.h"
#include <ncurses.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <signal.h>
#define MAX_HOSTILE_MISSILE 20
#define BASE_DEFAULT_MISSILE 10
struct missile {
enum missileType type;
float start_x, start_y;
float x, y;
float old_x, old_y;
float vel_x, vel_y;
float tar_x, tar_y;
int live;
};
struct missile_explosion_thread_arg {
WINDOW *screen;
int x, y;
};
struct hostile_missiles_thread_arg {
WINDOW *screen;
int live;
struct missile *hostile_missiles;
struct missile *player_missiles;
};
struct base {
int x, y;
int missile_count;
int live;
} bases[3];
struct fighter {
int x, y;
int shoot_x;
int live;
} fighter;
static WINDOW *game_screen;
static int game_live = 0;
static struct missile hostile_missiles[MAX_HOSTILE_MISSILE] = {0};
static struct missile player_missiles[45] = {0};
static int level = 1;
char *STAGE_1, *STAGE_2;
char *LARGE_STAGE_1, *LARGE_STAGE_2;
// updates bases' missile count, as the name suggests
void update_missile_count() {
char missile_count[3];
for (int i = 0; i < 3; i++) {
if (!bases[i].missile_count) {
wattron(game_screen, COLOR_PAIR(84));
mvwprintw(game_screen, bases[i].y + 4, bases[i].x + 4, "OUT");
} else {
sprintf(missile_count, "%i", bases[i].missile_count);
wattron(game_screen, COLOR_PAIR(84));
mvwprintw(game_screen, bases[i].y + 4, bases[i].x + 4, " "); // first, erase previous number
mvwprintw(game_screen, bases[i].y + 4, bases[i].x + 4, missile_count); // then, display new number
}
}
}
// activates player missile
void shoot_player_missile(int tar_x, int tar_y, int base) {
if (!bases[base].missile_count) {
update_missile_count();
return;
}
wattron(game_screen, COLOR_PAIR(8));
mvwaddch(game_screen, tar_y, tar_x, 'x'); // mark target position
float dist;
struct missile player_missile = {
.type = PLAYER,
.start_x = bases[base].x + 4,
.x = bases[base].x + 4,
.start_y = FRAME_HEIGHT - 7,
.y = FRAME_HEIGHT - 7,
.vel_x = 0,
.vel_y = 0,
.tar_x = tar_x,
.tar_y = tar_y,
.live = 1
};
dist = sqrtf(powf(player_missile.x - player_missile.tar_x, 2) + powf(player_missile.y - player_missile.tar_y, 2));
player_missile.vel_x = (player_missile.tar_x - player_missile.x) / dist * 2;
player_missile.vel_y = (player_missile.tar_y - player_missile.y) / dist * 2;
// add missile to the array of missiles to be updated
for (int i = 0; i < 30; i++) {
if (!player_missiles[i].live) {
player_missiles[i] = player_missile;
break;
}
}
bases[base].missile_count--;
update_missile_count();
}
// remove missile from screen
void kill_missile(void *missile_input) {
struct missile *missile = missile_input;
missile->live = 0;
wattron(game_screen, COLOR_PAIR(1));
//mvwaddch(game_screen, missile->tar_y, missile->tar_x, ' ');
// clean trace from current position back to where it started
while (1) {
mvwaddch(game_screen, round(missile->y), round(missile->x), ' ');
if (fabsf(missile->x - missile->start_x) < 0.1 && fabsf(missile->y - missile->start_y) < 0.1) {
break;
}
// move backwards
missile->x -= missile->vel_x;
missile->y -= missile->vel_y;
}
}
// handles missile explosion
void update_missile_explosion(void *arguments) {
struct missile_explosion_thread_arg *args = arguments;
sleep_add(0, 100000000);
wattron(game_screen, COLOR_PAIR(8));
draw_from_string(args->screen, args->x - 4, args->y - 2, LARGE_STAGE_1, DRAW); // explosion stage 1
sleep_add(0, 100000000);
wattron(game_screen, COLOR_PAIR(8));
draw_from_string(args->screen, args->x - 4, args->y - 2, LARGE_STAGE_2, DRAW); // explosion stage 2
sleep_add(0, 100000000);
wattron(game_screen, COLOR_PAIR(8));
draw_from_string(args->screen, args->x - 4, args->y - 2, LARGE_STAGE_2, ERASE); // clean up explosion
free(arguments);
}
// starts the explosion
void init_missile_explosion(int x, int y) {
struct missile_explosion_thread_arg *missile_explosion_args = malloc(sizeof(*missile_explosion_args));
*missile_explosion_args = (struct missile_explosion_thread_arg) {
.screen = game_screen,
.x = x,
.y = y
};
sched_wakeup(thread_create(&update_missile_explosion, missile_explosion_args));
}
// checks if hostile missile hit player's cities or bases
void check_hit_player(float x, float y) {
// check city hit
for (int i = 0; i < 6; i++) {
if ((x >= cities_x_pos[i]) && (x <= (cities_x_pos[i] + 6))) {
wattron(game_screen, COLOR_PAIR(3));
// remove city from screen
mvwprintw(game_screen, FRAME_HEIGHT - 4, cities_x_pos[i], " ");
mvwprintw(game_screen, FRAME_HEIGHT - 3, cities_x_pos[i], " ");
cities[i].live = 0;
}
init_missile_explosion(round(x), round(y));
}
// check base hit
for (int i = 0; i < 3; i++) {
if ((x >= bases[i].x) && (x <= (bases[i].x + 7))) {
bases[i].missile_count = 0; // a destroyed base can't shoot missiles ya?
bases[i].live = 0;
draw_from_file(game_screen, bases[i].x, FRAME_HEIGHT - 6, "graphics/base", ERASE); // remove base from screen
update_missile_count();
}
init_missile_explosion(round(x), round(y));
}
}
// checks if player missile hit hostile missile
void check_hit_hostile(float x, float y) {
for (int i = 0; i < MAX_HOSTILE_MISSILE; i++) {
float dist = sqrt(pow((x - hostile_missiles[i].x), 2) + pow((y - hostile_missiles[i].y), 2));
if (hostile_missiles[i].live && dist < 5) {
kill_missile(&hostile_missiles[i]);
score += score_multiplier(25, level);
}
init_missile_explosion(round(x), round(y));
}
}
void create_fighter() {
fighter.live = 1;
fighter.x = 0;
fighter.y = 13;
}
// creates and returns a hostile missile
struct missile create_hostile_missile(float from_x, float from_y, float to_x, float to_y, enum missileType type) {
struct missile missile = {
.live = 1,
.type = HOSTILE_NORMAL,
.start_x = from_x,
.start_y = from_y,
.x = from_x,
.y = from_y,
.tar_x = to_x,
.tar_y = to_y
};
float dist = sqrtf(powf(from_x - to_x, 2) + powf(from_y - to_y, 2));
missile.vel_x = (to_x - from_x) / dist;
missile.vel_y = (to_y - from_y) / dist;
return missile;
}
// generates hostile missiles
void gen_hostile_missiles() {
int rand_target_type;
float rand_target_x, rand_target_y;
for (int i = 0; i < 8; i++) {
// shoot 4 per wave, 5 seconds between 2 waves
if (i == 4) {
sleep_add(5, 0);
if (level != 1)
create_fighter();
}
rand_target_type = rand() % 2 - 1; // half of the missiles will target cities, while others target bases
if (rand_target_type) {
rand_target_x = cities[rand() % 6].x + rand() % 4 + 1;
rand_target_y = 36;
} else {
rand_target_x = bases[rand() % 3].x + rand() % 4 + 3;
rand_target_y = 33;
}
for (int j = 0; j < MAX_HOSTILE_MISSILE; j++)
if (!hostile_missiles[j].live) {
hostile_missiles[j] = create_hostile_missile((rand() % (FRAME_WIDTH - 1)), 0, rand_target_x, rand_target_y, HOSTILE_NORMAL);
if (!rand() % 6) // 1 in 6 chance
hostile_missiles[j].type = HOSTILE_SPLIT;
break;
}
}
}
void split_missile(struct missile *missile_pt) {
missile_pt->type = HOSTILE_NORMAL;
int split_num = rand() % 3 + 1;
for (int i = 0; i < split_num; i++) {
int rand_target_type;
int rand_target_x, rand_target_y;
rand_target_type = rand() % 2 - 1; // half of the missiles will target cities, while others target bases
if (rand_target_type) {
rand_target_x = cities_x_pos[rand() % 6] + rand() % 4 + 1;
rand_target_y = 36;
} else {
rand_target_x = bases_x_pos[rand() % 3] + rand() % 4 + 3;
rand_target_y = 33;
}
for (int j = 0; j < MAX_HOSTILE_MISSILE; j++)
if (!hostile_missiles[j].live) {
hostile_missiles[j] = create_hostile_missile(missile_pt->x, missile_pt->y, rand_target_x, rand_target_y, HOSTILE_NORMAL);
break;
}
}
}
// check if fighter jet and ufo is hit
void check_hit_special(float x, float y) {
if (fighter.live) {
if ((x - (fighter.x - 2)) < 16 && (y - (fighter.y - 2)) < 6) {
fighter.live = 0;
wattron(game_screen, COLOR_PAIR(2));
draw_from_file(game_screen, fighter.x, fighter.y, "graphics/fighter-jet", ERASE);
}
}
}
// updates fighter jet and ufo
void update_specials() {
if (fighter.live) {
if (fighter.x > FRAME_WIDTH - 7) {
fighter.live = 0;
}
wattron(game_screen, COLOR_PAIR(2));
draw_from_file(game_screen, fighter.x, fighter.y, "graphics/fighter-jet", ERASE);
fighter.x += 1;
draw_from_file(game_screen, fighter.x, fighter.y, "graphics/fighter-jet", DRAW);
if (fabsf(fighter.x - 40) < 1) {
int rand_target_type;
int rand_target_x, rand_target_y;
rand_target_type = rand() % 2 - 1; // half of the missiles will target cities, while others target bases
if (rand_target_type) {
rand_target_x = cities_x_pos[rand() % 6] + rand() % 4 + 1;
rand_target_y = 36;
} else {
rand_target_x = bases_x_pos[rand() % 3] + rand() % 4 + 3;
rand_target_y = 33;
}
for (int j = 0; j < MAX_HOSTILE_MISSILE; j++)
if (!hostile_missiles[j].live) {
hostile_missiles[j] = create_hostile_missile(fighter.x + 4, fighter.y + 2, rand_target_x, rand_target_y, HOSTILE_NORMAL);
break;
}
}
}
}
// updates missiles position and prints the trail behind it
void sub_update_missiles(struct missile *missiles, int missile_count) {
for (int i = 0; i < missile_count; i++) {
if (missiles[i].live) {
if (missiles[i].type == HOSTILE_SPLIT && fabsf(missiles[i].y - 14) < 1) {
split_missile(&missiles[i]);
}
if (fabsf(missiles[i].x - missiles[i].tar_x) <= 1 && fabsf(missiles[i].y - missiles[i].tar_y) <= 1) { // check if it arrived at it's destination
if (missiles[i].type == PLAYER) {
check_hit_hostile(missiles[i].x, missiles[i].y);
check_hit_special(missiles[i].x, missiles[i].y);
}
else
check_hit_player(missiles[i].x, missiles[i].y);
kill_missile(&missiles[i]);
} else {
// calculate new posiiton of the missile
missiles[i].old_x = missiles[i].x;
missiles[i].old_y = missiles[i].y;
missiles[i].x += missiles[i].vel_x;
missiles[i].y += missiles[i].vel_y;
// display the track behind the missile
if (missiles[i].type == PLAYER) {
wattron(game_screen, COLOR_PAIR(5));
if (round(missiles[i].vel_x) > 0)
mvwaddch(game_screen, round(missiles[i].old_y), round(missiles[i].old_x), '/');
else if (round(player_missiles[i].vel_x) < 0)
mvwaddch(game_screen, round(missiles[i].old_y), round(missiles[i].old_x), '\\');
else
mvwaddch(game_screen, round(missiles[i].old_y), round(missiles[i].old_x), '|');
} else {
wattron(game_screen, COLOR_PAIR(2));
if (round(missiles[i].vel_x) > 0)
mvwaddch(game_screen, round(missiles[i].old_y), round(missiles[i].old_x), '\\');
else if (round(missiles[i].vel_x) < 0)
mvwaddch(game_screen, round(missiles[i].old_y), round(missiles[i].old_x), '/');
else
mvwaddch(game_screen, round(missiles[i].old_y), round(missiles[i].old_x), '|');
}
// show position of missile
wattron(game_screen, COLOR_PAIR(8));
mvwaddch(game_screen, round(missiles[i].y), round(missiles[i].x), '.');
}
}
}
}
// handles mechanic to move on to next level, actually, it's only 2 steps :P
void next_level() {
level++;
sched_wakeup(thread_create(&game, NULL));
}
// displays and runs the bonus points screen
void bonus_points() {
wattron(game_screen, COLOR_PAIR(5));
mvwprintw(game_screen, FRAME_HEIGHT / 2 - 2, FRAME_WIDTH / 2 - 6, "BONUS POINTS");
// calculates and displays the bonus points for remaining player missiles
int bonus_points_missiles = 0;
char bonus_points_missiles_str[5];
for (int i = 0; i < 3; i++)
for (int j = bases[i].missile_count; j > 0; j--) {
bases[i].missile_count -= 1; // remove missiles from bases as being counted
bonus_points_missiles += 5; // 5 points per missile
wattron(game_screen, COLOR_PAIR(2));
sprintf(bonus_points_missiles_str, "%i", score_multiplier(bonus_points_missiles, level));
mvwprintw(game_screen, FRAME_HEIGHT / 2, FRAME_WIDTH / 2 - 6, bonus_points_missiles_str); // display count
mvwaddch(game_screen, FRAME_HEIGHT / 2, FRAME_WIDTH / 2 - 2 + bonus_points_missiles / 5, '^'); // cute little display counting number of missiles left
update_missile_count();
wrefresh(game_screen);
sleep_add(0, 100000000);
}
score += score_multiplier(bonus_points_missiles, level);
refresh_high_score(game_screen);
wrefresh(game_screen);
// calculates and displays the bonus points for remaining cities
int bonus_points_cities = 0;
char bonus_points_cities_str[5];
for (int i = 0; i < 6; i++)
if (cities[i].live) {
// erase the cities upon being counted
mvwprintw(game_screen, FRAME_HEIGHT - 4, cities_x_pos[i], " ");
mvwprintw(game_screen, FRAME_HEIGHT - 3, cities_x_pos[i], " ");
bonus_points_cities += 100; // 100 points per city
wattron(game_screen, COLOR_PAIR(2));
sprintf(bonus_points_cities_str, "%i", score_multiplier(bonus_points_cities, level));
mvwprintw(game_screen, FRAME_HEIGHT / 2 + 2, FRAME_WIDTH / 2 - 6, bonus_points_cities_str); // display counted
// shows cute tiny version of the cities
wattron(game_screen, COLOR_PAIR(3));
mvwaddch(game_screen, FRAME_HEIGHT / 2 + 2, FRAME_WIDTH / 2 - 2 + (bonus_points_cities / 100) * 4 - 3, ACS_CKBOARD);
wattron(game_screen, COLOR_PAIR(5));
mvwaddch(game_screen, FRAME_HEIGHT / 2 + 2, FRAME_WIDTH / 2 - 2 + (bonus_points_cities / 100) * 4 + 1 - 3, ACS_CKBOARD);
wattron(game_screen, COLOR_PAIR(3));
mvwaddch(game_screen, FRAME_HEIGHT / 2 + 2, FRAME_WIDTH / 2 - 2 + (bonus_points_cities / 100) * 4 + 2 - 3, ACS_CKBOARD);
wrefresh(game_screen);
sleep_add(0, 300000000);
}
score += score_multiplier(bonus_points_cities, level);
refresh_high_score(game_screen);
wrefresh(game_screen);
sleep_add(1, 0);
}
// check if all hostile missiles are gone
void check_end_missiles() {
int live_count = 0;
for (int i = 0; i < MAX_HOSTILE_MISSILE; i++)
if (hostile_missiles[i].live)
live_count++;
if (live_count == 0) {
sleep_add(1, 0);
game_live = 0;
bonus_points();
sleep_add(1, 0);
endwin();
//exit(0);
next_level();
}
}
// check if all cities are gone
void check_end_cities() {
int live_count = 0;
for (int i = 0; i < 6; i++)
if (cities[i].live)
live_count++;
if (live_count == 0) {
sleep_add(1, 0);
game_live = 0;
bonus_points();
sleep_add(1, 0);
endwin();
end();
}
}
// the game loop, as what the name of the function suggests
void game_loop() {
int counter = 0; // game tick counter, min: 0; max: 4
while (game_live) {
sleep_add(0, 60000000 * 1 / pow(level * 0.06 + 0.95 ,2)); // speeds up the game as players progresses to higher levels
if (counter < 4)
counter++;
else
counter = 0;
if (!counter) { // updates the hostile missiles 1 in 4 ticks, so that player missiles moves 4 times faster than hostile ones
update_specials();
sub_update_missiles(hostile_missiles, MAX_HOSTILE_MISSILE);
check_end_cities();
check_end_missiles();
}
sub_update_missiles(player_missiles, 45);
refresh_high_score(game_screen);
wrefresh(game_screen);
}
}
// moves the cursor from cur_x, cur_y to new_x, new_y
void move_cursor(int *cur_x, int *cur_y, int new_x, int new_y) {
wattron(game_screen, COLOR_PAIR(5));
if ((mvwinch(game_screen, *cur_y, *cur_x) & A_CHARTEXT) != ('x' & A_CHARTEXT)) { // don't erase if there's something besides of the cursor
mvwaddch(game_screen, *cur_y, *cur_x, ' '); // erase old cursor
}
*cur_x = new_x;
*cur_y = new_y;
mvwaddch(game_screen, *cur_y, *cur_x, '+'); // draw cursor at new position
wrefresh(game_screen);
}
// input handler for game screen
void game_screen_input() {
int cur_x = FRAME_WIDTH / 2;
int cur_y = (FRAME_HEIGHT - 7) / 2;
wattron(game_screen, COLOR_PAIR(5));
mvwaddch(game_screen, cur_y, cur_x, '+');
int input;
// MEVENT event;
input_set_thread();
while (game_live) {
input_set_thread();
input = wgetch(game_screen);
switch (input) {
/** case KEY_MOUSE:
if (getmouse(&event) == OK) {
if (event.x < FRAME_WIDTH && event.y < (FRAME_HEIGHT - 7)) {
move_cursor(&cur_x, &cur_y, event.x, event.y);
}
}
break; */
case KEY_LEFT:
if (cur_x > 0) {
move_cursor(&cur_x, &cur_y, cur_x - 1, cur_y);
}
break;
case KEY_RIGHT:
if (cur_x < FRAME_WIDTH - 1) {
move_cursor(&cur_x, &cur_y, cur_x + 1, cur_y);
}
break;
case KEY_UP:
if (cur_y > 0) {
move_cursor(&cur_x, &cur_y, cur_x, cur_y - 1);
}
break;
case KEY_DOWN:
if (cur_y < FRAME_HEIGHT - 7) {
move_cursor(&cur_x, &cur_y, cur_x, cur_y + 1);
}
break;
case '1':
shoot_player_missile(cur_x, cur_y, 0);
break;
case '2':
shoot_player_missile(cur_x, cur_y, 1);
break;
case '3':
shoot_player_missile(cur_x, cur_y, 2);
break;
case 'q':
game_live = 0;
endwin();
exit(0);
break;
//default:
//sched_wakeup(game_thread);
}
}
}
// introduces the stage to user
void stage_intro() {
draw_screen_settings(game_screen, 0, cities);
refresh_high_score(game_screen);
char level_text[5], score_x_text[5], speed_x_text[316];
sprintf(level_text, "%i", level);
sprintf(score_x_text, "%i", score_multiplier(1, level));
sprintf(speed_x_text, "%.2f", pow(level * 0.06 + 0.95 ,2));
char field[4][2][10] = {
{"PLAYER", "1"},
{"LEVEL", ""},
{"SCORE X", ""},
{"SPEED X", ""}
};
strcpy(field[1][1], level_text);
strcpy(field[2][1], score_x_text);
strcpy(field[3][1], speed_x_text);
for (int i = 0; i < 4; i++) {
wattron(game_screen, COLOR_PAIR(5));
mvwprintw(game_screen, FRAME_HEIGHT / 2 - 4 + i * 2, FRAME_WIDTH / 2 - 6, field[i][0]);
wattron(game_screen, COLOR_PAIR(2));
mvwprintw(game_screen, FRAME_HEIGHT / 2 - 4 + i * 2, FRAME_WIDTH / 2 + 3, field[i][1]);
}
wrefresh(game_screen);
sleep_add(2, 0);
werase(game_screen);
}
void game() {
sched_wakeup(thread_create(&game_screen_input, NULL));
LARGE_STAGE_1 = file_to_string("graphics/explosion-large-stage-1");
LARGE_STAGE_2 = file_to_string("graphics/explosion-large-stage-2");
game_screen = newwin(FRAME_HEIGHT, FRAME_WIDTH, 0, 0);
game_live = 1;
wattron(game_screen, A_BOLD);
keypad(game_screen, TRUE);
noecho();
fighter = (struct fighter) {0};
// setup all bases
for (int i = 0; i < 3; i++) {
bases[i] = (struct base) {
.x = bases_x_pos[i],
.y = FRAME_HEIGHT - 6,
.missile_count = BASE_DEFAULT_MISSILE,
.live = 1
};
}
// setup all cities
if (level == 1) // only on level #1
for (int i = 0; i < 6; i++) {
cities[i] = (struct city) {
.x = cities_x_pos[i],
.y = FRAME_HEIGHT - 4,
.live = 1
};
}
stage_intro();
draw_screen_settings(game_screen, 0, cities);
update_missile_count();
wrefresh(game_screen);
// let the 2 threads run the game
sched_wakeup(thread_create(&gen_hostile_missiles, NULL));
sched_wakeup(thread_create(&game_loop, NULL));
}