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-03-02 00:16:38 +01:00
|
|
|
LZY_Music *music;
|
|
|
|
LZY_Sound *sound;
|
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
|
|
|
|
2022-03-02 00:16:38 +01:00
|
|
|
sound = LZY_SoundLoad("res/sound.wav");
|
|
|
|
music = LZY_MusicLoad("res/music.ogg");
|
|
|
|
LZY_SoundPlay(sound, 0);
|
|
|
|
LZY_MusicPlay(music, 0);
|
|
|
|
|
2022-02-28 15:38:08 +01:00
|
|
|
do {
|
2022-03-02 23:32:07 +01:00
|
|
|
const int speed = 2;
|
|
|
|
|
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-03-02 23:32:07 +01:00
|
|
|
x -= speed;
|
2022-02-28 16:43:45 +01:00
|
|
|
if (LZY_KeyDown(LZYK_RIGHT))
|
2022-03-02 23:32:07 +01:00
|
|
|
x += speed;
|
2022-02-28 21:47:26 +01:00
|
|
|
if (LZY_KeyDown(LZYK_UP))
|
2022-03-02 23:32:07 +01:00
|
|
|
y -= speed;
|
2022-02-28 21:47:26 +01:00
|
|
|
if (LZY_KeyDown(LZYK_DOWN))
|
2022-03-02 23:32:07 +01:00
|
|
|
y += speed;
|
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();
|
2022-03-01 15:29:34 +01:00
|
|
|
LZY_DrawText("HELLOWO!", 0, 0);
|
2022-02-28 21:47:26 +01:00
|
|
|
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-03-02 00:16:38 +01:00
|
|
|
LZY_MusicDestroy(music);
|
|
|
|
LZY_SoundDestroy(sound);
|
|
|
|
|
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-02 23:32:07 +01:00
|
|
|
const int cx = x + 8;
|
|
|
|
const int cy = y + 8;
|
|
|
|
|
2022-03-01 15:29:34 +01:00
|
|
|
if (LZY_DrawTile(14, x, y))
|
2022-03-01 01:54:20 +01:00
|
|
|
LZY_Log(LZY_GetError());
|
2022-03-02 23:32:07 +01:00
|
|
|
|
|
|
|
LZY_DrawSetColor(0x00, 0xff, 0xff);
|
|
|
|
LZY_DrawLine(0, 0, cx - 1, cy - 1);
|
|
|
|
LZY_DrawLine(395, 0, cx, cy - 1);
|
|
|
|
LZY_DrawLine(0, 223, cx - 1, cy);
|
|
|
|
LZY_DrawLine(395, 223, cx, cy);
|
2022-02-28 21:47:26 +01:00
|
|
|
}
|