merge
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
bin/
|
||||||
|
compile_commands.json
|
||||||
|
*.data
|
||||||
@@ -21,7 +21,10 @@ C_FLAGS = \
|
|||||||
$(C_FLAG_NO_UNKNOWN_PRAGMAS)
|
$(C_FLAG_NO_UNKNOWN_PRAGMAS)
|
||||||
|
|
||||||
# INCLUDE FLGAS
|
# INCLUDE FLGAS
|
||||||
INCLUDE_FLAGS = -Iinclude
|
INCLUDE_FLAGS = \
|
||||||
|
-Iinclude \
|
||||||
|
$(EXTERNAL_FLAGS) \
|
||||||
|
$(RAYLIB_CFLAGS)
|
||||||
|
|
||||||
# EXTERNAL FLAGS
|
# EXTERNAL FLAGS
|
||||||
EXTERNAL_RAYGUI = -Iexternal/raygui
|
EXTERNAL_RAYGUI = -Iexternal/raygui
|
||||||
@@ -34,11 +37,13 @@ EXTERNAL_FLAGS = \
|
|||||||
ifeq ($(OS), Windows_NT)
|
ifeq ($(OS), Windows_NT)
|
||||||
SRC = $(wildcard src\*.c)
|
SRC = $(wildcard src\*.c)
|
||||||
TARGET = bin\win\game.exe
|
TARGET = bin\win\game.exe
|
||||||
RAYLIB_FLAGS = -I%RAYLIB% -L%RAYLIB% -lraylib -lopengl32 -lgdi32 -lwinmm
|
RAYLIB_CFLAGS = -I%RAYLIB%
|
||||||
|
RAYLIB_LIBS = -L%RAYLIB% -lraylib -lopengl32 -lgdi32 -lwinmm
|
||||||
else
|
else
|
||||||
SRC = $(wildcard src/*.c)
|
SRC = $(wildcard src/*.c)
|
||||||
TARGET = bin/unix/game
|
TARGET = bin/unix/game
|
||||||
RAYLIB_FLAGS = $(shell pkg-config --libs --cflags raylib) -lm
|
RAYLIB_CFLAGS = $(shell pkg-config --cflags raylib)
|
||||||
|
RAYLIB_LIBS = $(shell pkg-config --libs raylib) -lm
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# CREATE BIN DIR
|
# CREATE BIN DIR
|
||||||
@@ -46,7 +51,10 @@ $(shell mkdir -p bin/unix bin/win)
|
|||||||
|
|
||||||
# COMMANDS
|
# COMMANDS
|
||||||
build: $(SRC)
|
build: $(SRC)
|
||||||
$(COMPILER) $(SRC) -o $(TARGET) $(C_FLAGS) $(INCLUDE_FLAGS) $(EXTERNAL_FLAGS) $(RAYLIB_FLAGS)
|
$(COMPILER) $(SRC) -o $(TARGET) \
|
||||||
|
$(C_FLAGS) \
|
||||||
|
$(INCLUDE_FLAGS) \
|
||||||
|
$(RAYLIB_LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(TARGET)
|
rm -rf $(TARGET)
|
||||||
|
|||||||
@@ -1,684 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/app.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/app.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appGameBirds.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appGameBirds.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appGame.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appGame.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appGameEnemies.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appGameEnemies.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appGameFloor.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appGameFloor.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appGameIslands.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appGameIslands.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appGamePlayer.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appGamePlayer.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appGameShip.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appGameShip.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appGameShoot.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appGameShoot.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appLogo.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appLogo.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appMenu.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appMenu.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appMenuMainBackground.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appMenuMainBackground.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appMenuMain.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appMenuMain.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appMenuSettings.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appMenuSettings.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/appState.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/appState.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/engineAnimation.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/engineAnimation.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/engineArray.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/engineArray.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/engineCamera.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/engineCamera.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/engineConfig.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/engineConfig.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/engineFont.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/engineFont.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/engineGamegui.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/engineGamegui.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/engineGui.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/engineGui.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/engineInput.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/engineInput.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/engineObject.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/engineObject.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/enginePhysics.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/enginePhysics.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/enginePostfx.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/enginePostfx.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/engineRectangle.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/engineRectangle.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/engineSoundtrack.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/engineSoundtrack.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/engineSprite.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/engineSprite.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/engineVector.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/engineVector.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
"/usr/bin/gcc",
|
|
||||||
"-c",
|
|
||||||
"-std=c99",
|
|
||||||
"-g",
|
|
||||||
"-Wall",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
"-Iinclude",
|
|
||||||
"-Iexternal/rini",
|
|
||||||
"-Iexternal/raygui",
|
|
||||||
"-o",
|
|
||||||
"bin/osx/game",
|
|
||||||
"src/main.c"
|
|
||||||
],
|
|
||||||
"directory": "/home/huaqo/dev/the-last-hive",
|
|
||||||
"file": "/home/huaqo/dev/the-last-hive/src/main.c",
|
|
||||||
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
HEALTH_MAX = 100
|
||||||
|
START_GOLD = 0
|
||||||
@@ -108,7 +108,11 @@ typedef struct {
|
|||||||
Animation animation;
|
Animation animation;
|
||||||
Physics physics;
|
Physics physics;
|
||||||
float rotation;
|
float rotation;
|
||||||
|
<<<<<<< HEAD
|
||||||
Sound soundFlapping;
|
Sound soundFlapping;
|
||||||
|
=======
|
||||||
|
int health;
|
||||||
|
>>>>>>> origin/pirate
|
||||||
int gold;
|
int gold;
|
||||||
} Player;
|
} Player;
|
||||||
|
|
||||||
@@ -260,9 +264,15 @@ Projectiles CreateProjectiles(void);
|
|||||||
void UpdateProjectiles(Projectiles *projectiles, Enemies *enemies);
|
void UpdateProjectiles(Projectiles *projectiles, Enemies *enemies);
|
||||||
void RenderProjectiles(Projectiles *projectiles);
|
void RenderProjectiles(Projectiles *projectiles);
|
||||||
|
|
||||||
|
void CheckPlayerCollisions(Player *player, Enemies *enemies);
|
||||||
|
void CheckEnemyCollisions(Enemies *enemies);
|
||||||
|
void CheckProjectileCollisions(Projectiles *projectiles, Enemies *enemies,
|
||||||
|
Player *player);
|
||||||
|
|
||||||
void InitGame(App *app);
|
void InitGame(App *app);
|
||||||
void UpdateGame(App *app);
|
void UpdateGame(App *app);
|
||||||
void RenderComponents(App *app);
|
void RenderComponents(App *app);
|
||||||
|
void RenderOverlay(Mouse *mouse);
|
||||||
void RenderGame(App *app);
|
void RenderGame(App *app);
|
||||||
void CleanupGame(App *app);
|
void CleanupGame(App *app);
|
||||||
|
|
||||||
|
|||||||
+125
-115
@@ -1,190 +1,189 @@
|
|||||||
#ifndef ENGINE_H
|
#ifndef ENGINE_H
|
||||||
#define ENGINE_H
|
#define ENGINE_H
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <raygui.h>
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <raymath.h>
|
#include <raymath.h>
|
||||||
#include <raygui.h>
|
|
||||||
#include <rini.h>
|
#include <rini.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
Texture2D texture;
|
||||||
Texture2D texture;
|
Rectangle sourceRec;
|
||||||
Rectangle sourceRec;
|
Rectangle destRec;
|
||||||
Rectangle destRec;
|
Vector2 frameSize;
|
||||||
Vector2 frameSize;
|
Vector2 origin;
|
||||||
Vector2 origin;
|
float rotation;
|
||||||
float rotation;
|
Color color;
|
||||||
Color color;
|
|
||||||
} Sprite;
|
} Sprite;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int state;
|
int state;
|
||||||
int currentFrame;
|
int currentFrame;
|
||||||
int maxFrame;
|
int maxFrame;
|
||||||
int framesCounter;
|
int framesCounter;
|
||||||
int framesSpeed;
|
int framesSpeed;
|
||||||
float animTimer;
|
float animTimer;
|
||||||
} Animation;
|
} Animation;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void** elements;
|
void **elements;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
unsigned int capacity;
|
unsigned int capacity;
|
||||||
} Array;
|
} Array;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char* path;
|
const char *path;
|
||||||
float frameWidth;
|
float frameWidth;
|
||||||
float frameHeight;
|
float frameHeight;
|
||||||
float rotation;
|
float rotation;
|
||||||
} TextureAsset;
|
} TextureAsset;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char* path;
|
const char *path;
|
||||||
} ShaderAsset;
|
} ShaderAsset;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char* path;
|
const char *path;
|
||||||
} SoundtrackAsset;
|
} SoundtrackAsset;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char* path;
|
const char *path;
|
||||||
} SoundAsset;
|
} SoundAsset;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const TextureAsset *textureAssets;
|
const TextureAsset *textureAssets;
|
||||||
const ShaderAsset *shaderAssets;
|
const ShaderAsset *shaderAssets;
|
||||||
const SoundtrackAsset *soundtrackAssets;
|
const SoundtrackAsset *soundtrackAssets;
|
||||||
const SoundAsset *soundAssets;
|
const SoundAsset *soundAssets;
|
||||||
} Assets;
|
} Assets;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *path;
|
char *path;
|
||||||
rini_config rini;
|
rini_config rini;
|
||||||
} Config;
|
} Config;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum { NOT_CLICKED, HOVER, CLICKED } ButtonState;
|
||||||
NOT_CLICKED,
|
|
||||||
HOVER,
|
|
||||||
CLICKED
|
|
||||||
} ButtonState;
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
Sprite sprite;
|
||||||
Sprite sprite;
|
Vector2 notClicked;
|
||||||
Vector2 notClicked;
|
Vector2 hover;
|
||||||
Vector2 hover;
|
Vector2 clicked;
|
||||||
Vector2 clicked;
|
bool isHovered;
|
||||||
bool isHovered;
|
bool isClicked;
|
||||||
bool isClicked;
|
|
||||||
} ImageButton;
|
} ImageButton;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
Sprite sprite;
|
||||||
Sprite sprite;
|
|
||||||
} ImageElement;
|
} ImageElement;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
Rectangle rec;
|
||||||
Rectangle rec;
|
char *text;
|
||||||
char *text;
|
|
||||||
} Button;
|
} Button;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Vector2 screenPosition;
|
Vector2 screenPosition;
|
||||||
Vector2 worldPosition;
|
Vector2 worldPosition;
|
||||||
float zoomSpeed;
|
float zoomSpeed;
|
||||||
float minZoom;
|
float minZoom;
|
||||||
float maxZoom;
|
float maxZoom;
|
||||||
float scaleFactor;
|
float scaleFactor;
|
||||||
float wheelMove;
|
float wheelMove;
|
||||||
bool leftButton;
|
bool leftButton;
|
||||||
bool rightButton;
|
bool rightButton;
|
||||||
Texture2D cursorTexture;
|
Texture2D cursorTexture;
|
||||||
} Mouse;
|
} Mouse;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Sprite sprite;
|
Sprite sprite;
|
||||||
Vector2 position;
|
Vector2 position;
|
||||||
} Object;
|
} Object;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Object *data;
|
Object *data;
|
||||||
const Object *prototype;
|
const Object *prototype;
|
||||||
size_t count;
|
size_t count;
|
||||||
} ObjectArray;
|
} ObjectArray;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
Vector2 position;
|
||||||
Vector2 position;
|
Vector2 direction;
|
||||||
Vector2 direction;
|
Vector2 velocity;
|
||||||
Vector2 velocity;
|
float speed;
|
||||||
float speed;
|
float weight;
|
||||||
} Physics;
|
} Physics;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Shader shader;
|
Shader shader;
|
||||||
int resolutionLoc;
|
int resolutionLoc;
|
||||||
int strengthLoc;
|
int strengthLoc;
|
||||||
float strength;
|
float strength;
|
||||||
} PostProcessing;
|
} PostProcessing;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Music music;
|
Music music;
|
||||||
bool playing;
|
bool playing;
|
||||||
bool paused;
|
bool paused;
|
||||||
} Soundtrack;
|
} Soundtrack;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Vector2 *data;
|
Vector2 *data;
|
||||||
size_t count;
|
size_t count;
|
||||||
} Vector2Array;
|
} Vector2Array;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
const char* title;
|
const char *title;
|
||||||
} Window;
|
} Window;
|
||||||
|
|
||||||
void UpdateAnimation(Animation *animation, float deltaTime);
|
void UpdateAnimation(Animation *animation, float deltaTime);
|
||||||
|
|
||||||
Array* CreateArray(unsigned int initCapacity);
|
Array *CreateArray(unsigned int initCapacity);
|
||||||
int AddElementToArray(Array* array, void* element);
|
int AddElementToArray(Array *array, void *element);
|
||||||
int RemoveElementFromArray(Array* array, unsigned int index);
|
int RemoveElementFromArray(Array *array, unsigned int index);
|
||||||
void* GetRandomElementFromArray(Array* array);
|
void *GetRandomElementFromArray(Array *array);
|
||||||
void UpdateArray(Array* array, void (*updateFunc)(void*));
|
void UpdateArray(Array *array, void (*updateFunc)(void *));
|
||||||
void RenderArray(Array* array, void (*renderFunc)(void*));
|
void RenderArray(Array *array, void (*renderFunc)(void *));
|
||||||
void FreeArray(Array** array);
|
void FreeArray(Array **array);
|
||||||
|
|
||||||
Camera2D* GetCamera(void);
|
Camera2D *GetCamera(void);
|
||||||
Rectangle GetCameraRectangle(void);
|
Rectangle GetCameraRectangle(void);
|
||||||
void CreateCamera(Vector2 playerPosition, float initZoom);
|
void CreateCamera(Vector2 playerPosition, float initZoom);
|
||||||
void UpdateCameraTarget(Vector2 *position, const float smoothness);
|
void UpdateCameraTarget(Vector2 *position, const float smoothness);
|
||||||
void UpdateCameraZoom(const float *scaleFactor, const float *minZoom, const float *maxZoom);
|
void UpdateCameraZoom(const float *scaleFactor, const float *minZoom,
|
||||||
void UpdateCamera2D(Vector2* position, Mouse* mouse);
|
const float *maxZoom);
|
||||||
|
void UpdateCamera2D(Vector2 *position, Mouse *mouse);
|
||||||
|
|
||||||
void InitConfig(Config *config, const char* path);
|
void InitConfig(Config *config, const char *path);
|
||||||
int GetConfigInt(Config *config, const char *key);
|
int GetConfigInt(Config *config, const char *key);
|
||||||
int GetConfigIntOrDefault(Config *config, const char *key, int default_value);
|
int GetConfigIntOrDefault(Config *config, const char *key, int default_value);
|
||||||
const char* GetConfigString(Config *config, const char *key);
|
const char *GetConfigString(Config *config, const char *key);
|
||||||
const char* GetConfigStringOrDefault(Config *config, const char *key, const char *default_value);
|
const char *GetConfigStringOrDefault(Config *config, const char *key,
|
||||||
const char* GetConfigDescription(Config *config, const char *key);
|
const char *default_value);
|
||||||
|
const char *GetConfigDescription(Config *config, const char *key);
|
||||||
int SetConfigInt(Config *config, const char *key, int value, const char *desc);
|
int SetConfigInt(Config *config, const char *key, int value, const char *desc);
|
||||||
int SetConfigString(Config *config, const char *key, const char *text, const char *desc);
|
int SetConfigString(Config *config, const char *key, const char *text,
|
||||||
|
const char *desc);
|
||||||
int SetConfigDescription(Config *config, const char *key, const char *desc);
|
int SetConfigDescription(Config *config, const char *key, const char *desc);
|
||||||
int AddCommentLine(Config *config, const char *comment);
|
int AddCommentLine(Config *config, const char *comment);
|
||||||
void SaveConfig(Config *config);
|
void SaveConfig(Config *config);
|
||||||
void CleanUpConfig(Config *config);
|
void CleanUpConfig(Config *config);
|
||||||
|
|
||||||
void InitFont(Font *font, const char* path);
|
void InitFont(Font *font, const char *path);
|
||||||
void CleanupFont(Font *font);
|
void CleanupFont(Font *font);
|
||||||
|
|
||||||
ImageButton CreateImageButton(ButtonState state, Texture2D *texture, const TextureAsset *asset, Vector2 *source, Vector2 *clicked, Vector2 *hover, Rectangle *destRec);
|
ImageButton CreateImageButton(ButtonState state, Texture2D *texture,
|
||||||
ImageElement CreateImageElement(Texture2D *texture, const TextureAsset *asset, Vector2 *source, Rectangle *destRec);
|
const TextureAsset *asset, Vector2 *source,
|
||||||
|
Vector2 *clicked, Vector2 *hover,
|
||||||
|
Rectangle *destRec);
|
||||||
|
ImageElement CreateImageElement(Texture2D *texture, const TextureAsset *asset,
|
||||||
|
Vector2 *source, Rectangle *destRec);
|
||||||
int isImageButtonClicked(ImageButton *b, Sound soundHover, Sound soundClick);
|
int isImageButtonClicked(ImageButton *b, Sound soundHover, Sound soundClick);
|
||||||
void renderImageButton(ImageButton *b);
|
void renderImageButton(ImageButton *b);
|
||||||
void renderImageElement(ImageElement *e);
|
void renderImageElement(ImageElement *e);
|
||||||
@@ -193,18 +192,24 @@ Button initButton(char *text, Vector2 dimensions, Vector2 position);
|
|||||||
int isButtonClicked(Button *b);
|
int isButtonClicked(Button *b);
|
||||||
void renderButton(Button *b);
|
void renderButton(Button *b);
|
||||||
|
|
||||||
Mouse CreateMouse(float zoomSpeed, float minZoom, float maxZoom, Texture2D *texture);
|
Mouse CreateMouse(float zoomSpeed, float minZoom, float maxZoom,
|
||||||
|
Texture2D *texture);
|
||||||
void UpdateMouseScreen(Mouse *mouse);
|
void UpdateMouseScreen(Mouse *mouse);
|
||||||
void UpdateMouse(Mouse *mouse);
|
void UpdateMouse(Mouse *mouse);
|
||||||
Vector2 GetDirectionVector(void);
|
Vector2 GetDirectionVector(void);
|
||||||
|
|
||||||
ObjectArray CreateObjectArray(const Object *prototype, const size_t count);
|
ObjectArray CreateObjectArray(const Object *prototype, const size_t count);
|
||||||
Object* GetRandomObject(ObjectArray *objects);
|
Object *GetRandomObject(ObjectArray *objects);
|
||||||
void AddObjectToArray(ObjectArray *objects, const Object *prototype, Vector2 position);
|
void AddObjectToArray(ObjectArray *objects, const Object *prototype,
|
||||||
void SetPositionForObjectArray(ObjectArray *objects, const Vector2Array *positions);
|
Vector2 position);
|
||||||
void SetRandomPositionForObjectArray(ObjectArray *objects, const Rectangle bounds);
|
void SetPositionForObjectArray(ObjectArray *objects,
|
||||||
void SwapAndPopObjectsArrayOnRecCollision(ObjectArray *objects, const Rectangle rec);
|
const Vector2Array *positions);
|
||||||
void SwapAndPopObjectsArrayOnPointCollision(ObjectArray *objects, const Vector2 point);
|
void SetRandomPositionForObjectArray(ObjectArray *objects,
|
||||||
|
const Rectangle bounds);
|
||||||
|
void SwapAndPopObjectsArrayOnRecCollision(ObjectArray *objects,
|
||||||
|
const Rectangle rec);
|
||||||
|
void SwapAndPopObjectsArrayOnPointCollision(ObjectArray *objects,
|
||||||
|
const Vector2 point);
|
||||||
void RenderObjectArray(const ObjectArray *objects);
|
void RenderObjectArray(const ObjectArray *objects);
|
||||||
|
|
||||||
Vector2 GetDirectionBetweenTwoVectors(Vector2 vec1, Vector2 vec2);
|
Vector2 GetDirectionBetweenTwoVectors(Vector2 vec1, Vector2 vec2);
|
||||||
@@ -215,12 +220,12 @@ void UpdatePhysicsPosition(Vector2 *position, Vector2 *velocity);
|
|||||||
void UpdatePhysicsSpeed(float *speed, float *newSpeed);
|
void UpdatePhysicsSpeed(float *speed, float *newSpeed);
|
||||||
void UpdatePhysics(Physics *physics, Vector2 direction);
|
void UpdatePhysics(Physics *physics, Vector2 direction);
|
||||||
|
|
||||||
PostProcessing CreatePostFX(const char* shaderPath);
|
PostProcessing CreatePostFX(const char *shaderPath);
|
||||||
void UpdatePostFX(PostProcessing *postFX);
|
void UpdatePostFX(PostProcessing *postFX);
|
||||||
void RenderPostFX(PostProcessing *postFX, RenderTexture2D *target);
|
void RenderPostFX(PostProcessing *postFX, RenderTexture2D *target);
|
||||||
void UnloadPostFX(PostProcessing *postFX);
|
void UnloadPostFX(PostProcessing *postFX);
|
||||||
|
|
||||||
Soundtrack LoadSoundtrack(const char* musicPath);
|
Soundtrack LoadSoundtrack(const char *musicPath);
|
||||||
void UpdateSoundtrack(Soundtrack *soundtrack, bool playing);
|
void UpdateSoundtrack(Soundtrack *soundtrack, bool playing);
|
||||||
|
|
||||||
void UpdateSpriteSourceRec(Sprite *sprite, const Vector2 *vector);
|
void UpdateSpriteSourceRec(Sprite *sprite, const Vector2 *vector);
|
||||||
@@ -233,12 +238,17 @@ bool IsVectorZero(Vector2 v);
|
|||||||
Vector2 GetRandomVector(const Rectangle bounds);
|
Vector2 GetRandomVector(const Rectangle bounds);
|
||||||
Vector2 RotationToVector2(float rotation);
|
Vector2 RotationToVector2(float rotation);
|
||||||
float Vector2ToRotation(Vector2 vec);
|
float Vector2ToRotation(Vector2 vec);
|
||||||
|
float Cross2D(Vector2 a, Vector2 b);
|
||||||
|
|
||||||
Vector2 GetPositionInsideRectangle(Rectangle rec);
|
Vector2 GetPositionInsideRectangle(Rectangle rec);
|
||||||
Vector2 GetPositionOutsideRectangle(Rectangle rec, int min, int max);
|
Vector2 GetPositionOutsideRectangle(Rectangle rec, int min, int max);
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
bool SaveStorageValue(const char* fileName, unsigned int position, int value);
|
bool SaveStorageValue(const char* fileName, unsigned int position, int value);
|
||||||
int LoadStorageValue(const char* fileName, unsigned int position);
|
int LoadStorageValue(const char* fileName, unsigned int position);
|
||||||
|
|
||||||
#endif //ENGINE_H
|
#endif //ENGINE_H
|
||||||
|
|
||||||
|
=======
|
||||||
|
#endif // ENGINE_H
|
||||||
|
>>>>>>> origin/pirate
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# 04.07.26
|
||||||
|
|
||||||
|
What i can do next:
|
||||||
|
|
||||||
|
- Player health bar
|
||||||
|
- Enemy health
|
||||||
|
- Enemy shooting
|
||||||
|
- Enemy Projectile -> player collisions effect
|
||||||
|
- Player Projectile -> Enemy collision effect
|
||||||
|
- End screen or something
|
||||||
|
- Shader for foam when driving
|
||||||
+12
-1
@@ -69,8 +69,15 @@ void UpdateGame(App *app) {
|
|||||||
UpdateBirds(&g->birds);
|
UpdateBirds(&g->birds);
|
||||||
UpdateEnemies(&g->enemies, &g->projectiles);
|
UpdateEnemies(&g->enemies, &g->projectiles);
|
||||||
UpdateIslands(&g->islands);
|
UpdateIslands(&g->islands);
|
||||||
|
<<<<<<< HEAD
|
||||||
UpdateProjectiles(&g->projectiles, &g->enemies);
|
UpdateProjectiles(&g->projectiles, &g->enemies);
|
||||||
UpdateSoundtrack(&g->soundtracks[AMBIENT], app->flags.soundtrackOn);
|
UpdateSoundtrack(&g->soundtracks[AMBIENT], app->flags.soundtrackOn);
|
||||||
|
=======
|
||||||
|
UpdateProjectiles(&g->projectiles);
|
||||||
|
CheckPlayerCollisions(GetPlayer(), &app->game.enemies);
|
||||||
|
CheckEnemyCollisions(&app->game.enemies);
|
||||||
|
CheckProjectileCollisions(&app->game.projectiles, &app->game.enemies, GetPlayer());
|
||||||
|
>>>>>>> origin/pirate
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderComponents(App *app) {
|
void RenderComponents(App *app) {
|
||||||
@@ -92,6 +99,7 @@ void RenderGame(App *app) {
|
|||||||
BeginMode2D(*camera);
|
BeginMode2D(*camera);
|
||||||
RenderComponents(app);
|
RenderComponents(app);
|
||||||
EndMode2D();
|
EndMode2D();
|
||||||
|
<<<<<<< HEAD
|
||||||
DrawTextureRec(
|
DrawTextureRec(
|
||||||
g->mouse.cursorTexture,
|
g->mouse.cursorTexture,
|
||||||
(Rectangle){0, 0, g->mouse.cursorTexture.width,
|
(Rectangle){0, 0, g->mouse.cursorTexture.width,
|
||||||
@@ -100,8 +108,11 @@ void RenderGame(App *app) {
|
|||||||
|
|
||||||
Player *player = GetPlayer();
|
Player *player = GetPlayer();
|
||||||
DrawText(TextFormat("Gold: %u", player->gold), 0.0f, 0.0f, 12.0f, YELLOW);
|
DrawText(TextFormat("Gold: %u", player->gold), 0.0f, 0.0f, 12.0f, YELLOW);
|
||||||
|
=======
|
||||||
|
RenderOverlay(&g->mouse);
|
||||||
|
>>>>>>> origin/pirate
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(BLACK);
|
ClearBackground(BLACK);
|
||||||
for (int i = 0; i < SHADER_COUNT; i++) {
|
for (int i = 0; i < SHADER_COUNT; i++) {
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
#include "app.h"
|
||||||
|
|
||||||
|
float playerCollisionRadius = 8.0f;
|
||||||
|
float enemiesCollisionRadius = 8.0f;
|
||||||
|
float projectilesCollisionRadius = 1.0f;
|
||||||
|
|
||||||
|
void CheckPlayerCollisions(Player *player, Enemies *enemies) {
|
||||||
|
for (int i = 0; i < enemies->count; i++) {
|
||||||
|
|
||||||
|
Vector2 playerPos = player->physics.position;
|
||||||
|
Vector2 enemiesPos = enemies->physics[i].position;
|
||||||
|
|
||||||
|
float minDist = playerCollisionRadius + enemiesCollisionRadius;
|
||||||
|
|
||||||
|
if (CheckCollisionCircles(playerPos, playerCollisionRadius, enemiesPos,
|
||||||
|
enemiesCollisionRadius)) {
|
||||||
|
|
||||||
|
player->health -= 1;
|
||||||
|
|
||||||
|
float dist = GetDistanceBetweenTwoVectors(playerPos, enemiesPos);
|
||||||
|
float overlap = minDist - dist;
|
||||||
|
|
||||||
|
if (dist > 0.0f) {
|
||||||
|
Vector2 collisionVector = GetDirectionBetweenTwoVectors(
|
||||||
|
enemies->physics[i].position, player->physics.position);
|
||||||
|
player->physics.position.x += collisionVector.x * overlap;
|
||||||
|
player->physics.position.y += collisionVector.y * overlap;
|
||||||
|
Vector2 forward = RotationToVector2(player->rotation - 90.0f);
|
||||||
|
float side = Cross2D(forward, collisionVector);
|
||||||
|
player->rotation += side * 120.0f * GetFrameTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckEnemyCollisions(Enemies *enemies) {
|
||||||
|
for (int a = 0; a < enemies->count; a++) {
|
||||||
|
for (int b = a + 1; b < enemies->count; b++) {
|
||||||
|
|
||||||
|
Vector2 posA = enemies->physics[a].position;
|
||||||
|
Vector2 posB = enemies->physics[b].position;
|
||||||
|
|
||||||
|
float minDist = enemiesCollisionRadius * 2;
|
||||||
|
|
||||||
|
if (CheckCollisionCircles(posA, enemiesCollisionRadius, posB,
|
||||||
|
enemiesCollisionRadius)) {
|
||||||
|
|
||||||
|
Vector2 collisionVectorA = GetDirectionBetweenTwoVectors(posB, posA);
|
||||||
|
Vector2 collisionVectorB = GetDirectionBetweenTwoVectors(posA, posB);
|
||||||
|
float dist = GetDistanceBetweenTwoVectors(posA, posB);
|
||||||
|
float overlap = minDist - dist;
|
||||||
|
|
||||||
|
if (dist > 0.0f) {
|
||||||
|
enemies->physics[a].position.x += collisionVectorA.x * overlap * 0.5f;
|
||||||
|
enemies->physics[a].position.y += collisionVectorA.y * overlap * 0.5f;
|
||||||
|
|
||||||
|
enemies->physics[b].position.x += collisionVectorB.x * overlap * 0.5f;
|
||||||
|
enemies->physics[b].position.y += collisionVectorB.y * overlap * 0.5f;
|
||||||
|
|
||||||
|
Vector2 forwardA =
|
||||||
|
RotationToVector2(enemies->sprite[a].rotation - 90.0f);
|
||||||
|
Vector2 forwardB =
|
||||||
|
RotationToVector2(enemies->sprite[b].rotation - 90.0f);
|
||||||
|
float sideA = Cross2D(forwardA, collisionVectorA);
|
||||||
|
float sideB = Cross2D(forwardB, collisionVectorB);
|
||||||
|
enemies->sprite[a].rotation += sideA * 120.0f * GetFrameTime();
|
||||||
|
enemies->sprite[b].rotation += sideB * 120.0f * GetFrameTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckProjectileCollisions(Projectiles *projectiles, Enemies *enemies,
|
||||||
|
Player *player) {
|
||||||
|
for (int i = 0; i < projectiles->count; i++) {
|
||||||
|
if (!projectiles->active[i])
|
||||||
|
continue;
|
||||||
|
Vector2 projectilePos = projectiles->physics[i].position;
|
||||||
|
for (int j = 0; j < enemies->count; j++) {
|
||||||
|
Vector2 enemyPos = enemies->physics[j].position;
|
||||||
|
|
||||||
|
if (CheckCollisionCircles(projectilePos, projectilesCollisionRadius,
|
||||||
|
enemyPos, enemiesCollisionRadius)) {
|
||||||
|
player->gold += 20;
|
||||||
|
Rectangle cameraRec = GetCameraRectangle();
|
||||||
|
enemies->physics[j].position =
|
||||||
|
GetPositionOutsideRectangle(cameraRec, 100, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!projectiles->active[i])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Vector2 playerPos = player->physics.position;
|
||||||
|
if (CheckCollisionCircles(projectilePos, projectilesCollisionRadius,
|
||||||
|
playerPos, playerCollisionRadius)) {
|
||||||
|
|
||||||
|
player->health -= 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+82
-28
@@ -1,47 +1,62 @@
|
|||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
const TextureAsset enemiesTextureAssets[ENEMIES_TEX_COUNT] = {
|
const TextureAsset enemiesTextureAssets[ENEMIES_TEX_COUNT] = {
|
||||||
{"assets/ship_start.png", 16.0f, 16.0f, 90.0f}};
|
{"assets/ship_start.png", 16.0f, 16.0f, 90.0f}
|
||||||
|
};
|
||||||
|
|
||||||
Enemies CreateEnemies(void) {
|
Enemies CreateEnemies(void){
|
||||||
Enemies enemies = {.count = MAX_ENEMIES};
|
Enemies enemies = {.count = MAX_ENEMIES};
|
||||||
TextureAsset textureAsset = enemiesTextureAssets[BOAT];
|
TextureAsset textureAsset = enemiesTextureAssets[BOAT];
|
||||||
Texture2D texture = LoadTexture(textureAsset.path);
|
Texture2D texture = LoadTexture(textureAsset.path);
|
||||||
float frameWidth = textureAsset.frameWidth;
|
float frameWidth = textureAsset.frameWidth;
|
||||||
float rotation = textureAsset.rotation;
|
float rotation = textureAsset.rotation;
|
||||||
|
|
||||||
for (int i = 0; i < enemies.count; i++) {
|
for (int i = 0; i < enemies.count; i++)
|
||||||
enemies.sprite[i] = (Sprite){
|
{
|
||||||
.texture = texture,
|
enemies.sprite[i] = (Sprite){
|
||||||
.frameSize = {frameWidth, frameWidth},
|
.texture = texture,
|
||||||
.sourceRec = {0.0f, 0.0f, frameWidth, frameWidth},
|
.frameSize = {frameWidth, frameWidth},
|
||||||
.destRec = {GetScreenWidth() / 2, 0.0f, frameWidth, frameWidth},
|
.sourceRec = {0.0f, 0.0f, frameWidth, frameWidth},
|
||||||
.origin = {frameWidth / 2, frameWidth / 2},
|
.destRec = {GetScreenWidth()/2, 0.0f, frameWidth, frameWidth},
|
||||||
.rotation = rotation,
|
.origin = {frameWidth / 2, frameWidth / 2},
|
||||||
.color = WHITE};
|
.rotation = rotation,
|
||||||
|
.color = WHITE
|
||||||
|
};
|
||||||
|
|
||||||
enemies.animation[i] = (Animation){.state = 1,
|
enemies.animation[i] = (Animation){
|
||||||
.currentFrame = 0,
|
.state = 1,
|
||||||
.maxFrame = 2,
|
.currentFrame = 0,
|
||||||
.framesCounter = 0,
|
.maxFrame = 2,
|
||||||
.framesSpeed = 2.0f,
|
.framesCounter = 0,
|
||||||
.animTimer = 0.0f};
|
.framesSpeed = 2.0f,
|
||||||
|
.animTimer = 0.0f
|
||||||
|
};
|
||||||
|
|
||||||
Rectangle cameraRec = GetCameraRectangle();
|
Rectangle cameraRec = GetCameraRectangle();
|
||||||
|
|
||||||
enemies.physics[i] =
|
enemies.physics[i] = (Physics){
|
||||||
(Physics){.position = GetPositionOutsideRectangle(cameraRec, 100, 1000),
|
.position = GetPositionOutsideRectangle(cameraRec, 100, 1000),
|
||||||
.direction = (Vector2){0.0f, 0.0f},
|
.direction = (Vector2){0.0f, 0.0f},
|
||||||
.speed = 5.0f};
|
.speed = 5.0f,
|
||||||
|
.weight = 5.0f
|
||||||
|
};
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
enemies.arrived[i] = true;
|
enemies.arrived[i] = true;
|
||||||
enemies.destPos[i] = (Vector2){0.0f, 0.0f};
|
enemies.destPos[i] = (Vector2){0.0f, 0.0f};
|
||||||
enemies.alive[i] = true;
|
enemies.alive[i] = true;
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
enemies.arrived[i] = true;
|
||||||
|
enemies.destPos[i] = (Vector2){0.0f, 0.0f};
|
||||||
|
>>>>>>> origin/pirate
|
||||||
|
|
||||||
return enemies;
|
}
|
||||||
|
|
||||||
|
return enemies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
void UpdateEnemies(Enemies *enemies, Projectiles *projectiles) {
|
void UpdateEnemies(Enemies *enemies, Projectiles *projectiles) {
|
||||||
Camera2D *camera = GetCamera();
|
Camera2D *camera = GetCamera();
|
||||||
Rectangle cameraRec = GetCameraRectangle();
|
Rectangle cameraRec = GetCameraRectangle();
|
||||||
@@ -91,4 +106,43 @@ void RenderEnemies(Enemies *enemies) {
|
|||||||
RenderSprite(&enemies->sprite[i]);
|
RenderSprite(&enemies->sprite[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
void UpdateEnemies(Enemies *enemies){
|
||||||
|
Camera2D *camera = GetCamera();
|
||||||
|
Rectangle cameraRec = GetCameraRectangle();
|
||||||
|
|
||||||
|
for (int i = 0; i < enemies->count; i++)
|
||||||
|
{
|
||||||
|
if(enemies->arrived[i])
|
||||||
|
{
|
||||||
|
enemies->destPos[i] = GetPositionOutsideRectangle(cameraRec, 100, 1000);
|
||||||
|
enemies->arrived[i] = false;
|
||||||
|
}
|
||||||
|
if(CheckCollisionPointCircle(enemies->physics[i].position, enemies->destPos[i], 10.0F))
|
||||||
|
{
|
||||||
|
enemies->arrived[i] = true;
|
||||||
|
}
|
||||||
|
if(GetDistanceBetweenTwoVectors(enemies->physics[i].position, camera->target) > 1000){
|
||||||
|
enemies->physics[i].position = GetPositionOutsideRectangle(cameraRec, 100, 1000);
|
||||||
|
}
|
||||||
|
Vector2 dir = GetDirectionBetweenTwoVectors(enemies->physics[i].position, enemies->destPos[i]);
|
||||||
|
UpdatePhysics(&enemies->physics[i], dir);
|
||||||
|
UpdateSpriteDestRec(&enemies->sprite[i], &enemies->physics[i].position);
|
||||||
|
float rotation = Vector2ToRotation(dir);
|
||||||
|
UpdateSpriteRotation(&enemies->sprite[i], rotation + 90.0f);
|
||||||
|
UpdateAnimation(&enemies->animation[i], GetFrameTime());
|
||||||
|
UpdateSpriteSourceRec(&enemies->sprite[i], &(Vector2){enemies->sprite[i].frameSize.x * enemies->animation[i].currentFrame, enemies->sprite[i].frameSize.y});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderEnemies(Enemies *enemies){
|
||||||
|
|
||||||
|
for (int i = 0; i < enemies->count; i++)
|
||||||
|
{
|
||||||
|
RenderSprite(&enemies->sprite[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
>>>>>>> origin/pirate
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#include "app.h"
|
||||||
|
#include "raylib.h"
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
void RenderOverlay(Mouse *mouse) {
|
||||||
|
|
||||||
|
// Health
|
||||||
|
Player *player = GetPlayer();
|
||||||
|
const char *text = TextFormat("Health: %i\n"
|
||||||
|
"Gold: %i\n",
|
||||||
|
player->health, player->gold);
|
||||||
|
DrawText(text, 0, 0, 25, WHITE);
|
||||||
|
|
||||||
|
// Mouse
|
||||||
|
Rectangle mouseRectangle = (Rectangle){0, 0, mouse->cursorTexture.width,
|
||||||
|
mouse->cursorTexture.height};
|
||||||
|
DrawTextureRec(mouse->cursorTexture, mouseRectangle, mouse->screenPosition,
|
||||||
|
WHITE);
|
||||||
|
}
|
||||||
+98
-48
@@ -1,4 +1,5 @@
|
|||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
#include "engine.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FLAPPING,
|
FLAPPING,
|
||||||
@@ -10,30 +11,27 @@ const SoundAsset playerSoundAssets[SOUND_COUNT] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const TextureAsset playerTextureAssets[PLAYER_TEX_COUNT] = {
|
const TextureAsset playerTextureAssets[PLAYER_TEX_COUNT] = {
|
||||||
{"assets/ship_start.png", 16.0f, 16.0f, 0.0f}
|
{"assets/ship_start.png", 16.0f, 16.0f, 0.0f}};
|
||||||
};
|
|
||||||
|
|
||||||
float playerSpeeds[SPEED_COUNT] = {
|
float playerSpeeds[SPEED_COUNT] = {0.0f, 5.0f, 10.0f};
|
||||||
0.0f,
|
|
||||||
5.0f,
|
Config config;
|
||||||
10.0f
|
|
||||||
};
|
|
||||||
|
|
||||||
playerSpeedID GetPlayerSpeedID(float speed) {
|
playerSpeedID GetPlayerSpeedID(float speed) {
|
||||||
for (int i = 0; i < SPEED_COUNT; i++) {
|
for (int i = 0; i < SPEED_COUNT; i++) {
|
||||||
if (playerSpeeds[i] == speed) {
|
if (playerSpeeds[i] == speed) {
|
||||||
return (playerSpeedID)i;
|
return (playerSpeedID)i;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ANCHOR;
|
}
|
||||||
|
return ANCHOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* GetPlayer(void)
|
Player *GetPlayer(void) {
|
||||||
{
|
static Player player;
|
||||||
static Player player;
|
return &player;
|
||||||
return &player;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
void CreatePlayer(void)
|
void CreatePlayer(void)
|
||||||
{
|
{
|
||||||
TextureAsset startShipAsset = playerTextureAssets[START_SHIP];
|
TextureAsset startShipAsset = playerTextureAssets[START_SHIP];
|
||||||
@@ -51,16 +49,17 @@ void CreatePlayer(void)
|
|||||||
.rotation = rotation,
|
.rotation = rotation,
|
||||||
.color = WHITE
|
.color = WHITE
|
||||||
};
|
};
|
||||||
|
=======
|
||||||
|
void CreatePlayer(void) {
|
||||||
|
|
||||||
Animation playerAnimation = {
|
InitConfig(&config, "config/player.ini");
|
||||||
.state = 1,
|
int PLAYER_HEALTH_MAX = GetConfigInt(&config, "HEALTH_MAX");
|
||||||
.currentFrame = 0,
|
int START_GOLD = GetConfigInt(&config, "START_GOLD");
|
||||||
.maxFrame = 3,
|
>>>>>>> origin/pirate
|
||||||
.framesCounter = 0,
|
|
||||||
.framesSpeed = 0.0f,
|
|
||||||
.animTimer = 0.0f
|
|
||||||
};
|
|
||||||
|
|
||||||
|
TextureAsset startShipAsset = playerTextureAssets[START_SHIP];
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
Physics playerPhysics = {
|
Physics playerPhysics = {
|
||||||
.position = (Vector2){(float)LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSX), (float)LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSY)},
|
.position = (Vector2){(float)LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSX), (float)LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSY)},
|
||||||
.direction = (Vector2){0.0f, 0.0f},
|
.direction = (Vector2){0.0f, 0.0f},
|
||||||
@@ -95,35 +94,83 @@ void UpdatePlayer(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
Texture2D texture = LoadTexture(startShipAsset.path);
|
||||||
|
float frameWidth = startShipAsset.frameWidth;
|
||||||
|
float rotation = startShipAsset.rotation;
|
||||||
|
|
||||||
if(IsKeyPressed(KEY_S) || IsKeyPressed(KEY_DOWN)){
|
Sprite playerSprite = {.texture = texture,
|
||||||
if(player->physics.speed > playerSpeeds[ANCHOR]){
|
.frameSize = {frameWidth, frameWidth},
|
||||||
if(player->physics.speed > playerSpeeds[SLOW_AHEAD]){
|
.sourceRec = {0.0f, 0.0f, frameWidth, frameWidth},
|
||||||
player->physics.speed = playerSpeeds[SLOW_AHEAD];
|
.destRec = {0.0f, 0.0f, frameWidth, frameWidth},
|
||||||
}
|
.origin = {frameWidth / 2, frameWidth / 2},
|
||||||
else {
|
.rotation = rotation,
|
||||||
player->physics.speed = playerSpeeds[ANCHOR];
|
.color = WHITE};
|
||||||
|
|
||||||
}
|
Animation playerAnimation = {.state = 1,
|
||||||
}
|
.currentFrame = 0,
|
||||||
}
|
.maxFrame = 3,
|
||||||
|
.framesCounter = 0,
|
||||||
|
.framesSpeed = 0.0f,
|
||||||
|
.animTimer = 0.0f};
|
||||||
|
|
||||||
player->sprite.sourceRec.x = 16.0f * GetPlayerSpeedID(player->physics.speed);
|
Physics playerPhysics = {.position = (Vector2){0.0f, 0.0f},
|
||||||
|
.direction = (Vector2){0.0f, 0.0f},
|
||||||
|
.speed = playerSpeeds[ANCHOR],
|
||||||
|
.weight = 10.0f};
|
||||||
|
|
||||||
|
Player *player = GetPlayer();
|
||||||
|
*player = (Player){.sprite = playerSprite,
|
||||||
|
.animation = playerAnimation,
|
||||||
|
.physics = playerPhysics,
|
||||||
|
.rotation = rotation,
|
||||||
|
.health = PLAYER_HEALTH_MAX,
|
||||||
|
.gold = START_GOLD};
|
||||||
|
}
|
||||||
|
|
||||||
float rotationSpeed = 50.0f;
|
void UpdatePlayer(void) {
|
||||||
|
Player *player = GetPlayer();
|
||||||
|
if (IsKeyPressed(KEY_W) || IsKeyPressed(KEY_UP)) {
|
||||||
|
if (player->physics.speed < playerSpeeds[FAST_AHEAD]) {
|
||||||
|
if (player->physics.speed < playerSpeeds[SLOW_AHEAD]) {
|
||||||
|
player->physics.speed = playerSpeeds[SLOW_AHEAD];
|
||||||
|
} else {
|
||||||
|
player->physics.speed = playerSpeeds[FAST_AHEAD];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>>>>>>> origin/pirate
|
||||||
|
|
||||||
if (player->physics.speed > playerSpeeds[ANCHOR]){
|
if (IsKeyPressed(KEY_S) || IsKeyPressed(KEY_DOWN)) {
|
||||||
|
if (player->physics.speed > playerSpeeds[ANCHOR]) {
|
||||||
|
if (player->physics.speed > playerSpeeds[SLOW_AHEAD]) {
|
||||||
|
player->physics.speed = playerSpeeds[SLOW_AHEAD];
|
||||||
|
} else {
|
||||||
|
player->physics.speed = playerSpeeds[ANCHOR];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT)) {
|
player->sprite.sourceRec.x = 16.0f * GetPlayerSpeedID(player->physics.speed);
|
||||||
player->rotation -= rotationSpeed * GetFrameTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT)) {
|
float rotationSpeed = 50.0f;
|
||||||
player->rotation += rotationSpeed * GetFrameTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (player->physics.speed > playerSpeeds[ANCHOR]) {
|
||||||
|
|
||||||
|
if (IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT)) {
|
||||||
|
player->rotation -= rotationSpeed * GetFrameTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT)) {
|
||||||
|
player->rotation += rotationSpeed * GetFrameTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player->sprite.rotation = player->rotation;
|
||||||
|
|
||||||
|
Vector2 dir = RotationToVector2(player->rotation - 90.0f);
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
player->sprite.rotation = player->rotation;
|
player->sprite.rotation = player->rotation;
|
||||||
Vector2 dir = RotationToVector2(player->rotation - 90.0f);
|
Vector2 dir = RotationToVector2(player->rotation - 90.0f);
|
||||||
UpdatePhysics(&player->physics, dir);
|
UpdatePhysics(&player->physics, dir);
|
||||||
@@ -131,10 +178,13 @@ void UpdatePlayer(void)
|
|||||||
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSX, (int)player->physics.position.x);
|
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSX, (int)player->physics.position.x);
|
||||||
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSY, (int)player->physics.position.y);
|
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSY, (int)player->physics.position.y);
|
||||||
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_ROTATION, (int)player->rotation);
|
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_ROTATION, (int)player->rotation);
|
||||||
|
=======
|
||||||
|
UpdatePhysics(&player->physics, dir);
|
||||||
|
UpdateSpriteDestRec(&player->sprite, &player->physics.position);
|
||||||
|
>>>>>>> origin/pirate
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPlayer(void){
|
void RenderPlayer(void) {
|
||||||
Player* player = GetPlayer();
|
Player *player = GetPlayer();
|
||||||
RenderSprite(&player->sprite);
|
RenderSprite(&player->sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
-18
@@ -2,16 +2,10 @@
|
|||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <raymath.h>
|
#include <raymath.h>
|
||||||
|
|
||||||
typedef enum {
|
typedef enum { CANNONBALL_SHOOTING, CANNONBALL_IMPACT, SOUND_COUNT } SoundID;
|
||||||
CANNONBALL_SHOOTING,
|
|
||||||
CANNONBALL_IMPACT,
|
|
||||||
SOUND_COUNT
|
|
||||||
} SoundID;
|
|
||||||
|
|
||||||
const SoundAsset soundAssets[SOUND_COUNT] = {
|
const SoundAsset soundAssets[SOUND_COUNT] = {{"assets/cannonball_shooting.mp3"},
|
||||||
{"assets/cannonball_shooting.mp3"},
|
{"assets/cannonball_impact.mp3"}};
|
||||||
{"assets/cannonball_impact.mp3"}
|
|
||||||
};
|
|
||||||
|
|
||||||
Projectiles CreateProjectiles(void) {
|
Projectiles CreateProjectiles(void) {
|
||||||
Projectiles projectiles = {.count = MAX_PROJECTILES};
|
Projectiles projectiles = {.count = MAX_PROJECTILES};
|
||||||
@@ -23,7 +17,8 @@ Projectiles CreateProjectiles(void) {
|
|||||||
projectiles.radius[i] = 1.0f;
|
projectiles.radius[i] = 1.0f;
|
||||||
projectiles.active[i] = false;
|
projectiles.active[i] = false;
|
||||||
projectiles.color[i] = GRAY;
|
projectiles.color[i] = GRAY;
|
||||||
projectiles.soundShooting[i] = LoadSound(soundAssets[CANNONBALL_SHOOTING].path);
|
projectiles.soundShooting[i] =
|
||||||
|
LoadSound(soundAssets[CANNONBALL_SHOOTING].path);
|
||||||
projectiles.soundImpact[i] = LoadSound(soundAssets[CANNONBALL_IMPACT].path);
|
projectiles.soundImpact[i] = LoadSound(soundAssets[CANNONBALL_IMPACT].path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +47,7 @@ void UpdateProjectiles(Projectiles *projectiles, Enemies *enemies) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyDown(KEY_E) && (currentTime - lastShotTime >= reloadTime)) {
|
if (IsKeyDown(KEY_E) && (currentTime - lastShotTime >= reloadTime)) {
|
||||||
for (int i = 0; i < projectiles->count; i++){
|
for (int i = 0; i < projectiles->count; i++) {
|
||||||
if (!projectiles->active[i]) {
|
if (!projectiles->active[i]) {
|
||||||
projectiles->active[i] = true;
|
projectiles->active[i] = true;
|
||||||
Player *player = GetPlayer();
|
Player *player = GetPlayer();
|
||||||
@@ -68,26 +63,29 @@ void UpdateProjectiles(Projectiles *projectiles, Enemies *enemies) {
|
|||||||
|
|
||||||
for (int i = 0; i < projectiles->count; i++) {
|
for (int i = 0; i < projectiles->count; i++) {
|
||||||
|
|
||||||
if (!projectiles->active[i]) continue;
|
if (!projectiles->active[i])
|
||||||
|
continue;
|
||||||
|
|
||||||
for (int j = 0; j < enemies->count; j++){
|
for (int j = 0; j < enemies->count; j++) {
|
||||||
if (CheckCollisionCircleRec(projectiles->physics[i].position, projectiles->radius[i], enemies->sprite[j].destRec)){
|
if (CheckCollisionCircleRec(projectiles->physics[i].position,
|
||||||
|
projectiles->radius[i],
|
||||||
|
enemies->sprite[j].destRec)) {
|
||||||
PlaySound(projectiles->soundImpact[i]);
|
PlaySound(projectiles->soundImpact[i]);
|
||||||
Player *player = GetPlayer();
|
Player *player = GetPlayer();
|
||||||
player->gold += 1;
|
player->gold += 1;
|
||||||
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_GOLD, player->gold);
|
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_GOLD,
|
||||||
|
player->gold);
|
||||||
projectiles->active[i] = false;
|
projectiles->active[i] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdatePhysics(&projectiles->physics[i],
|
UpdatePhysics(&projectiles->physics[i], projectiles->physics[i].direction);
|
||||||
projectiles->physics[i].direction);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderProjectiles(Projectiles *projectiles) {
|
void RenderProjectiles(Projectiles *projectiles) {
|
||||||
for (int i = 0; i < projectiles->count; i++) {
|
for (int i = 0; i < projectiles->count; i++) {
|
||||||
if (projectiles->active[i]) {
|
if (projectiles->active[i] == true) {
|
||||||
DrawCircle(projectiles->physics[i].position.x,
|
DrawCircle(projectiles->physics[i].position.x,
|
||||||
projectiles->physics[i].position.y, projectiles->radius[i],
|
projectiles->physics[i].position.y, projectiles->radius[i],
|
||||||
projectiles->color[i]);
|
projectiles->color[i]);
|
||||||
|
|||||||
+15
-16
@@ -1,27 +1,26 @@
|
|||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
bool IsVectorZero(Vector2 v) {
|
bool IsVectorZero(Vector2 v) {
|
||||||
float epsilon = 0.01f;
|
float epsilon = 0.01f;
|
||||||
return (fabs(v.x) < epsilon && fabs(v.y) < epsilon);
|
return (fabs(v.x) < epsilon && fabs(v.y) < epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 GetRandomVector(const Rectangle bounds) {
|
Vector2 GetRandomVector(const Rectangle bounds) {
|
||||||
return (Vector2){
|
return (Vector2){
|
||||||
bounds.x + (float)GetRandomValue(0, 10000) / 10000.0f * bounds.width,
|
bounds.x + (float)GetRandomValue(0, 10000) / 10000.0f * bounds.width,
|
||||||
bounds.y + (float)GetRandomValue(0, 10000) / 10000.0f * bounds.height
|
bounds.y + (float)GetRandomValue(0, 10000) / 10000.0f * bounds.height};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 RotationToVector2(float rotation)
|
Vector2 RotationToVector2(float rotation) {
|
||||||
{
|
float rad = rotation * (PI / 180.0f);
|
||||||
float rad = rotation * (PI / 180.0f);
|
Vector2 vec = {cosf(rad), sinf(rad)};
|
||||||
Vector2 vec = { cosf(rad), sinf(rad) };
|
return vec;
|
||||||
return vec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Vector2ToRotation(Vector2 vec)
|
float Vector2ToRotation(Vector2 vec) {
|
||||||
{
|
float rad = atan2f(vec.y, vec.x);
|
||||||
float rad = atan2f(vec.y, vec.x);
|
float deg = rad * (180.0f / PI);
|
||||||
float deg = rad * (180.0f / PI);
|
return deg;
|
||||||
return deg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Cross2D(Vector2 a, Vector2 b) { return a.x * b.y - a.y * b.x; }
|
||||||
|
|||||||
Reference in New Issue
Block a user