PCBrawl/src/main.c

59 lines
1.1 KiB
C

#define LZY_IMPLEMENTATION
#define LZY_GINT_TILESET bimg_tset
#define LZY_GINT_FONT bimg_font
#define LZY_CHR_WIDTH 16
#define LZY_CHR_HEIGHT 16
#define LZY_FIRST_CHR ' '
#include "lzy.h"
static const int speed = 4;
int main(int argc, const char **argv) {
int x = 0;
int y = 0;
if (LZY_Init(argc, argv, "lzy example", 30, "res/tset.png",
"res/font.png")) {
LZY_Log(LZY_GetError());
LZY_Quit();
return 1;
}
LZY_Log("initialisation was a success!");
while (!LZY_ShouldQuit()) {
/* update */
LZY_CycleEvents();
/* move player */
if (LZY_KeyDown(LZYK_LEFT))
x -= speed;
if (LZY_KeyDown(LZYK_RIGHT))
x += speed;
if (LZY_KeyDown(LZYK_UP))
y -= speed;
if (LZY_KeyDown(LZYK_DOWN))
y += speed;
/* draw */
LZY_DrawBegin();
{
/* clear screen */
LZY_DrawSetColor(0, 0, 0);
LZY_DrawClear();
/* draw yellow line between player and topleft corner */
LZY_DrawSetColor(255, 255, 0);
LZY_DrawLine(x, y, 0, 0);
/* draw player */
LZY_DrawTile(1, x, y);
}
LZY_DrawEnd();
}
LZY_Log("cya");
LZY_Quit();
return 0;
}