update to use SPACE🪐BOX default GL context

This commit is contained in:
ohsqueezy 2024-03-04 20:10:48 -05:00
parent 5fd6f5545c
commit 341bb50bef
8 changed files with 139 additions and 116 deletions

12
.gitignore vendored
View File

@ -1,8 +1,6 @@
# Compilation
*.o
*.data
*.wasm
# Builds
build/
dist/
# Auto complete
compile_commands.json
@ -10,12 +8,6 @@ compile_commands.json
# SPACEBOX
BPmono.ttf
# Builds
*.x86_64
cakefoot.js
cakefoot_debug.html
cakefoot_debug.js
# Repository
local/
src/__pycache__/

140
Makefile
View File

@ -1,8 +1,10 @@
# Cakefoot by @ohsqueezy <https://ohsqueezy.itch.io>
# Cakefoot [https://cakefoot.dank.game]
#
# This Makefile can be used to create a Linux or web build. The Android rules are currently outdated.
# This Makefile can be used to create a Linux or web build.
#
# The [SPACEBOX] game framework source code from <https://open.shampoo.ooo/shampoo/spacebox> is required.
# NOTE: The Android rules are currently outdated.
#
# The SPACE🪐BOX game framework source code from <https://open.shampoo.ooo/shampoo/spacebox> is required.
#########
# Paths #
@ -53,8 +55,8 @@ WASM_DEBUG_BUILD_DIR := $(BUILD_ROOT)/wasm_debug
WASM_COOLMATH_BUILD_DIR := $(BUILD_ROOT)/wasm_coolmath
WINDOWS_BUILD_DIR := $(BUILD_ROOT)/win32
ARCADE_BUILD_DIR := $(BUILD_ROOT)/win32_arcade
BUILD_DIRS := $(X86_64_BUILD_DIR) $(X86_64_DEBUG_BUILD_DIR) $(WASM_BUILD_DIR) $(WASM_DEBUG_BUILD_DIR) $(WASM_COOLMATH_BUILD_DIR) $(WINDOWS_BUILD_DIR) \
$(ARCADE_BUILD_DIR)
BUILD_DIRS := $(X86_64_BUILD_DIR) $(X86_64_DEBUG_BUILD_DIR) $(WASM_BUILD_DIR) $(WASM_DEBUG_BUILD_DIR) $(WASM_COOLMATH_BUILD_DIR) \
$(WINDOWS_BUILD_DIR) $(ARCADE_BUILD_DIR)
$(BUILD_DIRS):
mkdir -p $@
@ -78,37 +80,39 @@ $(addsuffix /SDL2_rotozoom.o, $(BUILD_DIRS)): $(SDLGFX2_DIR)/SDL2_rotozoom.c $(w
$(addsuffix /glew.o, $(BUILD_DIRS)): $(GLEW_DIR)/glew.c $(wildcard $(GLEW_DIR)/*.h) | $(BUILD_DIRS)
$(CC) $< $(CFLAGS) -c -o $@
$(addsuffix /extension.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, extension.cpp extension.hpp Box.hpp Segment.hpp Color.hpp filesystem.hpp Pixels.hpp Log.hpp) \
| $(BUILD_DIRS)
$(addsuffix /extension.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, extension.cpp extension.hpp Box.hpp Segment.hpp Color.hpp \
filesystem.hpp Pixels.hpp Log.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Node.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Node.cpp Node.hpp Game.hpp Configuration.hpp Delegate.hpp Display.hpp Input.hpp Box.hpp Audio.hpp \
Log.hpp) | $(BUILD_DIRS)
$(addsuffix /Node.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Node.cpp Node.hpp Game.hpp Configuration.hpp Delegate.hpp \
Display.hpp Input.hpp Box.hpp Audio.hpp Log.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Game.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Game.cpp Game.hpp extension.hpp Node.hpp Recorder.hpp Input.hpp Configuration.hpp Delegate.hpp \
Audio.hpp Log.hpp) | $(BUILD_DIRS)
$(addsuffix /Game.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Game.cpp Game.hpp extension.hpp Node.hpp Recorder.hpp Input.hpp \
Configuration.hpp Delegate.hpp Audio.hpp Log.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Animation.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Animation.cpp Animation.hpp Node.hpp Timer.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Recorder.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Recorder.cpp Recorder.hpp Node.hpp Game.hpp Configuration.hpp Delegate.hpp Animation.hpp \
extension.hpp) | $(BUILD_DIRS)
$(addsuffix /Recorder.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Recorder.cpp Recorder.hpp Node.hpp Game.hpp Configuration.hpp \
Delegate.hpp Animation.hpp extension.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Input.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Input.cpp Input.hpp Node.hpp Animation.hpp Configuration.hpp Delegate.hpp) | $(BUILD_DIRS)
$(addsuffix /Input.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Input.cpp Input.hpp Node.hpp Animation.hpp Configuration.hpp \
Delegate.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Configuration.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Configuration.cpp Configuration.hpp Node.hpp Animation.hpp Log.hpp extension.hpp) \
| $(BUILD_DIRS)
$(addsuffix /Configuration.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Configuration.cpp Configuration.hpp Node.hpp Animation.hpp \
Log.hpp extension.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Delegate.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Delegate.cpp Delegate.hpp Node.hpp Game.hpp Input.hpp) | $(BUILD_DIRS)
$(addsuffix /Delegate.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Delegate.cpp Delegate.hpp Node.hpp Game.hpp Input.hpp) \
| $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Display.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Display.cpp Display.hpp Node.hpp Game.hpp Box.hpp Configuration.hpp Delegate.hpp Log.hpp) \
| $(BUILD_DIRS)
$(addsuffix /Display.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Display.cpp Display.hpp Node.hpp Game.hpp Box.hpp \
Configuration.hpp Delegate.hpp Log.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Box.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Box.cpp Box.hpp extension.hpp Segment.hpp) | $(BUILD_DIRS)
@ -117,7 +121,8 @@ $(addsuffix /Box.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Box.cpp Box.hpp
$(addsuffix /Segment.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Segment.cpp Segment.hpp extension.hpp Box.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Pixels.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Pixels.cpp Pixels.hpp Box.hpp extension.hpp Log.hpp math.hpp) | $(BUILD_DIRS)
$(addsuffix /Pixels.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Pixels.cpp Pixels.hpp Box.hpp extension.hpp Log.hpp math.hpp) \
| $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Audio.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Audio.cpp Audio.hpp Node.hpp filesystem.hpp) | $(BUILD_DIRS)
@ -126,19 +131,24 @@ $(addsuffix /Audio.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Audio.cpp Audi
$(addsuffix /GLObject.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, GLObject.cpp GLObject.hpp Log.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Texture.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Texture.cpp Texture.hpp GLObject.hpp filesystem.hpp Log.hpp) | $(BUILD_DIRS)
$(addsuffix /Texture.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Texture.cpp Texture.hpp GLObject.hpp filesystem.hpp Log.hpp) \
| $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /VBO.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, VBO.cpp VBO.hpp Log.hpp GLObject.hpp Attributes.hpp extension.hpp) | $(BUILD_DIRS)
$(addsuffix /VBO.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, VBO.cpp VBO.hpp Log.hpp GLObject.hpp Attributes.hpp extension.hpp) \
| $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Attributes.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Attributes.cpp Attributes.hpp Log.hpp extension.hpp) | $(BUILD_DIRS)
$(addsuffix /Attributes.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Attributes.cpp Attributes.hpp Log.hpp extension.hpp) \
| $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Model.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Model.cpp Model.hpp extension.hpp Attributes.hpp Texture.hpp Carousel.hpp) | $(BUILD_DIRS)
$(addsuffix /Model.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Model.cpp Model.hpp extension.hpp Attributes.hpp Texture.hpp \
Carousel.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Text.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Text.cpp Text.hpp Model.hpp Color.hpp Log.hpp Texture.hpp) | $(BUILD_DIRS)
$(addsuffix /Text.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Text.cpp Text.hpp Model.hpp Color.hpp Log.hpp Texture.hpp) \
| $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Color.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Color.cpp Color.hpp) | $(BUILD_DIRS)
@ -153,16 +163,17 @@ $(addsuffix /math.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, math.cpp math.h
$(addsuffix /Timer.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Timer.cpp Timer.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Curve.o, $(BUILD_DIRS)): $(addprefix $(SRC_DIR)/, Curve.cpp Curve.hpp) $(addprefix $(SB_SRC_DIR)/, Attributes.hpp math.hpp extension.hpp) \
| $(BUILD_DIRS)
$(addsuffix /Curve.o, $(BUILD_DIRS)): $(addprefix $(SRC_DIR)/, Curve.cpp Curve.hpp) $(addprefix $(SB_SRC_DIR)/, Attributes.hpp \
math.hpp extension.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Character.o, $(BUILD_DIRS)): $(addprefix $(SRC_DIR)/, Character.cpp Character.hpp Curve.hpp) $(addprefix $(SB_SRC_DIR)/, Configuration.hpp Switch.hpp\
Selection.hpp Segment.hpp Timer.hpp Sprite.hpp) | $(BUILD_DIRS)
$(addsuffix /Character.o, $(BUILD_DIRS)): $(addprefix $(SRC_DIR)/, Character.cpp Character.hpp Curve.hpp) \
$(addprefix $(SB_SRC_DIR)/, Configuration.hpp Switch.hpp Selection.hpp Segment.hpp Timer.hpp Sprite.hpp) \
| $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Enemy.o, $(BUILD_DIRS)): $(addprefix $(SRC_DIR)/, Enemy.cpp Enemy.hpp Curve.hpp Character.hpp) $(addprefix $(SB_SRC_DIR)/, Timer.hpp Animation.hpp \
Box.hpp Sprite.hpp) | $(BUILD_DIRS)
$(addsuffix /Enemy.o, $(BUILD_DIRS)): $(addprefix $(SRC_DIR)/, Enemy.cpp Enemy.hpp Curve.hpp Character.hpp) \
$(addprefix $(SB_SRC_DIR)/, Timer.hpp Animation.hpp Box.hpp Sprite.hpp) | $(BUILD_DIRS)
$(CXX) $(CXXFLAGS) $< -c -o $@
$(addsuffix /Cakefoot.o, $(BUILD_DIRS)): $(SRC_DIR)/Cakefoot.cpp $(SRC_H_FILES) $(SB_H_FILES) | $(BUILD_DIRS)
@ -197,39 +208,41 @@ Cakefoot-linux_debug.x86_64 : $(LINUX_DEBUG_OBJ)
# Use Emscripten to output JavaScript
EMSCRIPTENHOME = $(HOME)/ext/software/emsdk/upstream/emscripten
EMSCRIPTEN_CFLAGS = -Oz -Wall -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS="['png', 'jpg']" -s USE_SDL_TTF=2 -s USE_SDL_MIXER=2 \
-I $(SB_LIB_DIR) -I $(SB_SRC_DIR)
EMSCRIPTEN_CFLAGS = -Oz -Wall -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS="['png', 'jpg']" -s USE_SDL_TTF=2 \
-s USE_SDL_MIXER=2 -I $(SB_LIB_DIR) -I $(SB_SRC_DIR)
EMSCRIPTEN_LFLAGS = -s MIN_WEBGL_VERSION=2 -s EXPORTED_FUNCTIONS="['_main', '_malloc', '_pause_for_ads', '_unpause_for_ads']" \
-s LLD_REPORT_UNDEFINED -s NO_DISABLE_EXCEPTION_CATCHING -s FULL_ES3=1 -lidbfs.js -s ALLOW_MEMORY_GROWTH=1
EMSCRIPTEN_PRELOADS = --preload-file "config.json" --preload-file "resource/" --preload-file "src/shaders/" --preload-file "src/config_wasm.json" \
--pre-js "src/pre_js.js"
EMSCRIPTEN_PRELOADS = --preload-file "config.json" --preload-file "resource/" --preload-file "src/shaders/" \
--preload-file "src/config_wasm.json" --pre-js "src/pre_js.js"
EMSCRIPTEN_GAME_CONFIGS = config.json src/config_wasm.json resource/levels.json
cakefoot.js : CC = $(EMSCRIPTENHOME)/emcc
cakefoot.js : CXX = $(EMSCRIPTENHOME)/em++
cakefoot.js : CFLAGS = $(EMSCRIPTEN_CFLAGS)
cakefoot.js : CXXFLAGS = $(CFLAGS) --std=c++17
cakefoot.js : $(addprefix $(WASM_BUILD_DIR)/, SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) $(SRC_O_FILES)) $(EMSCRIPTEN_GAME_CONFIGS)
$(CXX) $(filter-out $(EMSCRIPTEN_GAME_CONFIGS), $^) $(CXXFLAGS) $(EMSCRIPTEN_LFLAGS) $(EMSCRIPTEN_PRELOADS) --pre-js "src/pre_js_foam.js" \
-o $(WASM_BUILD_DIR)/$@
cakefoot.js : $(addprefix $(WASM_BUILD_DIR)/, SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) $(SRC_O_FILES)) \
$(EMSCRIPTEN_GAME_CONFIGS)
$(CXX) $(filter-out $(EMSCRIPTEN_GAME_CONFIGS), $^) $(CXXFLAGS) $(EMSCRIPTEN_LFLAGS) $(EMSCRIPTEN_PRELOADS) \
--pre-js "src/pre_js_foam.js" -o $(WASM_BUILD_DIR)/$@
cakefoot_debug.html : CC = $(EMSCRIPTENHOME)/emcc
cakefoot_debug.html : CXX = $(EMSCRIPTENHOME)/em++
cakefoot_debug.html : CFLAGS = $(EMSCRIPTEN_CFLAGS) -g2
cakefoot_debug.html : CXXFLAGS = $(CFLAGS) --std=c++17
cakefoot_debug.html : $(addprefix $(WASM_DEBUG_BUILD_DIR)/, SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) $(SRC_O_FILES)) $(EMSCRIPTEN_GAME_CONFIGS)
$(CXX) $(filter-out $(EMSCRIPTEN_GAME_CONFIGS), $^) $(CXXFLAGS) $(EMSCRIPTEN_LFLAGS) $(EMSCRIPTEN_PRELOADS) --memoryprofiler --cpuprofiler -o \
$(WASM_DEBUG_BUILD_DIR)/$@
cakefoot_debug.html : $(addprefix $(WASM_DEBUG_BUILD_DIR)/, SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) $(SRC_O_FILES)) \
$(EMSCRIPTEN_GAME_CONFIGS)
$(CXX) $(filter-out $(EMSCRIPTEN_GAME_CONFIGS), $^) $(CXXFLAGS) $(EMSCRIPTEN_LFLAGS) $(EMSCRIPTEN_PRELOADS) --memoryprofiler \
--cpuprofiler -o $(WASM_DEBUG_BUILD_DIR)/$@
cakefoot_coolmath.js : CC = $(EMSCRIPTENHOME)/emcc
cakefoot_coolmath.js : CXX = $(EMSCRIPTENHOME)/em++
cakefoot_coolmath.js : CFLAGS = $(EMSCRIPTEN_CFLAGS) -D__COOLMATH__
cakefoot_coolmath.js : CXXFLAGS = $(CFLAGS) --std=c++17
cakefoot_coolmath.js : EMSCRIPTEN_GAME_CONFIGS += src/config_coolmath.json
cakefoot_coolmath.js : $(addprefix $(WASM_COOLMATH_BUILD_DIR)/, SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) $(SRC_O_FILES)) $(EMSCRIPTEN_GAME_CONFIGS) \
src/index_coolmath.html
$(CXX) $(filter-out $(EMSCRIPTEN_GAME_CONFIGS) src/index_coolmath.html, $^) $(CXXFLAGS) $(EMSCRIPTEN_LFLAGS) -D__COOLMATH__ $(EMSCRIPTEN_PRELOADS) \
--preload-file "src/config_coolmath.json" -o $(WASM_COOLMATH_BUILD_DIR)/$@
cakefoot_coolmath.js : $(addprefix $(WASM_COOLMATH_BUILD_DIR)/, SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) $(SRC_O_FILES)) \
$(EMSCRIPTEN_GAME_CONFIGS) src/index_coolmath.html
$(CXX) $(filter-out $(EMSCRIPTEN_GAME_CONFIGS) src/index_coolmath.html, $^) $(CXXFLAGS) $(EMSCRIPTEN_LFLAGS) \
-D__COOLMATH__ $(EMSCRIPTEN_PRELOADS) --preload-file "src/config_coolmath.json" -o $(WASM_COOLMATH_BUILD_DIR)/$@
cp src/index_coolmath.html $(WASM_COOLMATH_BUILD_DIR)/index.html
cd $(WASM_COOLMATH_BUILD_DIR) && \
zip -r Cakefoot_coolmath.zip cakefoot_coolmath.data cakefoot_coolmath.js cakefoot_coolmath.wasm index.html && \
@ -239,9 +252,9 @@ cakefoot_coolmath.js : $(addprefix $(WASM_COOLMATH_BUILD_DIR)/, SDL2_rotozoom.o
# Android build #
#################
# Detailed info on how this build target was originally created for the fill_screen demo is in README.md at the root of the repository. It
# requires the Android SDK and the source packages for SDL. The paths below should be edited to match the local system. Icon creation requires
# Imagemagick's convert tool from <https://imagemagick.org/>.
# Detailed info on how this build target was originally created for the fill_screen demo is in README.md at the root of the
# repository. It requires the Android SDK and the source packages for SDL. The paths below should be edited to match the local
# system. Icon creation requires Imagemagick's convert tool from <https://imagemagick.org/>.
SDL_SRC := $(HOME)/ext/software/SDL2-2.26.3
SDL_IMAGE_SRC := $(HOME)/ext/software/SDL2_image-2.6.2-android
@ -257,8 +270,9 @@ ANDROID_BUILD_DIR := build/android/$(ANDROID_PACKAGE)
ANDROID_CLASS := Cakefoot
ANDROID_CLASS_DIR := app/src/main/java/$(subst .,/,$(ANDROID_PACKAGE))
# The skeleton for the Android build is based on the SDL android-project. The libraries are symlinked in. If the script that rewrites the skeleton
# has changed, start with a fresh skeleton. Use the SPACEBOX revise skeleton script to edit the SDL android-project parameters.
# The skeleton for the Android build is based on the SDL android-project. The libraries are symlinked in. If the script that
# rewrites the skeleton has changed, start with a fresh skeleton. Use the SPACEBOX revise skeleton script to edit the SDL
# android-project parameters.
$(ANDROID_BUILD_DIR): $(SDL_SRC)/android-project/ $(SB_SRC_DIR)/android/revise_skeleton.sh
-mkdir -p $(ANDROID_BUILD_DIR)
rsync -ar $(SDL_SRC)/android-project/ $(ANDROID_BUILD_DIR)
@ -266,13 +280,15 @@ $(ANDROID_BUILD_DIR): $(SDL_SRC)/android-project/ $(SB_SRC_DIR)/android/revise_s
ln -nsf $(SDL_IMAGE_SRC) $(ANDROID_BUILD_DIR)/app/jni/SDL2_image
ln -nsf $(SDL_MIXER_SRC) $(ANDROID_BUILD_DIR)/app/jni/SDL2_mixer
ln -nsf $(SDL_TTF_SRC) $(ANDROID_BUILD_DIR)/app/jni/SDL2_ttf
$(SB_SRC_DIR)/android/revise_skeleton.sh $(ANDROID_PACKAGE) $(ANDROID_BUILD_DIR) $(ANDROID_MANIFEST) $(ANDROID_APP_MK) $(ANDROID_MK) $(ANDROID_CLASS) \
$(ANDROID_APP_NAME) $(ANDROID_MIN_TARGET) $(ANDROID_NDK) "Cakefoot" "21" "24.0.8215888" $(SB_SRC_DIR) $(SB_LIB_DIR) $(SRC_DIR)
$(SB_SRC_DIR)/android/revise_skeleton.sh $(ANDROID_PACKAGE) $(ANDROID_BUILD_DIR) $(ANDROID_MANIFEST) $(ANDROID_APP_MK) \
$(ANDROID_MK) $(ANDROID_CLASS) $(ANDROID_APP_NAME) $(ANDROID_MIN_TARGET) $(ANDROID_NDK) \
"Cakefoot" "21" "24.0.8215888" $(SB_SRC_DIR) $(SB_LIB_DIR) $(SRC_DIR)
ln -nsf $(OPENCV_ANDROID_SDK)/sdk/native/libs $(ANDROID_BUILD_DIR)/app/jni/src/opencv
ln -nsf $(CURL_ANDROID)/jni/build/curl $(ANDROID_BUILD_DIR)/app/jni/src/curl
ln -nsf $(CURL_ANDROID)/jni/build/openssl $(ANDROID_BUILD_DIR)/app/jni/src/openssl
sed -i "s/^APP_CPPFLAGS.*/& -nostartfiles/" "$(ANDROID_BUILD_DIR)/$(ANDROID_APP_MK)"
sed -i "s/org.libsdl.app/$(ANDROID_PACKAGE)/" "$(ANDROID_BUILD_DIR)/app/build.gradle" "$(ANDROID_BUILD_DIR)/$(ANDROID_MANIFEST)"
sed -i "s/org.libsdl.app/$(ANDROID_PACKAGE)/" "$(ANDROID_BUILD_DIR)/app/build.gradle" \
"$(ANDROID_BUILD_DIR)/$(ANDROID_MANIFEST)"
# Extend the SDLActivity class
$(ANDROID_BUILD_DIR)/$(ANDROID_CLASS_DIR)/$(ANDROID_CLASS).java: $(SB_SRC_DIR)/android/main_class.sh
@ -305,10 +321,10 @@ SDL_MINGW := $(SDL_MINGW_ROOT)/SDL2-2.24.2/i686-w64-mingw32
SDL_IMG_MINGW := $(SDL_MINGW_ROOT)/SDL2_image-2.5.2/i686-w64-mingw32
SDL_TTF_MINGW := $(SDL_MINGW_ROOT)/SDL2_ttf-2.0.15/i686-w64-mingw32
SDL_MIXER_MINGW := $(SDL_MINGW_ROOT)/SDL2_mixer-2.5.2/i686-w64-mingw32
WINDOWS_CFLAGS := -Wall -Wextra -O3 -c -I$(SB_LIB_DIR) -I$(SB_SRC_DIR) -DGLEW_STATIC -I$(SDL_MINGW)/include/SDL2 -I$(SDL_IMG_MINGW)/include/SDL2 \
-I$(SDL_TTF_MINGW)/include/SDL2 -I$(SDL_MIXER_MINGW)/include/SDL2
WINDOWS_LFLAGS := -lpthread -lstdc++fs -L$(SDL_MINGW)/lib -L$(SDL_IMG_MINGW)/lib -L$(SDL_TTF_MINGW)/lib -L$(SDL_MIXER_MINGW)/lib -lmingw32 -lSDL2_image \
-lSDL2_ttf -lSDL2_mixer -lSDL2main -lSDL2 -lopengl32 -static-libstdc++ -static-libgcc
WINDOWS_CFLAGS := -Wall -Wextra -O3 -c -I$(SB_LIB_DIR) -I$(SB_SRC_DIR) -DGLEW_STATIC -I$(SDL_MINGW)/include/SDL2 \
-I$(SDL_IMG_MINGW)/include/SDL2 -I$(SDL_TTF_MINGW)/include/SDL2 -I$(SDL_MIXER_MINGW)/include/SDL2
WINDOWS_LFLAGS := -lpthread -lstdc++fs -L$(SDL_MINGW)/lib -L$(SDL_IMG_MINGW)/lib -L$(SDL_TTF_MINGW)/lib -L$(SDL_MIXER_MINGW)/lib \
-lmingw32 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lSDL2main -lSDL2 -lopengl32 -static-libstdc++ -static-libgcc
# Set the compiler to the MinGW compilers
@ -317,7 +333,8 @@ Cakefoot-win32.exe: CXX = i686-w64-mingw32-g++-posix
Cakefoot-win32.exe: CFLAGS = $(WINDOWS_CFLAGS)
Cakefoot-win32.exe: CXXFLAGS = $(CFLAGS) --std=c++17
Cakefoot-win32.exe: LFLAGS = $(WINDOWS_LFLAGS)
Cakefoot-win32.exe: $(addprefix $(WINDOWS_BUILD_DIR)/, glew.o SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) $(SRC_O_FILES)) config.json
Cakefoot-win32.exe: $(addprefix $(WINDOWS_BUILD_DIR)/, glew.o SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) $(SRC_O_FILES)) \
config.json
$(CXX) $(filter-out config.json, $^) $(LFLAGS) -o $(WINDOWS_BUILD_DIR)/$@
mkdir ${basename $@}
cp $(SDL_MINGW)/bin/*.dll $(SDL_IMG_MINGW)/bin/*.dll $(SDL_TTF_MINGW)/bin/*.dll $(SDL_MIXER_MINGW)/bin/*.dll ${basename $@}
@ -334,8 +351,8 @@ Cakefoot-win32-ARCADE_ONLY.exe: CXX = i686-w64-mingw32-g++-posix
Cakefoot-win32-ARCADE_ONLY.exe: CFLAGS = $(WINDOWS_CFLAGS) -D__ARCADE_ONLY__
Cakefoot-win32-ARCADE_ONLY.exe: CXXFLAGS = $(CFLAGS) --std=c++17
Cakefoot-win32-ARCADE_ONLY.exe: LFLAGS = $(WINDOWS_LFLAGS) -D__ARCADE_ONLY__
Cakefoot-win32-ARCADE_ONLY.exe: $(addprefix $(ARCADE_BUILD_DIR)/, glew.o SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) $(SRC_O_FILES)) config.json \
src/config_arcade.json
Cakefoot-win32-ARCADE_ONLY.exe: $(addprefix $(ARCADE_BUILD_DIR)/, glew.o SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) \
$(SRC_O_FILES)) config.json src/config_arcade.json
$(CXX) $(filter-out config.json src/config_arcade.json, $^) $(LFLAGS) -o $(ARCADE_BUILD_DIR)/$@
mkdir ${basename $@}
cp $(SDL_MINGW)/bin/*.dll $(SDL_IMG_MINGW)/bin/*.dll $(SDL_TTF_MINGW)/bin/*.dll $(SDL_MIXER_MINGW)/bin/*.dll ${basename $@}
@ -351,7 +368,8 @@ Cakefoot-win32-ARCADE_ONLY.exe: $(addprefix $(ARCADE_BUILD_DIR)/, glew.o SDL2_ro
# Make all builds #
###################
all : Cakefoot-linux.x86_64 Cakefoot-linux_debug.x86_64 cakefoot.js cakefoot_debug.html cakefoot_coolmath.js Cakefoot-win32.exe Cakefoot-win32-ARCADE_ONLY.exe
all : Cakefoot-linux.x86_64 Cakefoot-linux_debug.x86_64 cakefoot.js cakefoot_debug.html cakefoot_coolmath.js Cakefoot-win32.exe \
Cakefoot-win32-ARCADE_ONLY.exe
#########################
# Clean up object files #

View File

@ -1,12 +1,12 @@
{
"display":
{
"dimensions": [864, 486],
"dimensions": [1280, 720],
"title": "cakefoot🍰👣",
"debug": false,
"render driver": "opengl",
"default font path": "resource/BPmono.ttf",
"show-cursor": true,
"show cursor": true,
"fluid resize": true,
"fps": false,
"fullscreen": false,
@ -104,13 +104,13 @@
"recording":
{
"screenshot-directory": "local/screenshots",
"video-directory": "local/video",
"screenshot directory": "local/screenshots",
"video directory": "local/video",
"enabled": true,
"write-mp4": true,
"video-frame-length": 33.333,
"max-video-memory": 2000,
"mp4-pixel-format": "yuv420p"
"write mp4": true,
"video frame length": 0.016666666,
"max video memory": 2000,
"mp4 pixel format": "yuv420p"
},
"input":
@ -132,14 +132,15 @@
"right": [["right"], ["d"]],
"down": [["down"], ["s"]],
"left": [["left"], ["a"]],
"pause": "escape"
"pause": "escape",
"log video memory size": ["CTRL", "SHIFT", "m"]
},
"log":
{
"enabled": true,
"output-directory": "/var/log/sb/",
"debug-to-stdout": true,
"debug-to-stdout": false,
"debug-to-file": true,
"info-file-name": "cakefoot_info.log",
"debug-file-name": "cakefoot_debug.log",
@ -391,6 +392,7 @@
"audio":
{
"chunk size": 512,
"files":
{
"restart": "resource/no.ogg",

View File

@ -5,6 +5,7 @@
<head>
<meta charset="utf-8">
<link rel="icon" href="favicon.ico" />
<link rel="canonical" href="https://cakefoot.dank.game" />
<style>
@import url("https://shampoo.ooo/lib/fonts/rounded-mplus/2m-medium/style.css");
@import url("https://shampoo.ooo/lib/fonts/rounded-mplus/2p-thin/style.css ");
@ -85,6 +86,13 @@
<!-- Emscripten's module object will update this canvas with WebGL content. -->
<canvas id="canvas"></canvas>
<!--
<div id="message">
<div>email list
<div>hints (coins, controls, arcade cabinet, launch, game engine and source, merch, etc.)
<div>follow
-->
<div id="message">
Cakefoot by <a href="https://ohsqueezy.itch.io">@ohsqueezy</a>👾&#xFE0F; <span class="bullet">🔸</span> Use ☝&#xFE0F;,
&#x1F5B1;&#xFE0F;, &#x2328;&#xFE0F; or 🎮 to play <span class="bullet">🔸</span>

2
lib/sb

@ -1 +1 @@
Subproject commit 71ff65d588fad52f7b77b77772079e85695e9937
Subproject commit 0e4f06d77917d1f4349fd0f46f245eb7e63ebfca

View File

@ -1,7 +1,7 @@
/* _ _
* c/a`k-e'f`o^o~t-, | a single-button action game | by @ooofoam
* / _< | wow a living cake the sweet | play online: https://shampoo.ooo/cakefoot
* > `~_/ | taste of victory | open source: https://open.shampoo.ooo/shampoo/cakefoot
* c/a`k-e'f`o^o~t-, | a single-button action game | @dankd0tgame
* / _< | wow a living cake the sweet | https://cakefoot.dank.game
* > `~_/ | taste of victory | https://open.shampoo.ooo/shampoo/cakefoot
*/
#if defined(__ANDROID__) || defined(ANDROID)
@ -60,8 +60,8 @@ Cakefoot::Cakefoot(std::initializer_list<std::string> configuration_merge) : Gam
/* Overwrite progress data with saved data if it is available */
if (fs::exists(progress_file_path))
{
/* Check progress data for existence of quest progress entries. If they are missing, it indicates an older progress file, so use the general progress
* values for the quest progress. */
/* Check progress data for existence of quest progress entries. If they are missing, it indicates an older progress file, so
* use the general progress values for the quest progress. */
nlohmann::json progress = Configuration::json_from_file(progress_file_path);
if (!progress.at("progress").contains("quest level"))
{
@ -108,7 +108,6 @@ Cakefoot::Cakefoot(std::initializer_list<std::string> configuration_merge) : Gam
name_entry = configuration()("display", "default initials");
/* Subscribe to events */
delegate().subscribe(&Cakefoot::respond, this);
delegate().subscribe(&Cakefoot::respond, this, SDL_MOUSEMOTION);
delegate().subscribe(&Cakefoot::respond, this, SDL_MOUSEBUTTONDOWN);
delegate().subscribe(&Cakefoot::respond, this, SDL_MOUSEBUTTONUP);
@ -129,8 +128,8 @@ Cakefoot::Cakefoot(std::initializer_list<std::string> configuration_merge) : Gam
/* Open the configuration and load the curve data per level */
load_curves();
/* loading GL context for 3D */
load_gl_context();
/* Link shaders and uniforms */
initialize_gl();
/* Load and fill VBO */
load_vbo();
@ -305,8 +304,8 @@ void Cakefoot::load_curves()
nlohmann::json levels = configuration()["levels"];
for (std::size_t ii = 0; ii < levels.size(); ii++)
{
/* Get the current level curve points, which is a list of 2D vertices in the old format of 864x486. The vertices are control points for
* the bezier. */
/* Get the current level curve points, which is a list of 2D vertices in the old format of 864x486. The vertices are control
* points for the bezier. */
nlohmann::json control = levels[ii]["curve"];
glm::vec2 orig = {864.0f, 486.0f}, point;
float rat = orig.x / orig.y;
@ -318,8 +317,8 @@ void Cakefoot::load_curves()
control[jj] = {(point.x / orig.x) * (2.0f * rat) - rat, (1.0f - point.y / orig.y) * 2.0f - 1.0f};
}
/* For each group of four control points, create a bezier, and add each of its vertices to a vector containing all the non-wrapped vertices, which
* is the full curve for the current level before being wrapped. */
/* For each group of four control points, create a bezier, and add each of its vertices to a vector containing all the
* non-wrapped vertices, which is the full curve for the current level before being wrapped. */
std::vector<glm::vec3> unwrapped;
for (std::size_t jj = 0; jj < control.size() - 2; jj += 3)
{
@ -340,10 +339,8 @@ void Cakefoot::load_curves()
}
}
void Cakefoot::load_gl_context()
void Cakefoot::initialize_gl()
{
super::load_gl_context();
/* Generate a vertex array object ID, bind it as current (requirement of OpenGL) */
vao.generate();
sb::Log::gl_errors("after generating VAO");
@ -394,8 +391,8 @@ void Cakefoot::set_up_buttons()
{
/* Set up text buttons */
for (const std::string& name : {
"start", "resume", "reset", "level increment", "level decrement", "profile increment", "profile decrement", "challenge increment",
"challenge decrement", "view increment", "view decrement"
"start", "resume", "reset", "level increment", "level decrement", "profile increment", "profile decrement",
"challenge increment", "challenge decrement", "view increment", "view decrement"
})
{
sb::Text text {name == "resume" || name == "reset" ? fonts.at("medium") : fonts.at("glyph")};
@ -435,8 +432,8 @@ void Cakefoot::set_up_buttons()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
sb::Plane arcade_prompt_plane;
arcade_prompt_plane.texture(arcade_prompt_texture);
button.at("start") = sb::Pad<>{arcade_prompt_plane, configuration()("button", "start alt translation"), configuration()("button", "start alt scale")[1],
1.0f / 5.0f};
button.at("start") = sb::Pad<>{arcade_prompt_plane, configuration()("button", "start alt translation"),
configuration()("button", "start alt scale")[1], 1.0f / 5.0f};
}
/* Set up text button callbacks */
@ -1809,6 +1806,8 @@ void Cakefoot::refresh_scoreboard()
void Cakefoot::respond(SDL_Event& event)
{
Game::respond(event);
/* Translate gamepad input to commands */
if (event.type == SDL_JOYBUTTONDOWN)
{
@ -2333,16 +2332,16 @@ void Cakefoot::respond(SDL_Event& event)
/* Loop through the map, and print each value. */
std::ostringstream message;
int first_column = 40, second_column = 12, count = 0;
message << std::endl;
for (std::pair<std::string, int> malloc_info_entry : malloc_map)
{
message << std::setw(first_column) << malloc_info_entry.first << std::setw(second_column) << std::setprecision(2)
<< std::fixed << malloc_info_entry.second / 1000.0 << " KB";
if ((++count % 3) == 0)
<< std::fixed << malloc_info_entry.second / 1'000'000.0 << " MB";
if ((++count % 2) == 0)
{
message << std::endl;
}
}
message << "---" << std::endl;
sb::Log::log(message);
}
#endif
@ -2352,9 +2351,10 @@ void Cakefoot::respond(SDL_Event& event)
{
std::ostringstream message;
glm::vec2 translation = sb::wrap_point(character.position, {-curve().aspect, -1.0f, 0.0f}, {curve().aspect, 1.0f, 1.0f});
message << std::fixed << std::setprecision(2) << "Character coords: unwrapped " << character.position << ", wrapped " << translation
<< ", clip " << sb::world_to_clip(translation, projection * view) << ", ndc " << sb::world_to_ndc(translation, projection * view)
<< ", window " << sb::world_to_viewport(translation, window_box().size(), projection * view);
message << std::fixed << std::setprecision(2) << "Character coords: unwrapped " << character.position << ", wrapped " <<
translation << ", clip " << sb::world_to_clip(translation, projection * view) << ", ndc " <<
sb::world_to_ndc(translation, projection * view) << ", window " <<
sb::world_to_viewport(translation, window_box().size(), projection * view);
sb::Log::log(message);
}
}
@ -2385,7 +2385,8 @@ void Cakefoot::respond(SDL_Event& event)
{
if (name != "fullscreen" || configuration()("display", "fullscreen enabled"))
{
if ((event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEMOTION) && button.at(name).collide(mouse_ndc, view, projection))
if ((event.type == SDL_MOUSEBUTTONDOWN ||
event.type == SDL_MOUSEMOTION) && button.at(name).collide(mouse_ndc, view, projection))
{
if (event.type == SDL_MOUSEBUTTONDOWN)
{
@ -2477,7 +2478,8 @@ void Cakefoot::update(float timestamp)
}
/* Transformation that applies the rotation state of the entire scene */
glm::mat4 rotation_matrix = glm::rotate(glm::mat4(1), rotation_x, {0.0f, 1.0f, 0.0f}) * glm::rotate(glm::mat4(1), rotation_y, {1.0f, 0.0f, 0.0f});
glm::mat4 rotation_matrix = glm::rotate(glm::mat4(1), rotation_x, {0.0f, 1.0f, 0.0f}) * glm::rotate(
glm::mat4(1), rotation_y, {1.0f, 0.0f, 0.0f});
/* Clear screen to world color */
if (flash_animation.playing())

View File

@ -281,8 +281,8 @@ private:
std::vector<Splash> splash;
/*!
* Load sound effects and music into objects that can be used by the SDL mixer library. Use chunk objects for background music instead of
* music objects so background music tracks can fade into each other.
* Load sound effects and music into objects that can be used by the SDL mixer library. Use chunk objects for background music instead
* of music objects so background music tracks can fade into each other.
*/
void load_audio();
@ -292,13 +292,14 @@ private:
void load_curves();
/*!
* Create GL context via super class and load vertices, UV data, and shaders.
* Compile and attach shaders, store locations of uniforms, initialize some GL properties. This must be done after the GL context
* is created (currently the context is created in the Game constructor, so it will have been created already when this is called).
*/
void load_gl_context();
void initialize_gl();
/*!
* Create button objects and assign them to the entries in the button map. This can be re-run to apply changes made in the configuration or
* to refresh label content.
* Create button objects and assign them to the entries in the button map. This can be re-run to apply changes made in the
* configuration or to refresh label content.
*/
void set_up_buttons();

View File

@ -2,7 +2,7 @@
"display":
{
"dimensions": [1920, 1080],
"show-cursor": false,
"show cursor": false,
"fullscreen": true,
"arcade only": true,
"use arcade prompt": true,