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
|
#include "TZR.h"
#include "px.h"
#include <stdlib.h>
#include <time.h>
int
main(void)
{
if (TZR_Init(128, 128, 60, .mixer=false))
return 1;
if (atexit(TZR_Quit)) {
TZR_Quit();
return 1;
}
if (pxInit())
return 1;
if (atexit(pxDeinit)) {
pxDeinit();
return 1;
}
srand(time(NULL));
PxSpr spr = {
8, 8,
(uint8_t[]){
2, 0, 0, 0, 0, 0, 3, 0,
0, 2, 0, 0, 0, 3, 0, 3,
0, 0, 2, 2, 2, 0, 4, 0,
0, 0, 0, 0, 0, 5, 0, 0,
0, 0, 0, 0, 7, 0, 0, 0,
0, 0, 0, 6, 0, 0, 0, 0,
0, 0, 0, 6, 0, 0, 0, 0,
7, 0, 0, 0, 0, 0, 0, 7
}
};
int x = 8, y = 8;
pxCls(0);
while (!TZR_ShouldQuit()) {
TZR_CycleEvents();
x -= TZR_IsKeyDown(SDL_SCANCODE_A);
x += TZR_IsKeyDown(SDL_SCANCODE_D);
y -= TZR_IsKeyDown(SDL_SCANCODE_W);
y += TZR_IsKeyDown(SDL_SCANCODE_S);
pxPal();
pxSpal();
pxPalt();
for (int i = 0; i < PX_WIDTH * PX_HEIGHT; i++)
if (pxbuf[i])
pxbuf[i] -= 1;
pxZ(1);
pxSpr(&spr, x, y);
pxZ(0);
pxRectfill(112, 112, x, y, 10);
pxRect(16, 16, x, y, 15);
pxPal(3, 11);
pxPalt(3, true);
pxSpr(&spr, x, y + 8, .flip_x=true, .flip_y=true);
pxPset(0, 0, 10);
pxPset(1, 0, 10);
pxPset(0, 1, pxPget(0, 0));
TZR_DrawBegin();
pxFlip();
TZR_DrawEnd();
}
return 0;
}
|