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
|
#include <time.h>
static int _main_loop(void *udata);
static float
randf(void)
{
return 10000. / (float)(rand() % 10000);
}
int
main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
{
srand(time(nullptr));
defer(wdeinit);
assert(TZR_Init(.interlace=true,
.width=640,
.height=640,
.ratio=4/3.,
.basepath=argv[1],
.pixel_perfect=true,
.target_fps=60) == 0);
defer(TZR_Quit);
TZR_MainLoop(_main_loop, nullptr);
return 0;
}
static int
_main_loop([[maybe_unused]] void *udata)
{
assert(TZR_DrawBegin() == 0);
if (rand() % 10 == 0) {
int r; do r = rand(); while ((r & 7) == 0);
TZR_DrawSetColor(r & 1, (r & 2) != 0, (r & 4) != 0);
TZR_DrawClear();
TZR_PlaySound(TZR_RES("res/rain.wav"));
TZR_DrawSetColor(0, 0, 0);
if (rand() % 128) {
TZR_DrawImage(TZR_RES("res/title.bmp"),
___tzr_config.width / 2 + 255 - rand() % 512,
___tzr_config.height / 2 + 255 - rand() % 512,
.center=true,
.sx=randf() * 2,
.sy=randf() * 2,
.r=randf(),
.flip_x=(rand()%3)==0,
.flip_y=(rand()%3)==0);
} else {
TZR_DrawImage(TZR_RES("res/death.bmp"),
___tzr_config.width / 2,
___tzr_config.height / 2,
.center=true,
.sx=1.0+randf()*.1,
.sy=1.0+randf()*.1);
}
//map_draw();
//player_draw();
} else {
TZR_DrawSetColor(0, 0, 0);
TZR_DrawClear();
}
assert(TZR_DrawEnd() == 0);
return 0;
}
|