diff options
author | kdx <kdx@42l.fr> | 2023-02-18 01:18:42 +0100 |
---|---|---|
committer | kdx <kdx@42l.fr> | 2023-02-18 01:18:42 +0100 |
commit | 72a6892b5b18e450d82468e7bb830687a0215eb4 (patch) | |
tree | c8126b0557161a671df47c9fed2c7f915a53298e | |
parent | 80635fd59c54d8ba4591029114bea3755cccb816 (diff) | |
download | bozojam-72a6892b5b18e450d82468e7bb830687a0215eb4.tar.gz |
art
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | cfg.h | 4 | ||||
-rw-r--r-- | commands.c | 24 | ||||
-rw-r--r-- | commands.h | 15 | ||||
-rw-r--r-- | level.c | 39 | ||||
-rw-r--r-- | level.h | 9 | ||||
-rw-r--r-- | main.c | 26 | ||||
-rw-r--r-- | res/down.bmp | bin | 0 -> 1674 bytes | |||
-rw-r--r-- | res/left.bmp | bin | 0 -> 1674 bytes | |||
-rw-r--r-- | res/right.bmp | bin | 0 -> 1674 bytes | |||
-rw-r--r-- | res/up.bmp | bin | 0 -> 1674 bytes |
11 files changed, 117 insertions, 5 deletions
@@ -4,8 +4,9 @@ SRC := $(wildcard *.c) OBJ := $(patsubst %.c,%.o,$(SRC)) NAME := bozo SDL2-CFG := sdl2-config -CFLAGS := -Wall -Wextra -std=c99 $(shell $(SDL2-CFG) --cflags) -LDFLAGS := $(shell $(SDL2-CFG) --libs) -lSDL2_image -lSDL2_mixer -lSDL2_gfx +LZRFLAGS := -DLZR_DISABLE_MIXER +CFLAGS := -Wall -Wextra -std=c99 $(shell $(SDL2-CFG) --cflags) $(LZRFLAGS) +LDFLAGS := $(shell $(SDL2-CFG) --libs) -lSDL2_image -lSDL2_gfx all: $(NAME) @@ -2,7 +2,7 @@ #include "lzr.h" enum { - CFG_DWIDTH = 256, + CFG_DWIDTH = 288, CFG_DHEIGHT = 256, CFG_FPS = 60, CFG_TSIZE = 16 @@ -16,5 +16,5 @@ static const LZR_Config cfg = { "jam like nobody is watching (cause they ain't)", 0.0, false, - true + false }; diff --git a/commands.c b/commands.c new file mode 100644 index 0000000..83272ee --- /dev/null +++ b/commands.c @@ -0,0 +1,24 @@ +#include "commands.h" +#include "lzr.h" +#include "cfg.h" + +static const unsigned int commands[COM_LEN] = { + COM_RIGHT, + COM_RIGHT, + COM_UP, + COM_DOWN, + COM_LEFT, + COM_LEFT, + COM_DOWN, + COM_UP +}; + +void commands_draw(void) +{ + LZR_DrawSetColor(1, 1, 1, 1); + for (int i = 0; i < COM_LEN; i++) { + const int dx = CFG_TSIZE / 2; + const int dy = CFG_TSIZE / 2 + i * (int)(CFG_TSIZE * 1.5); + LZR_DrawImage(commands[i], dx, dy); + } +} diff --git a/commands.h b/commands.h new file mode 100644 index 0000000..39badc5 --- /dev/null +++ b/commands.h @@ -0,0 +1,15 @@ +#pragma once + +enum { + COM_LEFT, + COM_RIGHT, + COM_UP, + COM_DOWN, + _COM_COUNT +}; + +enum { + COM_LEN = 8 +}; + +void commands_draw(void); @@ -0,0 +1,39 @@ +#include "level.h" +#include "lzr.h" +#include "cfg.h" + +static const char level[LEVEL_HEIGHT * LEVEL_WIDTH] = { + "000000000000" + "0..........0" + "0..........0" + "0..........0" + "0..........0" + "0..........0" + "0..........0" + "0..........0" + "0..........0" + "0..........0" + "0..........0" + "0..........0" + "0..........0" + "0..........0" + "0..........0" + "000000000000" +}; + +void level_draw() +{ + LZR_DrawSetColor(1, 1, 1, 1); + for (int y = 0; y < LEVEL_HEIGHT; y++) + for (int x = 0; x < LEVEL_WIDTH; x++) { + const int dx = (x + 3) * CFG_TSIZE; + const int dy = y * CFG_TSIZE; + if (level_get(x, y) == '0') + LZR_DrawRectangle(true, dx, dy, CFG_TSIZE, CFG_TSIZE); + } +} + +int level_get(int x, int y) +{ + return level[x + y * LEVEL_WIDTH]; +} @@ -0,0 +1,9 @@ +#pragma once + +enum { + LEVEL_WIDTH = 12, + LEVEL_HEIGHT = 16 +}; + +void level_draw(void); +int level_get(int x, int y); @@ -1,8 +1,32 @@ #include "lzr.h" #include "cfg.h" +#include "level.h" +#include "commands.h" +#include <stdlib.h> + +static float rcol(void) +{ + return (rand() & 1) * 0.1; +} int main(int argc, char **argv) { (void)argc, (void)argv; - return 0; + if (LZR_Init(cfg)) + return LZR_Quit(), 1; + if (LZR_ImageLoad("res/left.bmp") < 0 || + LZR_ImageLoad("res/right.bmp") < 0 || + LZR_ImageLoad("res/up.bmp") < 0 || + LZR_ImageLoad("res/down.bmp") < 0) + return LZR_Quit(), 1; + while (!LZR_ShouldQuit()) { + LZR_CycleEvents(); + LZR_DrawBegin(); + LZR_DrawSetColor(rcol(), rcol(), rcol(), 1); + LZR_DrawClear(); + level_draw(); + commands_draw(); + LZR_DrawEnd(); + } + return LZR_Quit(), 0; } diff --git a/res/down.bmp b/res/down.bmp Binary files differnew file mode 100644 index 0000000..8c62b5b --- /dev/null +++ b/res/down.bmp diff --git a/res/left.bmp b/res/left.bmp Binary files differnew file mode 100644 index 0000000..80e126c --- /dev/null +++ b/res/left.bmp diff --git a/res/right.bmp b/res/right.bmp Binary files differnew file mode 100644 index 0000000..6beee4e --- /dev/null +++ b/res/right.bmp diff --git a/res/up.bmp b/res/up.bmp Binary files differnew file mode 100644 index 0000000..1fbed51 --- /dev/null +++ b/res/up.bmp |