Compare commits
5 Commits
52b3240549
...
18c8e6b887
| Author | SHA1 | Date |
|---|---|---|
|
|
18c8e6b887 | |
|
|
f599b85b67 | |
|
|
c737cf2f86 | |
|
|
96fbb318c0 | |
|
|
7a9dc006d1 |
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"intelliSenseMode": "linux-gcc-arm",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/src",
|
||||
"${workspaceFolder}/src/components",
|
||||
"${workspaceFolder}/core",
|
||||
"${workspaceFolder}/core/host/generic",
|
||||
"/usr/include/lua5.4",
|
||||
"/usr/include/pipewire-0.3",
|
||||
"/usr/include/spa-0.2",
|
||||
"/usr/include/libdrm",
|
||||
"/usr/include/libdecor-0",
|
||||
"/usr/include/x86_64-linux-gnu"
|
||||
],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"defines": [
|
||||
"-D_REENTRANT"
|
||||
],
|
||||
"cStandard": "c17",
|
||||
"browse": {
|
||||
"path": [
|
||||
"${workspaceFolder}"
|
||||
],
|
||||
"limitSymbolsToIncludedHeaders": true,
|
||||
"databaseFilename": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
|
|
@ -4,14 +4,5 @@
|
|||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug",
|
||||
"type": "gdb",
|
||||
"request": "launch",
|
||||
"target": "${workspaceFolder}/build/linux/2D_Engine",
|
||||
"cwd": "${workspaceFolder}/build/linux",
|
||||
"valuesFormatting": "parseText",
|
||||
"preLaunchTask": "Build"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,11 +1,7 @@
|
|||
{
|
||||
"nixEnvSelector.suggestion": false,
|
||||
"nixEnvSelector.nixFile": "${workspaceFolder}/shell.nix",
|
||||
"nixEnvSelector.useFlakes": false,
|
||||
|
||||
"files.associations": {
|
||||
"*.tsx": "xml",
|
||||
"*.map": "json",
|
||||
"configure": "shellscript"
|
||||
"configure": "shellscript",
|
||||
}
|
||||
}
|
||||
|
|
@ -54,6 +54,25 @@
|
|||
"clear": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Run",
|
||||
"detail": "Build project and run",
|
||||
"type": "shell",
|
||||
"command": "make",
|
||||
"args": [
|
||||
"-j$(nproc)",
|
||||
"run"
|
||||
],
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": true,
|
||||
"panel": "shared",
|
||||
"showReuseMessage": true,
|
||||
"clear": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Build Verbose",
|
||||
"detail": "Build project with verbosity on",
|
||||
|
|
@ -72,6 +91,25 @@
|
|||
"clear": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Build Debug",
|
||||
"detail": "Build project in debug mode",
|
||||
"type": "shell",
|
||||
"command": "make",
|
||||
"args": [
|
||||
"-j$(nproc)",
|
||||
"DEBUG=2"
|
||||
],
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": true,
|
||||
"panel": "shared",
|
||||
"showReuseMessage": true,
|
||||
"clear": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Run Debug",
|
||||
"detail": "Build project in debug mode and run",
|
||||
|
|
@ -91,25 +129,6 @@
|
|||
"showReuseMessage": true,
|
||||
"clear": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Build Debug",
|
||||
"detail": "Build project in debug mode",
|
||||
"type": "shell",
|
||||
"command": "make",
|
||||
"args": [
|
||||
"-j$(nproc)",
|
||||
"DEBUG=2"
|
||||
],
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": true,
|
||||
"panel": "shared",
|
||||
"showReuseMessage": true,
|
||||
"clear": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
26
Makefile
26
Makefile
|
|
@ -4,14 +4,6 @@ SHELL = /usr/bin/env bash
|
|||
|
||||
ROOT := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
ifeq ($(filter clean-all,$(MAKECMDGOALS)),)
|
||||
ifneq ($(realpath $(ROOT)/config.mk), $(ROOT)/config.mk)
|
||||
$(error ERROR: Please run the configure script before building)
|
||||
endif
|
||||
|
||||
include $(ROOT)/config.mk
|
||||
endif
|
||||
|
||||
#
|
||||
# User settings
|
||||
#
|
||||
|
|
@ -34,12 +26,28 @@ TARGET_HOST_CFLAGS += -O1 -g -DDEBUG=$(DEBUG) -Wextra -Wall --pedantic -Wno-miss
|
|||
-Wstrict-prototypes -Winline -Wundef -Wnested-externs -Wcast-qual \
|
||||
-Wshadow -Wunreachable-code -Wlogical-op -Wfloat-equal -Wstrict-aliasing=2 \
|
||||
-Wredundant-decls -Wold-style-definition
|
||||
|
||||
ASSET_BUILDER_CFLAGS += -O1 -g -DDEBUG=$(DEBUG) -Wextra -Wall --pedantic -Wno-missing-braces \
|
||||
-Wno-missing-field-initializers -Wformat=2 -Wswitch-default -Wswitch \
|
||||
-Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 \
|
||||
-Wstrict-prototypes -Winline -Wundef -Wnested-externs -Wcast-qual \
|
||||
-Wshadow -Wunreachable-code -Wlogical-op -Wfloat-equal -Wstrict-aliasing=2 \
|
||||
-Wredundant-decls -Wold-style-definition
|
||||
endif
|
||||
|
||||
#
|
||||
# End
|
||||
#
|
||||
|
||||
# Import config
|
||||
ifeq ($(filter clean-all,$(MAKECMDGOALS)),)
|
||||
ifneq ($(realpath $(ROOT)/config.mk), $(ROOT)/config.mk)
|
||||
$(error ERROR: Please run the configure script before building)
|
||||
endif
|
||||
|
||||
include $(ROOT)/config.mk
|
||||
endif
|
||||
|
||||
# Relocate vars
|
||||
BUILD_DIR := $(ROOT)/$(BUILD_DIR)/$(TARGET_HOST)
|
||||
|
||||
|
|
@ -85,5 +93,5 @@ clean-all:
|
|||
run: all
|
||||
$(Q)cd $(BUILD_DIR) && ./$(notdir $(OUTPUT))
|
||||
|
||||
print-var-% :
|
||||
print-var-% :
|
||||
@echo $($*)
|
||||
|
|
|
|||
4
TODO.md
4
TODO.md
|
|
@ -28,10 +28,10 @@
|
|||
|
||||
- [ ] Create lua component
|
||||
|
||||
- [ ] Rethink makefile structure
|
||||
|
||||
### Done
|
||||
|
||||
- [x] Rethink makefile structure
|
||||
|
||||
- [x] Make camera center on map
|
||||
|
||||
- [x] Create camera
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
gcc
|
||||
# Headers
|
||||
-Iassets/asset_builder/src/headers
|
||||
-Isrc/components
|
||||
|
||||
# Macros
|
||||
-DDEBUG=2
|
||||
|
|
@ -17,14 +17,14 @@ endif
|
|||
|
||||
$(ASSET_BUILDER_OUTPUT): $(OBJECTS)
|
||||
$(Q)mkdir -p $(dir $@)
|
||||
@echo -e "[100%] $(YELLOW)Linking $(notdir $(ASSET_BUILDER_OUTPUT))$(RESET)"
|
||||
$(Q)$(ASSET_BUILDER_CC) $(ASSET_BUILDER_CFLAGS) $(ASSET_BUILDER_LDFLAGS) $(OBJECTS) -o $@
|
||||
$(Q)$(HOST_CC) $(ASSET_BUILDER_CFLAGS) $(OBJECTS) -o $@ $(ASSET_BUILDER_LDFLAGS)
|
||||
@echo "[100%] $(YELLOW)Linking $(notdir $(ASSET_BUILDER_OUTPUT))$(RESET)"
|
||||
|
||||
$(BUILD_DIR)/$(notdir $(ASSET_BUILDER_DIR))/%.o: $(ASSET_BUILDER_DIR)/%
|
||||
$(Q)mkdir -p $(dir $@)
|
||||
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE)+1))))
|
||||
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE)*100/$(TOTAL_BUILD_FILES)))))
|
||||
@echo -e "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)"
|
||||
$(Q)$(ASSET_BUILDER_CC) $(ASSET_BUILDER_CFLAGS) $(INCLUDES:%=-I%) -MMD -MP -c $< -o $@
|
||||
$(Q)$(HOST_CC) $(ASSET_BUILDER_CFLAGS) $(INCLUDES:%=-I%) -MMD -MP -c $< -o $@
|
||||
@echo "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)"
|
||||
|
||||
-include $(ASSET_BUILDER_OBJECTS:.o=.d)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ ASSETS := \
|
|||
maps/dungeon_entry.map \
|
||||
maps/dungeon_room_1.map
|
||||
|
||||
LUA_SOURCES := \
|
||||
enemy_system.lua
|
||||
|
||||
OBJECTS := $(ASSETS:%=$(BUILD_DIR)/$(notdir $(ASSETS_DIR))/%.o)
|
||||
|
||||
ifeq ($(TOTAL_BUILD_FILES),)
|
||||
|
|
@ -16,14 +19,14 @@ TOTAL_BUILD_FILES := $(shell echo $$(($$($(MAKE) -n $(OBJECTS) TOTAL_BUILD_FILES
|
|||
endif
|
||||
|
||||
$(ASSET_OUTPUT): $(OBJECTS) $(ASSET_BUILDER_OUTPUT)
|
||||
@echo -e "[100%] $(YELLOW)Building $(notdir $(ASSET_OUTPUT))$(RESET)"
|
||||
@echo "[100%] $(YELLOW)Building $(notdir $(ASSET_OUTPUT))$(RESET)"
|
||||
$(Q)$(ASSET_BUILDER_OUTPUT) $@ $(OBJECTS)
|
||||
|
||||
$(BUILD_DIR)/$(notdir $(ASSETS_DIR))/%.o: $(ASSETS_DIR)/% $(ASSET_BUILDER_OUTPUT)
|
||||
$(Q)mkdir -p $(dir $@)
|
||||
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1))))
|
||||
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES)))))
|
||||
@echo -e "[$(PERCENTAGE)%] $(GREEN)Building ASSET object $@$(RESET)"
|
||||
@echo "[$(PERCENTAGE)%] $(GREEN)Building ASSET object $@$(RESET)"
|
||||
$(Q)$(ASSET_BUILDER_OUTPUT) $@ -c $<
|
||||
|
||||
$(ASSET_BUILDER_OUTPUT): FORCE
|
||||
|
|
|
|||
|
|
@ -26,22 +26,27 @@ print_error()
|
|||
}
|
||||
|
||||
## Parse args
|
||||
CURRENT_HOST="guess"
|
||||
TARGET_HOST="guess"
|
||||
|
||||
for i in "$@"; do
|
||||
case $i in
|
||||
--target-host=*)
|
||||
TARGET_HOST="${i#*=}"
|
||||
shift # past argument=value
|
||||
shift
|
||||
;;
|
||||
--current-host=*)
|
||||
CURRENT_HOST="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--clean)
|
||||
CLEAN=1
|
||||
EXIT_AFTER_CLEAN=1
|
||||
shift # past argument=value
|
||||
shift
|
||||
;;
|
||||
--reconfigure)
|
||||
CLEAN=1
|
||||
shift # past argument=value
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage : ./configure [OPTION]..."
|
||||
|
|
@ -51,6 +56,9 @@ for i in "$@"; do
|
|||
echo -e "\033[1m --target-host=\033[mHOST"
|
||||
echo -e "\tselect target host platform, default is \"guess\" and"
|
||||
echo -e "\twill try to configure for your current OS"
|
||||
echo -e "\033[1m --current-host=\033[mHOST"
|
||||
echo -e "\tselect current host platform, default is \"guess\" and"
|
||||
echo -e "\twill try to detect your current OS"
|
||||
echo -e "\033[1m --clean\033[m"
|
||||
echo -e "\tclean build, config, cache, etc, and exit"
|
||||
echo -e "\033[1m --reconfigure\033[m"
|
||||
|
|
@ -78,20 +86,22 @@ if [ -n "${EXIT_AFTER_CLEAN}" ]; then
|
|||
fi
|
||||
|
||||
## Deduce current and target hosts
|
||||
case "${OSTYPE}" in
|
||||
linux*)
|
||||
CURRENT_HOST="linux"
|
||||
;;
|
||||
# msys*|cygwin*)
|
||||
# CURRENT_HOST="windows"
|
||||
# ;;
|
||||
# darwin*)
|
||||
# CURRENT_HOST="macos"
|
||||
# ;;
|
||||
*)
|
||||
print_error "Current detected os is unsuppoted to build from: ${OSTYPE}\nUse --help for more informations."
|
||||
;;
|
||||
esac
|
||||
if [ "${CURRENT_HOST}" = "guess" ]; then
|
||||
case "${OSTYPE}" in
|
||||
linux*)
|
||||
CURRENT_HOST="linux"
|
||||
;;
|
||||
# msys*|cygwin*)
|
||||
# CURRENT_HOST="windows"
|
||||
# ;;
|
||||
# darwin*)
|
||||
# CURRENT_HOST="macos"
|
||||
# ;;
|
||||
*)
|
||||
print_error "Current detected os is unsuppoted to build from: ${OSTYPE}\nUse --help for more informations."
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "Configuring for current host: ${CURRENT_HOST}"
|
||||
|
||||
|
|
@ -101,8 +111,8 @@ fi
|
|||
|
||||
case "${CURRENT_HOST}" in
|
||||
linux)
|
||||
ASSET_BUILDER_CC="gcc"
|
||||
ASSET_BUILDER_AR="ar"
|
||||
HOST_CC="gcc"
|
||||
HOST_AR="ar"
|
||||
ASSET_BUILDER_CFLAGS="--std=c17 -O2 \$(shell pkg-config --cflags libpng json-c)"
|
||||
ASSET_BUILDER_LDFLAGS="\$(shell pkg-config --libs libpng json-c)"
|
||||
;;
|
||||
|
|
@ -117,17 +127,16 @@ case "${TARGET_HOST}" in
|
|||
|
||||
case "${CURRENT_HOST}" in
|
||||
linux)
|
||||
TARGET_HOST_CC="gcc"
|
||||
TARGET_HOST_AR="ar"
|
||||
TARGET_HOST_CFLAGS="--std=c17 -Os -DASSET_FILE_NAME=\\\"\$(notdir \$(ASSET_OUTPUT))\\\" -D_GNU_SOURCE=1 \$(shell pkg-config --cflags sdl3 lua)"
|
||||
TARGET_HOST_LDFLAGS="\$(shell pkg-config --libs sdl3 lua) -lm"
|
||||
TARGET_HOST_LIBCORE="libcore.a"
|
||||
;;
|
||||
*)
|
||||
print_error "Cross compiling from ${CURRENT_HOST} to ${TARGET_HOST} is not supported yet."
|
||||
print_error "Cross compiling from ${CURRENT_HOST} for ${TARGET_HOST} is not supported yet."
|
||||
;;
|
||||
esac
|
||||
|
||||
TARGET_CC="gcc"
|
||||
TARGET_AR="ar"
|
||||
TARGET_CFLAGS="--std=c17 -Os -DASSET_FILE_NAME=\\\"\$(notdir \$(ASSET_OUTPUT))\\\" -D_GNU_SOURCE=1 \$(shell pkg-config --cflags sdl3)"
|
||||
TARGET_LDFLAGS="\$(shell pkg-config --libs sdl3) -lm"
|
||||
TARGET_LIBCORE="libcore.a"
|
||||
;;
|
||||
|
||||
fxcg50)
|
||||
|
|
@ -135,17 +144,16 @@ case "${TARGET_HOST}" in
|
|||
|
||||
case "${CURRENT_HOST}" in
|
||||
linux)
|
||||
TARGET_HOST_CC="sh-elf-gcc"
|
||||
TARGET_HOST_AR="sh-elf-ar"
|
||||
TARGET_HOST_CFLAGS="--std=c17 -Os"
|
||||
TARGET_HOST_LDFLAGS=""
|
||||
TARGET_HOST_LIBCORE="libcore.a"
|
||||
;;
|
||||
*)
|
||||
print_error "Cross compiling from ${CURRENT_HOST} to ${TARGET_HOST} is not supported yet."
|
||||
print_error "Cross compiling from ${CURRENT_HOST} for ${TARGET_HOST} is not supported yet."
|
||||
;;
|
||||
esac
|
||||
|
||||
TARGET_CC="sh-elf-gcc"
|
||||
TARGET_AR="sh-elf-ar"
|
||||
TARGET_CFLAGS="--std=c17 -O3"
|
||||
TARGET_LDFLAGS=""
|
||||
TARGET_LIBCORE="libcore.a"
|
||||
;;
|
||||
*)
|
||||
print_error "Unsupported target host: ${TARGET_HOST}"
|
||||
|
|
@ -155,22 +163,24 @@ echo "Writing config file."
|
|||
echo
|
||||
echo "${CONFIG_FILE}:"
|
||||
echo "\`\`\`"
|
||||
tee ${CONFIG_FILE} <<EOF
|
||||
|
||||
tee "${CONFIG_FILE}" <<EOF
|
||||
# This file was generated by the configure script.
|
||||
|
||||
TARGET_HOST = ${TARGET_HOST}
|
||||
LIBCORE = ${TARGET_LIBCORE}
|
||||
LIBCORE = ${TARGET_HOST_LIBCORE}
|
||||
|
||||
TARGET_HOST_CC = ${TARGET_CC}
|
||||
TARGET_HOST_AR = ${TARGET_AR}
|
||||
TARGET_HOST_CFLAGS = ${TARGET_CFLAGS}
|
||||
TARGET_HOST_LDFLAGS = ${TARGET_LDFLAGS}
|
||||
TARGET_HOST_CC = ${TARGET_HOST_CC}
|
||||
TARGET_HOST_AR = ${TARGET_HOST_AR}
|
||||
TARGET_HOST_CFLAGS = ${TARGET_HOST_CFLAGS}
|
||||
TARGET_HOST_LDFLAGS = ${TARGET_HOST_LDFLAGS}
|
||||
|
||||
HOST_CC = ${HOST_CC}
|
||||
|
||||
ASSET_BUILDER_CC = ${ASSET_BUILDER_CC}
|
||||
ASSET_BUILDER_AR = ${ASSET_BUILDER_AR}
|
||||
ASSET_BUILDER_CFLAGS = ${ASSET_BUILDER_CFLAGS}
|
||||
ASSET_BUILDER_LDFLAGS = ${ASSET_BUILDER_LDFLAGS}
|
||||
EOF
|
||||
|
||||
echo "\`\`\`"
|
||||
|
||||
#
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
gcc
|
||||
# Headers
|
||||
-Icore
|
||||
-Icore/host/generic
|
||||
-Isrc/components
|
||||
|
||||
# Macros
|
||||
-DASSET_FILE_NAME="$(make print-var-ASSET_OUTPUT)"
|
||||
|
|
@ -24,14 +24,14 @@ endif
|
|||
$(LIBCORE): $(OBJECTS)
|
||||
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1))))
|
||||
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES)))))
|
||||
@echo -e "[$(PERCENTAGE)%] $(YELLOW)Creating Static Lib $@$(RESET)"
|
||||
@echo "[$(PERCENTAGE)%] $(YELLOW)Creating Static Lib $@$(RESET)"
|
||||
$(Q)$(TARGET_HOST_AR) rcs $@ $(OBJECTS)
|
||||
|
||||
$(BUILD_DIR)/$(notdir $(CORE_DIR))/%.o: $(CORE_DIR)/%
|
||||
$(Q)mkdir -p $(dir $@)
|
||||
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1))))
|
||||
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES)))))
|
||||
@echo -e "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)"
|
||||
@echo "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)"
|
||||
$(Q)$(TARGET_HOST_CC) $(TARGET_HOST_CFLAGS) $(INCLUDES:%=-I%) -MMD -MP -c $< -o $@
|
||||
|
||||
-include $(OBJECTS:.o=.d)
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
gcc
|
||||
# Headers
|
||||
-Icore
|
||||
-Icore/host/linux
|
||||
-Isrc/components
|
||||
|
|
@ -28,14 +28,19 @@ inline int display_init(void)
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef DRIVERS
|
||||
debug_printf("Listing available render drivers.");
|
||||
const int NB_DRIVERS = SDL_GetNumRenderDrivers();
|
||||
for(int i = 0; i < NB_DRIVERS; i++)
|
||||
debug_printf("%d : %s", i, SDL_GetRenderDriver(i));
|
||||
|
||||
if(DRIVERS) warning_printf("This build of 2D_Engine_C only support the following drivers : %s", DRIVERS);
|
||||
warning_printf("This build of 2D_Engine_C only support the following drivers : %s", DRIVERS);
|
||||
|
||||
game.display.renderer = SDL_CreateRenderer(game.display.window, DRIVERS);
|
||||
#else
|
||||
game.display.renderer = SDL_CreateRenderer(game.display.window, NULL);
|
||||
#endif // DRIVERS
|
||||
|
||||
if(!game.display.renderer)
|
||||
{
|
||||
error_printf("Failed to create renderer : %s", SDL_GetError());
|
||||
|
|
@ -53,13 +58,13 @@ inline int display_init(void)
|
|||
error_printf("Failed to set renderer draw blend mode : %s", SDL_GetError());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
if(!SDL_SetDefaultTextureScaleMode(game.display.renderer, SDL_SCALEMODE_NEAREST))
|
||||
{
|
||||
error_printf("Failed to set default texture scale mode : %s", SDL_GetError());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
*/
|
||||
debug_printf("Initialized display.");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
#define DISPLAY_WIDTH 720
|
||||
#define DISPLAY_HEIGHT 480
|
||||
|
||||
//#define DRIVERS NULL
|
||||
#define DRIVERS "vulkan,gpu,software"
|
||||
|
||||
typedef struct display_t {
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@ TOTAL_BUILD_FILES := $(shell echo $$(($$($(MAKE) -n $(OBJECTS) TOTAL_BUILD_FILES
|
|||
endif
|
||||
|
||||
$(OUTPUT): $(OBJECTS) $(LIBCORE)
|
||||
@echo -e "[100%] $(YELLOW)Linking $(notdir $(OUTPUT))$(RESET)"
|
||||
$(Q)$(TARGET_HOST_CC) $(TARGET_HOST_CFLAGS) $(TARGET_HOST_LDFLAGS) $(OBJECTS) -L$(BUILD_DIR) -lcore -o $@
|
||||
@echo "[100%] $(YELLOW)Linking $(notdir $(OUTPUT))$(RESET)"
|
||||
$(Q)$(TARGET_HOST_CC) $(TARGET_HOST_CFLAGS) $(OBJECTS) -o $@ -L$(BUILD_DIR) -lcore $(TARGET_HOST_LDFLAGS)
|
||||
|
||||
$(BUILD_DIR)/$(notdir $(SOURCE_DIR))/%.o: $(SOURCE_DIR)/%
|
||||
$(Q)mkdir -p $(dir $@)
|
||||
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1))))
|
||||
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES)))))
|
||||
@echo -e "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)"
|
||||
@echo "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)"
|
||||
$(Q)$(TARGET_HOST_CC) $(TARGET_HOST_CFLAGS) $(INCLUDES:%=-I%) -MMD -MP -c $< -o $@
|
||||
|
||||
$(LIBCORE): FORCE
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@
|
|||
COMPONENT(TRANSFORM_COMPONENT, transform_component, DRAW)
|
||||
COMPONENT(HITBOX_COMPONENT, hitbox_component, DRAW)
|
||||
COMPONENT(INTERACT_COMPONENT, interact_component, DRAW)
|
||||
COMPONENT(LUA_COMPONENT, lua_component, DRAW)
|
||||
#else
|
||||
COMPONENT(TRANSFORM_COMPONENT, transform_component, NO_DRAW)
|
||||
COMPONENT(HITBOX_COMPONENT, hitbox_component, NO_DRAW)
|
||||
COMPONENT(INTERACT_COMPONENT, interact_component, NO_DRAW)
|
||||
COMPONENT(LUA_COMPONENT, lua_component, NO_DRAW)
|
||||
#endif // DEBUG >= 2
|
||||
|
||||
COMPONENT(PHYSICS_SYSTEM, physics_system, NO_DRAW)
|
||||
|
|
@ -18,7 +20,6 @@ COMPONENT(ANIMATION_SYSTEM, animation_system, NO_DRAW)
|
|||
COMPONENT(PLAYER_SYSTEM, player_system, NO_DRAW)
|
||||
COMPONENT(LEVER_COMPONENT, lever_component, NO_DRAW)
|
||||
COMPONENT(DOOR_COMPONENT, door_component, NO_DRAW)
|
||||
// COMPONENT(LUA_COMPONENT, lua_component, NO_DRAW)
|
||||
// Add new components definition here
|
||||
|
||||
#undef COMPONENT
|
||||
|
|
|
|||
|
|
@ -1,6 +1,51 @@
|
|||
#ifndef LUA_COMPONENT_H
|
||||
#define LUA_COMPONENT_H
|
||||
#include "lua_component.h"
|
||||
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <lualib.h>
|
||||
#include "game.h"
|
||||
#include "ecs.h"
|
||||
#include "memory_alloc.h"
|
||||
#include "errors.h"
|
||||
|
||||
inline int lua_component_init(component_t *component)
|
||||
{
|
||||
lua_component_data_t *component_data = component->data;
|
||||
|
||||
#endif // LUA_COMPONENT_H
|
||||
component_data->lua_state = luaL_newstate();
|
||||
|
||||
luaL_openlibs(component_data->lua_state);
|
||||
|
||||
luaL_dostring(component_data->lua_state, "function f (a) print(a) end");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
inline int lua_component_update(component_t *component __attribute__((unused)))
|
||||
{
|
||||
lua_component_data_t *component_data = component->data;
|
||||
|
||||
luaL_dostring(component_data->lua_state, "f(\"prout\")");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#if DEBUG >= 2
|
||||
#include "display.h"
|
||||
|
||||
inline int lua_component_draw(const component_t *component)
|
||||
{
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif // DEBUG >= 2
|
||||
|
||||
inline int lua_component_destroy(component_t *component)
|
||||
{
|
||||
lua_component_data_t *component_data = component->data;
|
||||
|
||||
lua_close(component_data->lua_state);
|
||||
|
||||
free(component_data);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef LUA_COMPONENT_H
|
||||
#define LUA_COMPONENT_H
|
||||
|
||||
#include <lua.h>
|
||||
#include "ecs.h"
|
||||
#include "errors.h"
|
||||
|
||||
typedef struct lua_component_data_t {
|
||||
lua_State *lua_state;
|
||||
} lua_component_data_t;
|
||||
|
||||
int lua_component_init(component_t *component);
|
||||
int lua_component_update(component_t *component);
|
||||
#if DEBUG >= 2
|
||||
int lua_component_draw(const component_t *component);
|
||||
#endif // DEBUG >= 2
|
||||
int lua_component_destroy(component_t *component);
|
||||
|
||||
#endif // LUA_COMPONENT_H
|
||||
10
src/game.c
10
src/game.c
|
|
@ -21,7 +21,7 @@ int game_init(void)
|
|||
entity_manager_init();
|
||||
if(asset_manager_init()) return_failure_int;
|
||||
|
||||
asset_t *map_asset = asset_manager_load_asset("dungeon_room_1", ASSET_MAP);
|
||||
asset_t *map_asset = asset_manager_load_asset("dungeon_entry", ASSET_MAP);
|
||||
if(!map_asset) return_failure_int;
|
||||
|
||||
game.map = map_asset->data;
|
||||
|
|
@ -118,7 +118,15 @@ int game_init(void)
|
|||
|
||||
if(!entity_new_component(player_entity, PLAYER_SYSTEM)) return_failure_int;
|
||||
}
|
||||
/* ======== Enemy ======== */
|
||||
/*
|
||||
{
|
||||
entity_t *enemy_entity = entity_manager_new_entity(1);
|
||||
if(!enemy_entity) return_failure_int;
|
||||
|
||||
if(!entity_new_component(enemy_entity, LUA_COMPONENT)) return_failure_int;
|
||||
}
|
||||
*/
|
||||
game.is_running = true;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
Loading…
Reference in New Issue