lzy/src/main.c

53 lines
948 B
C
Raw Normal View History

2022-02-28 15:38:08 +01:00
#define LZY_IMPLEMENTATION
2022-03-01 01:54:20 +01:00
#define LZY_GINT_TILESET bimg_tset
2022-03-01 15:13:35 +01:00
#define LZY_GINT_FONT bimg_font
#define LZY_CHR_WIDTH 16
#define LZY_CHR_HEIGHT 16
#define LZY_FIRST_CHR ' '
2022-02-28 15:38:08 +01:00
#include "lzy.h"
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
2022-03-01 15:13:35 +01:00
if (LZY_Init("lzy example", 30, "res/tset.png", "res/font.png")) {
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) {
2022-03-01 01:54:20 +01:00
if (LZY_DrawTile(4, x, y))
LZY_Log(LZY_GetError());
2022-02-28 21:47:26 +01:00
}