-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
78 lines (60 loc) · 1.07 KB
/
main.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
#include <stdio.h>
#include <SDL/SDL.h>
#include <GL/glew.h>
#include "estk.h"
#include "fisk.h"
static void
loop_frame(float fr)
{
if (fr > 0.3f) return;
glClear(GL_COLOR_BUFFER_BIT);
boatFrame(fr);
esVec2 boat_pos = boatGetPosition();
fishMoveFrame(fr, boat_pos.x);
seaPosition(fr, boat_pos.x-22.0f);
seaRender();
fishRender();
boatRender();
spriteFlushRender();
esGameGlSwap();
}
#ifndef EMSCRIPTEN
static void
key_quit()
{
esGameLoopQuit();
}
#endif
int
main()
{
esGameInit(WINW, WINH);
glClearColor(0.1, 0.1, 0.3, 1.0);
if (seaSetup()) {
printf("Cannot create sea!\n");
return 1;
}
if (boatSetup()) {
printf("Cannot create boat!\n");
return 1;
}
if (spriteSetup()) {
printf("Cannot setup sprites!\n");
return 1;
}
if (fishSetup()) {
printf("Cannot setup fish!\n");
return 1;
}
if (scoreSetup()) {
printf("Cannot start score system\n");
return 1;
}
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#ifndef EMSCRIPTEN
esGameRegisterKey(SDLK_q, key_quit);
#endif
esGameLoop(loop_frame, NULL, 0);
return 0;
}