PCBrawl/src/main.c

51 lines
866 B
C
Raw Normal View History

2022-02-28 15:38:08 +01:00
#define LZY_IMPLEMENTATION
#include "lzy.h"
2022-02-28 18:01:06 +01:00
#include <stdint.h>
2022-02-28 15:38:08 +01:00
2022-02-28 21:47:26 +01:00
static void draw_player(int x, int y);
2022-02-28 15:38:08 +01:00
int main(void) {
2022-02-28 21:47:26 +01:00
int x = 0;
int y = 0;
2022-02-28 18:01:06 +01:00
if (LZY_Init("lzy example", 30)) {
2022-02-28 16:26:59 +01:00
LZY_Log(LZY_GetError());
LZY_Quit();
2022-02-28 15:38:08 +01:00
return 1;
2022-02-28 16:26:59 +01:00
}
LZY_Log("init was great success!");
2022-02-28 15:38:08 +01:00
do {
2022-02-28 21:47:26 +01:00
/* update */
2022-02-28 15:38:08 +01:00
LZY_CycleEvents();
2022-02-28 16:43:45 +01:00
if (LZY_KeyDown(LZYK_LEFT))
2022-02-28 21:47:26 +01:00
x--;
2022-02-28 16:43:45 +01:00
if (LZY_KeyDown(LZYK_RIGHT))
2022-02-28 21:47:26 +01:00
x++;
if (LZY_KeyDown(LZYK_UP))
y--;
if (LZY_KeyDown(LZYK_DOWN))
y++;
2022-02-28 18:01:06 +01:00
2022-02-28 21:47:26 +01:00
/* draw */
2022-02-28 18:01:06 +01:00
LZY_DrawBegin();
2022-02-28 21:47:26 +01:00
{
LZY_DrawSetColor(0x20, 0x20, 0x00);
LZY_DrawClear();
draw_player(x, y);
}
2022-02-28 18:01:06 +01:00
LZY_DrawEnd();
2022-02-28 16:26:59 +01:00
} while (!LZY_ShouldQuit());
2022-02-28 15:38:08 +01:00
2022-02-28 16:26:59 +01:00
LZY_Log("cya");
LZY_Quit();
return 0;
2022-02-28 15:38:08 +01:00
}
2022-02-28 21:47:26 +01:00
static void draw_player(int x, int y) {
LZY_DrawSetColor(0x00, 0xff, 0xff);
LZY_DrawFillRect(x, y, 8, 8);
LZY_DrawSetColor(0xff, 0x00, 0x00);
LZY_DrawRect(x + 1, y + 1, 6, 6);
}