This commit is contained in:
KikooDX 2022-04-01 17:37:59 +02:00
commit 9ea7bf73bb
14 changed files with 1287 additions and 0 deletions

9
.clang-format Normal file
View File

@ -0,0 +1,9 @@
BasedOnStyle: LLVM
IndentWidth: 8
UseTab: AlignWithSpaces
BreakBeforeBraces: Linux
AllowShortIfStatementsOnASingleLine: Never
AllowShortFunctionsOnASingleLine: Empty
IndentCaseLabels: false
ColumnLimit: 80
AlignConsecutiveMacros: true

27
CMakeLists.txt Normal file
View File

@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.22)
project(wehfou)
include(GenerateG3A)
include(Fxconv)
find_package(Gint 2.7.0 REQUIRED)
include_directories(inc)
set(SOURCES
src/main.c
src/lzy.c
)
set(ASSETS
res/tset.png
res/font.png
)
fxconv_declare_assets(${ASSETS} WITH_METADATA)
add_executable(thyaddin ${SOURCES} ${ASSETS})
target_compile_options(thyaddin PRIVATE -Wall -Wextra -Os)
target_link_libraries(thyaddin Gint::Gint)
generate_g3a(TARGET thyaddin OUTPUT "wehfou.g3a"
NAME "wehfou" ICONS res/icon-uns.png res/icon-sel.png)

34
Makefile Normal file
View File

@ -0,0 +1,34 @@
CC ?= gcc
CFLAGS = -std=c99 -Wall -Wextra -O3 -I./inc -MMD $(shell sdl2-config --cflags)
LDFLAGS = -lSDL2 -lSDL2_image -lSDL2_mixer $(shell sdl2-config --libs)
OBJ_NAME = wehfou
OBJS := $(patsubst %.c,%.o,$(wildcard src/*.c))
all: $(OBJ_NAME)
$(OBJ_NAME): $(OBJS)
$(CC) $(LDFLAGS) $(LIBRARIES) -o $(OBJ_NAME) $(OBJS)
strip $(OBJ_NAME)
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
cg:
fxsdk build-cg
run: $(OBJ_NAME)
./$(OBJ_NAME)
format:
@clang-format -style=file -verbose -i src/*.c
@clang-format -style=file -verbose -i inc/*.h
clean:
rm -f $(OBJ_NAME).g3a $(OBJ_NAME)
rm -f $(OBJS) src/*.d
rm -Rf build-cg
.PHONY: cg run run-txt format clean
-include src/*.d

6
inc/conf.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#define CHR_WIDTH 8
#define CHR_HEIGHT 16
#define DISPLAY_WIDTH 400
#define DISPLAY_HEIGHT 224

1119
inc/lzy.h Normal file

File diff suppressed because it is too large Load Diff

7
inc/player.h Normal file
View File

@ -0,0 +1,7 @@
#pragma once
void player_init(float x, float y);
void player_draw(void);
#define PLAYER_WIDTH 12
#define PLAYER_HEIGHT 12

BIN
res/font.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

7
res/fxconv-metadata.txt Normal file
View File

@ -0,0 +1,7 @@
tset.png:
type: bopti-image
name: bimg_tset
font.png:
type: bopti-image
name: bimg_font
profile: p4

BIN
res/icon-sel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
res/icon-uns.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1010 B

BIN
res/tset.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

10
src/lzy.c Normal file
View File

@ -0,0 +1,10 @@
#include "conf.h"
#define LZY_IMPLEMENTATION
#define LZY_GINT_TILESET bimg_tset
#define LZY_GINT_FONT bimg_font
#define LZY_CHR_WIDTH CHR_WIDTH
#define LZY_CHR_HEIGHT CHR_HEIGHT
#define LZY_DISPLAY_WIDTH DISPLAY_WIDTH
#define LZY_DISPLAY_HEIGHT DISPLAY_HEIGHT
#define LZY_FIRST_CHR ' '
#include "lzy.h"

50
src/main.c Normal file
View File

@ -0,0 +1,50 @@
#include "conf.h"
#include "lzy.h"
int main(int argc, const char **argv)
{
int x = 0;
int y = 0;
if (LZY_Init(argc, argv, "wehfou official goty", 30, "res/tset.png",
"res/font.png")) {
LZY_Log(LZY_GetError());
LZY_Quit();
return 1;
}
while (!LZY_ShouldQuit()) {
/* update */
LZY_CycleEvents();
if (LZY_KeyDown(LZYK_LEFT))
x -= 2;
if (LZY_KeyDown(LZYK_RIGHT))
x += 2;
if (LZY_KeyDown(LZYK_UP))
y -= 2;
if (LZY_KeyDown(LZYK_DOWN))
y += 2;
/* draw */
LZY_DrawBegin();
{
/* draw background */
LZY_DrawTileEx(0, 0, 0, 13, 7);
LZY_DrawTileEx(0, DISPLAY_WIDTH / 2, 0, 13, 7);
LZY_DrawTileEx(0, 0, DISPLAY_HEIGHT / 2, 13, 7);
LZY_DrawTileEx(0, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2,
13, 7);
/* draw player */
if (LZY_DrawChar('s', x, y))
LZY_Log(LZY_GetError());
}
LZY_DrawEnd();
}
LZY_Log("cya");
LZY_Quit();
return 0;
}

18
src/player.c Normal file
View File

@ -0,0 +1,18 @@
#include "player.h"
#include "lzy.h"
static float x, y, spd_x, spd_y;
void player_init(float nx, float ny)
{
x = nx;
y = ny;
spd_x = 0.0f;
spd_y = 0.0f;
}
void player_draw(void)
{
LZY_DrawSetColor(255, 0, 255);
LZY_DrawFillRect(x, y, PLAYER_WIDTH, PLAYER_HEIGHT);
}