-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschwerkraft.c
87 lines (77 loc) · 1.71 KB
/
schwerkraft.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
#include "../sparrow3d/sparrow3d.h"
#include <SDL_image.h>
#include "menu.h"
#include "font.h"
SDL_Surface* screen;
void draw_game(void)
{
spResetZBuffer();
spClearTarget(3);
spIdentity();
drawLevel();
spSetZSet(0);
spSetZTest(0);
draw_music();
spFlip();
}
int calc_game(Uint32 steps)
{
calc_music(steps);
if (spGetInput()->button[SP_BUTTON_START_NOWASD])
{
spGetInput()->button[SP_BUTTON_START_NOWASD] = 0;
return 1;
}
return calcLevel(steps);
}
void resize(Uint16 w,Uint16 h)
{
spSelectRenderTarget(spGetWindowSurface());
spSetPerspective(50.0,(float)spGetWindowSurface()->w/(float)spGetWindowSurface()->h,1.0,100);
reloadFont();
}
int main(int argc, char **argv)
{
spInitCore();
spSetDefaultWindowSize( 800, 480 ); //Creates a 640x480 window at PC instead of 320x240
screen = spCreateDefaultWindow();
resize(screen->w,screen->h);
spSetAlphaTest(1);
spSetLight(1);
//spSetLightColor(0,SP_ONE*2,SP_ONE*2,SP_ONE*2);
spUsePrecalculatedNormals(1);
init_menu_stuff();
initLevel();
init_music();
int result = 1;
while (result)
{
result = spLoop(draw_menu,calc_menu,10,resize,NULL);
switch (result)
{
case 1:
createRandomLevel(0);
result = spLoop(draw_game,calc_game,10,resize,NULL);
break;
case 2:
createRandomLevel(1);
result = spLoop(draw_game,calc_game,10,resize,NULL);
break;
case 3:
spLoop(draw_help,calc_help,10,resize,NULL);
break;
case 4:
spLoop(draw_about,calc_about,10,resize,NULL);
break;
case 5:
result = 0;
break;
}
}
quitLevel();
quit_menu_stuff();
quit_music();
quitFont();
spQuitCore();
return 0;
}