-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
69 lines (62 loc) · 1.98 KB
/
main.cpp
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
#include "define.h"
#include <allegro.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
//*************************************
//Função Main
//*************************************
int main() {
init();
MIDI *music = load_midi("graphics/music.mid");
play_midi(music,TRUE);
int loop = true;
while(loop){
objects *obj = (objects*)malloc(sizeof(objects));
spaceship *ship = (spaceship*)malloc(sizeof(spaceship));
obj->ship = ship;
setShipSprite(obj->ship);
game_option escolha;
escolha = callMenu();
switch(escolha){
case EASY_GAME: ship->speed = 1; break;
case MEDIUM_GAME: ship->speed = 3; break;
case HARD_GAME: ship->speed = 5; break;
case EXIT_GAME: loop = FALSE; break;
}
int level = 1;
while(loop&&level<=6){
char path[100] = "graphics/";
char filename[100];
sprintf(filename,"stage%d.w3d",level);
strcat(path,filename);
FILE *stage = fopen(path,"rb");
getAllCells(obj,stage);
fclose(stage);
game_condition progress;
int background = backgroundColor(level);
progress = gameLoop(obj,background);
switch(progress){
case NEXT_STAGE: level++; break;
case GAME_OVER:{
BITMAP *gameOver;
gameOver = load_bitmap("graphics/gameover.bmp",NULL);
updateScreen(gameOver);
rest(2000);
level = 100;
}break;
case LEAVE_GAME: loop = FALSE; break;
}
}
if(level==7){
BITMAP *win;
win = load_bitmap("graphics/venceu.bmp",NULL);
updateScreen(win);
rest(2000);
}
}
deinit();
return 0;
}
END_OF_MAIN()