Compare commits

..

No commits in common. "amigaos" and "v3.1.2" have entirely different histories.

42 changed files with 182 additions and 1115 deletions

12
.github/FUNDING.yml vendored
View File

@ -1,12 +0,0 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: LiquidityC
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

4
.gitignore vendored
View File

@ -15,7 +15,3 @@
/steam_appid.txt /steam_appid.txt
/*.so /*.so
/breakhack*.run /breakhack*.run
compile_commands.json
*.o
breakhack

View File

@ -5,9 +5,9 @@ SET(CMAKE_COLOR_MAKEFILE ON)
project(breakhack C) project(breakhack C)
set(breakhack_GAME_TITLE "BreakHack") set(breakhack_GAME_TITLE "BreakHack")
set(breakhack_MAJOR_VERSION 4) set(breakhack_MAJOR_VERSION 3)
set(breakhack_MINOR_VERSION 0) set(breakhack_MINOR_VERSION 1)
set(breakhack_PATCH_VERSION 3) set(breakhack_PATCH_VERSION 2)
set(breakhack_RELEASE_TYPE "") set(breakhack_RELEASE_TYPE "")
# Checksums # Checksums
@ -184,62 +184,61 @@ endif ()
# PROGRAMS: # PROGRAMS:
add_executable(breakhack add_executable(breakhack
src/main.c src/main
src/texture.c src/texture
src/screenresolution.c src/screenresolution
src/sprite.c src/sprite
src/sprite_util.c src/sprite_util
src/util.c src/util
src/event.c src/event
src/player.c src/player
src/save.c src/map
src/map.c src/map_lua
src/map_lua.c src/camera
src/camera.c src/timer
src/timer.c src/roommatrix
src/roommatrix.c src/position
src/position.c src/monster
src/monster.c src/stats
src/stats.c src/actiontext
src/actiontext.c src/random
src/random.c src/time
src/time.c src/linkedlist
src/linkedlist.c src/hashtable
src/hashtable.c src/gui
src/gui.c src/item
src/item.c src/item_builder
src/item_builder.c src/pointer
src/pointer.c src/gui_button
src/gui_button.c src/particle_engine
src/particle_engine.c src/particle_emitter
src/particle_emitter.c src/menu
src/menu.c src/collisions
src/collisions.c src/keyboard
src/keyboard.c src/input
src/input.c src/mixer
src/mixer.c src/io_util
src/io_util.c src/physfsrwops
src/physfsrwops.c src/skillbar
src/skillbar.c src/texturecache
src/texturecache.c src/skill
src/skill.c src/projectile
src/projectile.c src/vector2d
src/vector2d.c src/map_room_modifiers
src/map_room_modifiers.c sqlite3/sqlite3
sqlite3/sqlite3.c src/db
src/db.c src/settings
src/settings.c src/actiontextbuilder
src/actiontextbuilder.c src/animation
src/animation.c src/trap
src/trap.c src/artifact
src/artifact.c src/screen
src/screen.c src/hiscore
src/hiscore.c src/object
src/object.c src/gui_util
src/gui_util.c src/tooltip
src/tooltip.c src/gamecontroller
src/gamecontroller.c src/effect_util
src/effect_util.c
${STEAM_SOURCES} ${STEAM_SOURCES}
) )
@ -283,19 +282,19 @@ endif (MSVC)
IF (CMOCKA_FOUND AND NOT OSX AND NOT CLANG) IF (CMOCKA_FOUND AND NOT OSX AND NOT CLANG)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
enable_testing() enable_testing()
add_executable(test_util test/test_util.c src/util.c) add_executable(test_util test/test_util src/util)
target_link_libraries(test_util ${CMOCKA_LIBRARY}) target_link_libraries(test_util ${CMOCKA_LIBRARY})
add_test(test_util test_util) add_test(test_util test_util)
add_executable(test_linkedlist test/test_linkedlist.c src/linkedlist.c src/util.c) add_executable(test_linkedlist test/test_linkedlist src/linkedlist src/util)
target_link_libraries(test_linkedlist ${CMOCKA_LIBRARY}) target_link_libraries(test_linkedlist ${CMOCKA_LIBRARY})
add_test(test_linkedlist test_linkedlist) add_test(test_linkedlist test_linkedlist)
add_executable(test_hashtable test/test_hashtable.c src/hashtable.c src/util.c) add_executable(test_hashtable test/test_hashtable src/hashtable src/util)
target_link_libraries(test_hashtable ${CMOCKA_LIBRARY}) target_link_libraries(test_hashtable ${CMOCKA_LIBRARY})
add_test(test_hashtable test_hashtable) add_test(test_hashtable test_hashtable)
add_executable(test_input test/test_input.c src/input.c src/keyboard.c) add_executable(test_input test/test_input src/input src/keyboard)
target_link_libraries(test_input target_link_libraries(test_input
${CMOCKA_LIBRARY} ${CMOCKA_LIBRARY}
${SDL2_LIBRARY} ${SDL2_LIBRARY}
@ -309,7 +308,7 @@ ENDIF ()
# LINT: # LINT:
if (CPPCHECK_FOUND) if (CPPCHECK_FOUND)
add_custom_target(lint add_custom_target(lint
COMMAND ${CPPCHECK_EXECUTABLE} --force --language=c --template=gcc --error-exitcode=1 --quiet --suppress=missingInclude --enable=warning,style,performance,portability,information,missingInclude src/ COMMAND ${CPPCHECK_EXECUTABLE} --force --language=c --template=gcc --error-exitcode=1 --quiet --suppress=unreadVariable --suppress=missingInclude --enable=warning,style,performance,portability,information,missingInclude src/
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Run cppcheck" COMMENT "Run cppcheck"
) )

View File

@ -7,12 +7,12 @@ release:
.PHONY: release .PHONY: release
clean: clean:
@make -sC _build/debug clean @make clean -sC _build/debug
@make -sC _build/release clean @make clean -sC _build/release
.PHONY: clean .PHONY: clean
test: test:
@make -sC _build/debug test @make test -sC _build/debug
.PHONY: test .PHONY: test
run: $(all) run: $(all)
@ -24,27 +24,9 @@ playtest: $(all)
.PHONY: playtest .PHONY: playtest
lint: lint:
@make -sC _build/debug lint @make lint -sC _build/debug
.PHONY: lint .PHONY: lint
package: package:
@make -sC _build/release package @make package -sC _build/release
.PHONY: package .PHONY: package
setup:
@mkdir -p _build/release
@mkdir -p _build/debug
@cd _build/debug/ && \
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=YES ../.. && \
cd -
@cd _build/debug/ && \
cmake -DCMAKE_BUILD_TYPE=Release ../.. && \
cd -
@ln -s _build/debug/compile_commands.json
@echo "Setup complete"
.PHONY: setup
teardown:
@rm -rf _build
@rm compile_commands.json
.PHONY: teardown

View File

@ -1,503 +0,0 @@
#
# Project: breakhack
#
# Created on: 29-08-2022 21:00:37
# by George Sokianos
#
###################################################################
##
##//// Objects
##
###################################################################
breakhack_OBJ := \
src/actiontext.o src/actiontextbuilder.o src/animation.o \
src/artifact.o src/camera.o src/collisions.o \
src/db.o src/effect_util.o src/event.o \
src/gamecontroller.o src/gui_button.o src/gui.o \
src/gui_util.o src/hashtable.o src/hiscore.o \
src/input.o src/io_util.o src/item_builder.o \
src/item.o src/keyboard.o src/linkedlist.o \
src/main.o src/map.o src/map_lua.o \
src/map_room_modifiers.o src/menu.o src/mixer.o \
src/monster.o src/object.o src/particle_emitter.o \
src/particle_engine.o src/physfsrwops.o src/player.o \
src/pointer.o src/position.o src/projectile.o \
src/random.o src/roommatrix.o src/save.o \
src/screen.o src/screenresolution.o src/settings.o \
src/skill.o src/skillbar.o src/sprite.o \
src/sprite_util.o src/stats.o src/texture.o \
src/texturecache.o src/time.o src/timer.o \
src/tooltip.o src/trap.o src/util.o \
src/vector2d.o bh_random/src/bh_random.o
###################################################################
##
##//// Variables and Environment
##
###################################################################
CC := gcc:bin/gcc
INCPATH := -I. -I/sdk/local/newlib/include/SDL2 -Ibh_random/src \
-I/sdk/local/common/include/lua53
# -DDEBUG
CFLAGS := $(INCPATH) -Wall -Wwrite-strings -Wno-discarded-qualifiers
# \
# -g -gstabs
# -ggdb -gdwarf-2
LFLAGS := -lauto -lSDL2_image -lSDL2_ttf -lfreetype -ltiff -lwebp -lpng -ljpeg \
-llua53 -lsqlite3 -lz \
-lSDL2_mixer -lmikmod -lmodplug -lFLAC -logg \
-lSDL2 -lphysfs -lpthread -athread=native -lstdc++
# \
# -g -gstabs
# -ggdb -gdwarf-2
# -lunix
# -lenet -lcrypto -lSDL2_gl4es -lglu_gl4es -lgl4es -lopenal \
###################################################################
##
##//// General rules
##
###################################################################
.PHONY: all all-before all-after clean clean-custom realclean
all: all-before breakhack all-after
all-before:
# You can add rules here to execute before the project is built
all-after:
# You can add rules here to execute after the project is built
clean: clean-custom
@echo "Cleaning compiler objects..."
@rm -f $(breakhack_OBJ)
realclean:
@echo "Cleaning compiler objects and targets..."
@rm -f $(breakhack_OBJ) breakhack
###################################################################
##
##//// Targets
##
###################################################################
breakhack: $(breakhack_OBJ)
@echo "Linking breakhack"
@gcc:bin/gcc -o breakhack $(breakhack_OBJ) $(LFLAGS)
@echo "Removing stale debug target: breakhack"
@rm -f breakhack.debug
###################################################################
##
##//// Standard rules
##
###################################################################
# A default rule to make all the objects listed below
# because we are hiding compiler commands from the output
.c.o:
@echo "Compiling $<"
@$(CC) -c $< -o $*.o $(CFLAGS)
src/actiontext.o: src/actiontext.c src/actiontext.h \
src/position.h src/sprite.h src/texture.h \
src/camera.h src/roommatrix.h src/timer.h \
src/vector2d.h src/util.h src/update_data.h \
src/player.h src/stats.h src/skill.h \
src/linkedlist.h src/input.h src/artifact.h \
src/map.h src/defines.h src/monster.h \
src/map_room_modifiers.h src/object.h src/doorlocktype.h
src/actiontextbuilder.o: src/actiontextbuilder.c src/actiontextbuilder.h src/actiontext.h \
src/position.h src/sprite.h src/timer.h \
src/vector2d.h src/camera.h src/update_data.h \
src/player.h src/map.h src/roommatrix.h \
src/gui.h src/util.h
src/animation.o: src/animation.c src/animation.h src/timer.h \
src/camera.h src/position.h src/vector2d.h \
src/sprite.h src/texture.h \
src/dimension.h src/roommatrix.h src/defines.h \
src/map_room_modifiers.h src/input.h
src/artifact.o: src/artifact.c src/artifact.h src/sprite.h \
src/texture.h src/position.h src/camera.h \
src/roommatrix.h src/timer.h \
src/vector2d.h src/util.h src/texturecache.h \
src/dimension.h src/particle_engine.h src/player.h \
src/stats.h src/actiontext.h src/skill.h \
src/linkedlist.h src/input.h src/random.h \
src/camera.o: src/camera.c src/camera.h src/position.h \
src/timer.h src/vector2d.h src/map.h \
src/linkedlist.h src/sprite.h src/texture.h \
src/roommatrix.h src/defines.h src/config.h \
src/monster.h src/stats.h src/actiontext.h \
src/player.h src/doorlocktype.h src/particle_emitter.h \
src/skill.h src/input.h src/artifact.h \
src/map_room_modifiers.h src/object.h src/util.h
src/collisions.o: src/collisions.c src/collisions.h
src/db.o: src/db.c src/db.h
src/effect_util.o: src/effect_util.c src/gui.h src/linkedlist.h \
src/sprite.h src/texture.h src/position.h \
src/camera.h src/roommatrix.h src/timer.h \
src/vector2d.h src/player.h \
src/stats.h src/actiontext.h src/skill.h \
src/input.h src/artifact.h src/monster.h src/doorlocktype.h \
src/particle_emitter.h src/dimension.h src/defines.h \
src/config.h src/map_room_modifiers.h
src/event.o: src/event.c src/event.h src/player.h \
src/sprite.h src/stats.h \
src/actiontext.h src/camera.h src/skill.h \
src/linkedlist.h src/input.h src/artifact.h
src/gamecontroller.o: src/gamecontroller.c src/gamecontroller.h
src/gui_button.o: src/gui_button.c src/util.h src/gui_button.h \
src/pointer.h src/sprite.h src/camera.h \
src/input.h src/texture.h src/position.h \
src/roommatrix.h src/timer.h src/linkedlist.h \
src/vector2d.h
src/gui.o: src/gui.c src/gui.h src/linkedlist.h \
src/sprite.h src/texture.h src/position.h \
src/camera.h src/roommatrix.h src/timer.h \
src/vector2d.h src/player.h \
src/stats.h src/actiontext.h src/skill.h \
src/input.h src/artifact.h src/util.h \
src/map.h \
src/defines.h src/config.h src/monster.h \
src/doorlocktype.h src/particle_emitter.h src/map_room_modifiers.h \
src/object.h src/texturecache.h \
src/dimension.h src/gui_util.h
src/gui_util.o: src/gui_util.c src/texturecache.h src/texture.h \
src/dimension.h src/position.h \
src/camera.h src/gui_util.h src/sprite.h \
src/roommatrix.h src/timer.h
src/hashtable.o: src/hashtable.c src/hashtable.h src/defines.h \
src/config.h
src/hiscore.o: src/hiscore.c src/hiscore.h src/linkedlist.h \
src/player.h src/sprite.h \
src/stats.h src/actiontext.h src/camera.h \
src/skill.h src/input.h src/artifact.h \
src/db.h
src/input.o: src/input.c src/input.h
src/io_util.o: src/io_util.c src/physfsrwops.h src/io_util.h
src/item_builder.o: src/item_builder.c src/item_builder.h \
src/item.h src/sprite.h src/position.h \
src/player.h src/camera.h src/linkedlist.h \
src/texture.h src/dimension.h \
src/timer.h src/vector2d.h src/util.h \
src/gui.h src/roommatrix.h src/stats.h \
src/actiontext.h src/skill.h src/input.h \
src/artifact.h src/mixer.h src/gamestate.h \
src/random.h src/texturecache.h src/defines.h \
src/map_room_modifiers.h src/sprite_util.h src/map.h \
src/config.h src/monster.h src/doorlocktype.h \
src/particle_emitter.h
src/item.o: src/item.c src/item.h src/sprite.h \
src/texture.h src/position.h src/camera.h \
src/roommatrix.h src/timer.h src/player.h \
src/stats.h src/actiontext.h \
src/skill.h src/linkedlist.h src/input.h \
src/artifact.h src/vector2d.h src/util.h \
src/mixer.h src/gamestate.h src/gui.h \
src/actiontextbuilder.h src/update_data.h
src/keyboard.o: src/keyboard.c src/keyboard.h src/defines.h \
src/config.h
src/linkedlist.o: src/linkedlist.c src/linkedlist.h
src/main.o: src/main.c /sdk/local/newlib/include/SDL2/SDL_main.h \
src/linkedlist.h src/player.h src/sprite.h \
src/texture.h src/position.h src/camera.h \
src/roommatrix.h src/timer.h src/stats.h \
src/actiontext.h src/vector2d.h src/skill.h \
src/input.h src/artifact.h src/screenresolution.h \
src/dimension.h src/map.h src/defines.h \
src/config.h src/monster.h src/doorlocktype.h \
src/particle_emitter.h src/map_room_modifiers.h src/object.h \
src/map_lua.h src/gamestate.h src/gui.h \
src/util.h src/item_builder.h src/item.h \
src/pointer.h src/gui_button.h src/particle_engine.h \
src/menu.h src/keyboard.h \
src/mixer.h src/random.h src/skillbar.h \
src/texturecache.h src/update_data.h src/settings.h \
src/actiontextbuilder.h src/screen.h src/hiscore.h \
src/io_util.h src/tooltip.h src/gamecontroller.h \
src/time.h src/sprite_util.h src/event.h \
src/save.h src/steam/steamworks_api_wrapper.h src/defines.h
src/map.o: src/map.c src/map.h src/linkedlist.h \
src/sprite.h src/texture.h src/position.h \
src/camera.h src/roommatrix.h src/timer.h \
src/vector2d.h src/defines.h src/config.h \
src/monster.h src/stats.h src/actiontext.h \
src/player.h src/doorlocktype.h src/particle_emitter.h \
src/skill.h src/input.h src/artifact.h \
src/map_room_modifiers.h src/object.h src/map_lua.h \
src/util.h src/item.h src/item_builder.h \
src/gui.h src/particle_engine.h src/dimension.h \
src/update_data.h src/trap.h src/mixer.h
src/map_lua.o: src/map_lua.c src/map_lua.h src/map.h \
src/linkedlist.h src/sprite.h \
src/camera.h src/position.h src/timer.h \
src/defines.h src/monster.h src/player.h \
src/map_room_modifiers.h src/object.h src/doorlocktype.h \
src/config.h src/util.h src/stats.h \
src/io_util.h src/texturecache.h src/texture.h \
src/dimension.h src/trap.h src/roommatrix.h \
src/actiontext.h src/skill.h src/input.h \
src/artifact.h src/update_data.h src/gui.h \
src/vector2d.h src/item.h src/item_builder.h
src/map_room_modifiers.o: src/map_room_modifiers.c src/map_room_modifiers.h src/vector2d.h \
src/player.h src/sprite.h src/texture.h \
src/position.h src/camera.h src/roommatrix.h \
src/timer.h src/stats.h src/actiontext.h \
src/skill.h src/linkedlist.h src/input.h \
src/artifact.h src/defines.h
src/menu.o: src/menu.c src/menu.h src/camera.h \
src/position.h src/timer.h src/vector2d.h \
src/linkedlist.h src/texture.h \
src/dimension.h src/sprite.h src/roommatrix.h \
src/util.h src/defines.h src/map_room_modifiers.h \
src/input.h src/config.h src/gui_button.h \
src/pointer.h src/keyboard.h src/mixer.h \
src/gamestate.h src/collisions.h
src/mixer.o: src/mixer.c src/mixer.h src/gamestate.h \
src/util.h src/io_util.h src/settings.h
src/monster.o: src/monster.c src/monster.h src/sprite.h \
src/texture.h src/position.h src/camera.h \
src/roommatrix.h src/timer.h src/stats.h \
src/actiontext.h src/vector2d.h src/player.h \
src/skill.h src/linkedlist.h src/input.h \
src/artifact.h src/doorlocktype.h src/particle_emitter.h \
src/dimension.h src/util.h src/random.h \
src/gui.h src/item.h src/item_builder.h \
src/map.h src/defines.h src/config.h \
src/map_room_modifiers.h src/object.h src/particle_engine.h \
src/update_data.h src/actiontextbuilder.h src/texturecache.h \
src/trap.h src/mixer.h
src/object.o: src/object.c src/object.h src/camera.h \
src/position.h src/timer.h src/vector2d.h \
src/player.h src/sprite.h src/stats.h \
src/actiontext.h src/skill.h src/linkedlist.h \
src/input.h src/artifact.h src/texture.h \
src/roommatrix.h src/util.h src/mixer.h \
src/gamestate.h src/random.h src/texturecache.h
src/particle_emitter.o: src/particle_emitter.c src/particle_emitter.h src/timer.h \
src/position.h src/dimension.h
src/particle_engine.o: src/particle_engine.c src/particle_engine.h src/position.h \
src/dimension.h src/camera.h src/timer.h \
src/vector2d.h src/linkedlist.h src/util.h \
src/defines.h src/config.h
src/physfsrwops.o: src/physfsrwops.c src/physfsrwops.h
src/player.o: src/player.c src/player.h src/sprite.h \
src/texture.h src/position.h src/camera.h \
src/roommatrix.h src/timer.h src/stats.h \
src/actiontext.h src/vector2d.h src/skill.h \
src/linkedlist.h src/input.h src/artifact.h \
src/monster.h src/doorlocktype.h src/particle_emitter.h \
src/dimension.h src/util.h src/gui.h \
src/item.h src/particle_engine.h src/keyboard.h \
src/defines.h src/config.h src/mixer.h \
src/gamestate.h src/random.h src/projectile.h \
src/map_room_modifiers.h src/update_data.h src/map.h \
src/texturecache.h src/actiontextbuilder.h \
src/animation.h src/trap.h src/gamecontroller.h \
src/event.h src/effect_util.h src/steam/steamworks_api_wrapper.h \
src/defines.h
src/pointer.o: src/pointer.c src/pointer.h src/sprite.h \
src/texture.h src/position.h src/camera.h \
src/roommatrix.h src/timer.h src/vector2d.h \
src/input.h src/util.h src/particle_engine.h
src/position.o: src/position.c src/position.h src/defines.h
src/projectile.o: src/projectile.c src/projectile.h src/sprite.h \
src/texture.h src/position.h src/camera.h \
src/roommatrix.h src/timer.h \
src/vector2d.h src/defines.h src/map_room_modifiers.h \
src/input.h src/update_data.h src/player.h \
src/map.h src/gui.h src/config.h \
src/util.h src/texturecache.h src/dimension.h \
src/stats.h src/actiontext.h src/skill.h \
src/linkedlist.h src/artifact.h src/monster.h \
src/doorlocktype.h src/particle_emitter.h src/mixer.h \
src/gamestate.h src/item_builder.h src/item.h \
src/random.h src/object.h src/effect_util.h
src/random.o: src/random.c src/time.h src/random.h
src/roommatrix.o: src/roommatrix.c src/defines.h src/config.h \
src/roommatrix.h src/position.h src/camera.h \
src/timer.h src/vector2d.h \
src/map_room_modifiers.h src/input.h src/util.h \
src/map.h src/linkedlist.h src/sprite.h src/texture.h \
src/monster.h src/stats.h src/actiontext.h \
src/player.h src/doorlocktype.h src/particle_emitter.h \
src/skill.h src/artifact.h src/object.h \
src/item.h src/update_data.h src/gui.h
src/save.o: src/save.c src/save.h src/player.h \
src/sprite.h src/stats.h \
src/actiontext.h src/camera.h src/skill.h \
src/linkedlist.h src/input.h src/artifact.h \
src/db.h src/defines.h src/config.h
src/screen.o: src/screen.c src/screen.h src/texture.h \
src/dimension.h \
src/position.h src/camera.h src/linkedlist.h \
src/sprite.h src/roommatrix.h src/timer.h \
src/vector2d.h src/util.h src/hiscore.h \
src/player.h src/stats.h src/actiontext.h \
src/skill.h src/input.h
src/screenresolution.o: src/screenresolution.c src/defines.h src/config.h \
src/util.h src/screenresolution.h
src/settings.o: src/settings.c src/settings.h src/util.h \
src/defines.h src/config.h
src/skill.o: src/skill.c src/texturecache.h src/texture.h \
src/dimension.h src/position.h \
src/camera.h src/skill.h src/roommatrix.h \
src/defines.h src/map_room_modifiers.h src/input.h \
src/sprite.h src/timer.h src/vector2d.h \
src/util.h src/player.h src/stats.h \
src/actiontext.h src/linkedlist.h src/artifact.h \
src/config.h src/monster.h src/doorlocktype.h \
src/particle_emitter.h src/mixer.h src/gamestate.h \
src/gui.h src/random.h src/particle_engine.h \
src/projectile.h src/update_data.h src/map.h \
src/item.h src/animation.h src/trap.h \
src/tooltip.h src/actiontextbuilder.h
src/skillbar.o: src/skillbar.c src/defines.h src/config.h \
src/skillbar.h src/linkedlist.h src/camera.h \
src/position.h src/timer.h src/vector2d.h \
src/player.h src/sprite.h src/stats.h \
src/actiontext.h src/skill.h src/input.h \
src/artifact.h src/texture.h \
src/dimension.h src/util.h src/roommatrix.h \
src/map_room_modifiers.h src/keyboard.h src/texturecache.h \
src/particle_engine.h src/update_data.h src/map.h \
src/monster.h src/object.h src/doorlocktype.h
src/sprite.o: src/sprite.c src/sprite.h src/texture.h \
src/dimension.h \
src/position.h src/camera.h src/timer.h \
src/vector2d.h src/roommatrix.h src/defines.h \
src/map_room_modifiers.h src/input.h src/util.h \
src/update_data.h src/player.h src/stats.h \
src/actiontext.h src/skill.h src/linkedlist.h \
src/artifact.h src/map.h src/monster.h \
src/object.h src/doorlocktype.h
src/sprite_util.o: src/sprite_util.c src/sprite_util.h src/sprite.h \
src/texture.h src/position.h src/camera.h \
src/roommatrix.h src/timer.h
src/stats.o: src/stats.c src/gui.h \
src/linkedlist.h src/sprite.h src/texture.h \
src/position.h src/camera.h src/roommatrix.h \
src/timer.h src/vector2d.h src/player.h \
src/stats.h src/actiontext.h src/skill.h \
src/input.h src/artifact.h src/random.h \
src/util.h src/defines.h
src/texture.o: src/texture.c src/texture.h \
src/dimension.h src/position.h \
src/camera.h src/timer.h src/vector2d.h \
src/util.h
src/texturecache.o: src/texturecache.c src/texturecache.h \
src/texture.h src/dimension.h \
src/position.h src/camera.h src/hashtable.h \
src/defines.h src/config.h src/util.h
src/time.o: src/time.c src/time.h
src/timer.o: src/timer.c src/util.h
src/tooltip.o: src/tooltip.c src/tooltip.h src/camera.h \
src/position.h src/timer.h \
src/vector2d.h src/sprite.h src/texture.h \
src/roommatrix.h src/gui_util.h src/defines.h \
src/config.h src/gui.h src/linkedlist.h \
src/player.h src/stats.h src/actiontext.h \
src/skill.h src/input.h src/artifact.h \
src/texturecache.h
src/trap.o: src/trap.c src/trap.h \
src/sprite.h src/texture.h src/position.h \
src/camera.h src/roommatrix.h src/timer.h \
src/player.h src/stats.h src/actiontext.h \
src/skill.h src/linkedlist.h src/input.h \
src/artifact.h src/update_data.h src/map.h \
src/gui.h src/vector2d.h src/util.h \
src/random.h
src/util.o: src/util.c src/time.h src/defines.h \
src/config.h
src/vector2d.o: src/vector2d.c
bh_random/src/bh_random.o:
@g++ -c bh_random/src/bh_random.cpp -o bh_random/src/bh_random.o $(CFLAGS)
# prepare an archive for the program
release:
@echo "Creating release files..."
@mkdir -p release/breakhack
@cp -r release_files/* release/breakhack/
@cp -r data release/breakhack/
@cp -r assets release/breakhack/
@cp breakhack release/breakhack/
@strip release/breakhack/breakhack
@cp README.md release/breakhack/
@cp README_Amiga.md release/breakhack/
@cp LICENSE.txt release/breakhack/
@cp CREDITS.md release/breakhack/
@echo "Creating release archive..."
@lha -aeqr3 a breakhack-OS4.lha release/
@echo "Clean release files..."
@delete release ALL QUIET FORCE

View File

@ -1,4 +1,3 @@
[![maintenance](https://img.shields.io/badge/maintenance-passively--maintained-orange)](https://img.shields.io/badge/maintenance-passively--maintained-orange)
[![Build Status](https://travis-ci.org/Oliveshark/breakhack.svg?branch=master)](https://travis-ci.org/Oliveshark/breakhack) [![Build Status](https://travis-ci.org/Oliveshark/breakhack.svg?branch=master)](https://travis-ci.org/Oliveshark/breakhack)
[![Build status](https://ci.appveyor.com/api/projects/status/2a18npdntkmlx3dc?svg=true)](https://ci.appveyor.com/project/LiquidityC/breakhack) [![Build status](https://ci.appveyor.com/api/projects/status/2a18npdntkmlx3dc?svg=true)](https://ci.appveyor.com/project/LiquidityC/breakhack)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/fc02d56fa7194e61b2c7d260fd2e4186)](https://www.codacy.com/app/LiquidityC/breakhack?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Oliveshark/breakhack&amp;utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/fc02d56fa7194e61b2c7d260fd2e4186)](https://www.codacy.com/app/LiquidityC/breakhack?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Oliveshark/breakhack&amp;utm_campaign=Badge_Grade)

View File

@ -1,48 +0,0 @@
# breakhack for AmigaOS 4.1 FE
breakhack is a small roguelike game for having some good time, while
you wait for your amiga to compile or render a screen. It is developed
by Linus Probert and you can find it for various platforms on Steam.
## Installation
Extract the archive wherever you want and run the *breakhack* binary.
## I would like to thank
- Linus Probert for creating this awesome game and open sourcing it
- Capehill for his tireless work on SDL port for AmigaOS 4.1 FE
- Roman "kas1e" Kargin and Nouvel "HunoPPC" Hugues for their help
with libphysfs
## Known issues
There are some issues with the Fullscreen graphics, depending which
Renderer driver is used. I might fix them in the future.
## Support
If you enjoy what I am doing and would like to keep me up during the night,
please consider to buy me a coffee at:
https://ko-fi.com/walkero
## Known issues
You can find the known issues at
https://git.walkero.gr/walkero/breakhack/issues
# Changelog
## [4.0.3r2] - 2023-07-04
### Changed
- Compiled with latest SDL 2.0.28 that has a better support for 16bit
screens. Now it works under Qemu. Tested with Software rendering
### Fixed
- Fixed the hiscore date. Now it is saved on UTC +8 years which is
the Amiga epoch diff against the unix one. This doesn affect the
old hi-scores though
## [4.0.3r1] - 2022-12-21
### Added
- First release for AmigaOS 4

Binary file not shown.

View File

@ -8,7 +8,7 @@ if (NOT CMAKE_BUILD_TYPE)
endif () endif ()
add_library(bh_random STATIC add_library(bh_random STATIC
src/bh_random.cpp src/bh_random
) )
IF ( MSVC ) IF ( MSVC )

View File

@ -1 +0,0 @@
4edeb17 Fixes cross save problems due to architecture differences

View File

@ -1 +0,0 @@
e636ec1 Don't delete saves from other architectures on death

View File

@ -7,12 +7,12 @@ endif ()
add_executable(checksumtool add_executable(checksumtool
src/checksum.c src/checksum
) )
target_compile_definitions(checksumtool PUBLIC EXECUTABLE=1) target_compile_definitions(checksumtool PUBLIC EXECUTABLE=1)
add_library(checksum add_library(checksum
src/checksum.c src/checksum
) )
IF ( MSVC ) IF ( MSVC )

View File

@ -9,7 +9,7 @@
# compile, using preprocessor checks for platform-specific bits instead of # compile, using preprocessor checks for platform-specific bits instead of
# testing in here. # testing in here.
cmake_minimum_required(VERSION 3.6) cmake_minimum_required(VERSION 2.8.4)
project(PhysicsFS) project(PhysicsFS)
set(PHYSFS_VERSION 3.0.1) set(PHYSFS_VERSION 3.0.1)

Binary file not shown.

View File

@ -47,7 +47,7 @@ actiontext_render(ActionText *t, Camera *cam)
if (t->dead) if (t->dead)
return; return;
if (!timer_started(t->timer)) if (!t->dead && !timer_started(t->timer))
timer_start(t->timer); timer_start(t->timer);
if (timer_get_ticks(t->timer) < 500) { if (timer_get_ticks(t->timer) < 500) {

View File

@ -32,7 +32,7 @@ actiontextbuilder_init(SDL_Renderer *renderer)
} }
void void
actiontextbuilder_create_text(const char *msg, SDL_Color color, const Position *p) actiontextbuilder_create_text(const char *msg, SDL_Color color, Position *p)
{ {
assert (gRenderer != NULL); assert (gRenderer != NULL);
Sprite *sprite = sprite_create(); Sprite *sprite = sprite_create();

View File

@ -34,7 +34,7 @@ void
actiontextbuilder_render(Camera*); actiontextbuilder_render(Camera*);
void void
actiontextbuilder_create_text(const char *msg, SDL_Color, const Position*); actiontextbuilder_create_text(const char *msg, SDL_Color, Position*);
void void
actiontextbuilder_close(void); actiontextbuilder_close(void);

View File

@ -86,7 +86,7 @@ animation_render(Animation *animation, Camera *camera)
} }
void void
animation_set_frames(Animation *animation, const AnimationClip clips[]) animation_set_frames(Animation *animation, AnimationClip clips[])
{ {
for (size_t i = 0; i < animation->clipCount; i++) { for (size_t i = 0; i < animation->clipCount; i++) {
animation->clips[i] = clips[i]; animation->clips[i] = clips[i];

View File

@ -53,7 +53,7 @@ void
animation_load_texture(Animation *, const char *path, SDL_Renderer*); animation_load_texture(Animation *, const char *path, SDL_Renderer*);
void void
animation_set_frames(Animation*, const AnimationClip clips[]); animation_set_frames(Animation*, AnimationClip clips[]);
void void
animation_run(Animation*); animation_run(Animation*);

View File

@ -303,7 +303,7 @@ artifact_create(MagicalEffect effect)
} }
Artifact * Artifact *
artifact_copy(const Artifact *a) artifact_copy(Artifact *a)
{ {
Artifact *new = ec_malloc(sizeof(Artifact)); Artifact *new = ec_malloc(sizeof(Artifact));
*new = *a; *new = *a;

View File

@ -66,7 +66,7 @@ Artifact *
artifact_create(MagicalEffect); artifact_create(MagicalEffect);
Artifact * Artifact *
artifact_copy(const Artifact*); artifact_copy(Artifact*);
void void
artifact_render(Artifact*, Camera*); artifact_render(Artifact*, Camera*);

View File

@ -1,36 +0,0 @@
/*
* BreakHack - A dungeone crawler RPG
* Copyright (C) 2018 Linus Probert <linus.probert@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_H_
#define CONFIG_H_
// #cmakedefine _WIN32 ${WIN32}
#define GAME_TITLE "BreakHack"
#define MAJOR_VERSION 4
#define MINOR_VERSION 0
#define PATCH_VERSION 3
#define RELEASE_TYPE ""
/* Checksums */
#define SO_LIBSTEAM_CHECKSUM 0x1f5786b
#define DLL_LIBSTEAM_CHECKSUM 0x18dba28
#endif // CONFIG_H_

View File

@ -97,7 +97,7 @@ hiscore_init(void)
static void static void
save_hiscore(double gold, int lvl, int dlvl) save_hiscore(double gold, int lvl, int dlvl)
{ {
const char *query = "INSERT INTO hiscore(time, gold, playerLevel, dungeonLevel) values (datetime('now','+8 years'), ?, ?, ?)"; const char *query = "INSERT INTO hiscore(gold, playerLevel, dungeonLevel) values (?, ?, ?)";
sqlite3_stmt *stmt = db_prepare(db, query); sqlite3_stmt *stmt = db_prepare(db, query);
debug("Saving high score: %dg %dpl %dl", debug("Saving high score: %dg %dpl %dl",

View File

@ -204,6 +204,7 @@ create_treasure(int current_level)
unsigned int value; unsigned int value;
amt = (unsigned int) 1 + get_random(5*current_level) % 40; amt = (unsigned int) 1 + get_random(5*current_level) % 40;
amt = amt == 0 ? 1 : amt;
if (current_level > 9) { if (current_level > 9) {
highest_treasure = PLATINUM; highest_treasure = PLATINUM;

View File

@ -142,4 +142,3 @@ unsigned int linkedlist_size(LinkedList *head)
} }
return 1 + linkedlist_size(head->next); return 1 + linkedlist_size(head->next);
} }

View File

@ -44,4 +44,3 @@ void linkedlist_destroy(LinkedList **head);
unsigned int linkedlist_size(LinkedList *head); unsigned int linkedlist_size(LinkedList *head);
#endif // LINKEDLIST_H_ #endif // LINKEDLIST_H_

View File

@ -58,28 +58,19 @@
#include "sprite_util.h" #include "sprite_util.h"
#include "event.h" #include "event.h"
#include "config.h" #include "config.h"
#include "save.h"
#ifdef STEAM_BUILD #ifdef STEAM_BUILD
#include "checksum.h" #include "checksum.h"
#include "steam/steamworks_api_wrapper.h" #include "steam/steamworks_api_wrapper.h"
#endif // STEAM_BUILD #endif // STEAM_BUILD
#if defined(__amigaos4__)
#define USED __attribute__((used))
#define VSTRING "BreakHack 4.0.3r2 (04.07.2023)"
#define VERSTAG "\0$VER: " VSTRING
static const char *stack USED = "$STACK:102400";
static const char *version USED = VERSTAG;
#endif
static char *artifacts_tooltip[] = { static char *artifacts_tooltip[] = {
"CONGRATULATIONS!", "", "CONGRATULATIONS!", "",
"", "",
" You just picked up your first artifact!", "", " You just picked up your first artifact!", "",
"", "",
" Your current artifacts and corresponding level are", "", " Your current artifacts and corresponding level are", "",
" listed next to your skills.", "", " listed next to your skills." "",
"", "",
"", "",
" Artifacts have mystical effects that improve your offensive", "", " Artifacts have mystical effects that improve your offensive", "",
@ -103,8 +94,8 @@ static char *skills_tooltip[] = {
"", "",
"", "",
" SKILL INFO: SHIFT + <N>", "", " SKILL INFO: SHIFT + <N>", "",
" Where <N> is the number corresponding to", "", " Where <N> is the number corresponding to the skill", "",
" the skill, i.e. 1, 2, 3, 4, 5", "", " Eg. 1, 2, 3, 4, 5", "",
"", "",
" DISABLE TOOLTIPS: CTRL + D", "", " DISABLE TOOLTIPS: CTRL + D", "",
"", "",
@ -429,56 +420,6 @@ goToCharacterMenu(void *unused)
gGameState = CHARACTER_MENU; gGameState = CHARACTER_MENU;
} }
static void
choose_music(void)
{
if (cLevel > (unsigned int) (quickGame ? 11 : 19)) {
mixer_play_music(BOSS_MUSIC0);
} else if (cLevel % (quickGame ? 3 : 5) == 0) {
gui_log("You sense something powerful in the vicinity");
mixer_play_music(BOSS_MUSIC0);
} else {
mixer_play_music(GAME_MUSIC0 + get_random(2));
}
}
static void
continueGame(void *unused)
{
(void) unused;
const Save *save = save_get();
quickGame = save->quickGame;
arcadeGame = save->arcadeGame;
playerClass = save->player_class;
cLevel = save->map_level;
set_random_seed(save->seed);
debug("Loading seed: %d", save->seed);
debug("Loading map level: %d", save->map_level);
gGameState = PLAYING;
if (gPlayer)
player_destroy(gPlayer);
gPlayer = player_create(playerClass, gCamera);
// Load player from save
gPlayer->daggers = save->player_daggers;
gPlayer->xp = save->player_xp;
gPlayer->stateData = save->player_state;
gPlayer->stats = save->player_stats;
gPlayer->stat_data = save->player_player_stats;
gPlayer->potion_sips = save->player_potion_sips;
gPlayer->equipment = save->player_equipment;
gPlayer->gold = save->player_gold;
choose_music();
resetGame();
skillbar_reset(gSkillBar);
gui_clear_message_log();
gui_log("The Dungeon Crawl continues!");
gui_event_message("Welcome back!");
}
static void static void
startRegularGame(void *unused) startRegularGame(void *unused)
{ {
@ -518,7 +459,6 @@ static void
goToMainMenu(void *unused) goToMainMenu(void *unused)
{ {
UNUSED(unused); UNUSED(unused);
save_load();
gui_clear_message_log(); gui_clear_message_log();
gGameState = MENU; gGameState = MENU;
menu_destroy(inGameMenu); menu_destroy(inGameMenu);
@ -534,47 +474,37 @@ static void
goToGameSelectMenu(void *unused) goToGameSelectMenu(void *unused)
{ {
UNUSED(unused); UNUSED(unused);
int item_count = 3; static TEXT_MENU_ITEM menuItems[] = {
#ifdef STEAM_BUILD {
item_count += 1;
#endif
if (save_exists()) {
item_count += 1;
}
TEXT_MENU_ITEM *menuItems = ec_malloc(item_count * sizeof(TEXT_MENU_ITEM));
int i = 0;
if (save_exists()) {
menuItems[i++] = (TEXT_MENU_ITEM) {
"CONTINUE",
"Continue your last session",
continueGame,
};
}
menuItems[i++] = (TEXT_MENU_ITEM) {
"STANDARD GAME", "STANDARD GAME",
"Standard 20 level game, recommended for new players", "Standard 20 level game, recommended for new players",
startRegularGame startRegularGame
}; },
#ifdef STEAM_BUILD #ifdef STEAM_BUILD
menuItems[i++] = (TEXT_MENU_ITEM) { {
"WEEKLY CHALLENGE", "WEEKLY CHALLENGE",
"Quick game with weekly leaderboards at breakhack.net", "Quick game with weekly leaderboards at breakhack.net",
startWeeklyGame startWeeklyGame
}; },
#endif #endif
menuItems[i++] = (TEXT_MENU_ITEM) { {
"QUICK GAME", "QUICK GAME",
"Shorter 12 level game, with more action earlier in the game", "Shorter 12 level game, with more action earlier in the game",
startQuickGame startQuickGame
}; },
menuItems[i++] = (TEXT_MENU_ITEM) { {
"ARCADE GAME", "ARCADE GAME",
"One big level with lots of action", "One big level with lots of action",
startArcadeGame startArcadeGame
}
}; };
menu_create_text_menu(&gameSelectMenu, menuItems, item_count, gRenderer); #ifdef STEAM_BUILD
free(menuItems); int count = 4;
#else
int count = 3;
#endif
menu_create_text_menu(&gameSelectMenu, &menuItems[0], count, gRenderer);
gGameState = GAME_SELECT; gGameState = GAME_SELECT;
} }
@ -761,7 +691,6 @@ init(void)
event_register_listener(on_event_callback); event_register_listener(on_event_callback);
settings_init(); settings_init();
save_init();
hiscore_init(); hiscore_init();
initMainMenu(); initMainMenu();
@ -945,17 +874,17 @@ check_next_level(void)
return; return;
} }
if (tile->levelExit) { if (tile->levelExit) {
mixer_play_effect(NEXT_LEVEL);
++cLevel; ++cLevel;
if (!weeklyGame) { if (cLevel > (unsigned int) (quickGame ? 11 : 19)) {
save_save(get_random_seed(), mixer_play_music(BOSS_MUSIC0);
cLevel, } else if (cLevel % (quickGame ? 3 : 5) == 0) {
quickGame, gui_log("You sense something powerful in the vicinity");
arcadeGame, mixer_play_music(BOSS_MUSIC0);
gPlayer); } else {
mixer_play_music(GAME_MUSIC0 + get_random(2));
} }
mixer_play_effect(NEXT_LEVEL);
choose_music();
if (!gameCompleted()) { if (!gameCompleted()) {
resetGame(); resetGame();
} }
@ -1187,7 +1116,6 @@ run_game(void)
camera_shake(VECTOR2D_RIGHT, 800); camera_shake(VECTOR2D_RIGHT, 800);
gui_log("The dungeon consumed you"); gui_log("The dungeon consumed you");
gui_event_message("You died!"); gui_event_message("You died!");
save_clear();
end_game_details(); end_game_details();
mixer_play_effect(SPLAT); mixer_play_effect(SPLAT);
gGameState = GAME_OVER; gGameState = GAME_OVER;
@ -1421,7 +1349,6 @@ void close(void)
texturecache_close(); texturecache_close();
settings_close(); settings_close();
hiscore_close(); hiscore_close();
save_close();
#ifdef STEAM_BUILD #ifdef STEAM_BUILD
steam_shutdown(); steam_shutdown();
@ -1476,7 +1403,7 @@ int main(int argc, char *argv[])
#endif // STEAM_BUILD #endif // STEAM_BUILD
PHYSFS_init(argv[0]); PHYSFS_init(argv[0]);
#if !defined(DEBUG) && !defined(__amigaos4__) #ifndef DEBUG
PHYSFS_mount("assets.pack", NULL, 0); PHYSFS_mount("assets.pack", NULL, 0);
PHYSFS_mount("data.pack", NULL, 0); PHYSFS_mount("data.pack", NULL, 0);
#else #else
@ -1502,4 +1429,3 @@ int main(int argc, char *argv[])
return 0; return 0;
} }

View File

@ -110,7 +110,7 @@ menu_create_character_selector(void (*onCharacterSelect)(const char *), Camera *
"Commissions/Mage.png" "Commissions/Mage.png"
}; };
static const char *callbackData[] = { static char *callbackData[] = {
"warrior", "warrior",
"rogue", "rogue",
"mage" "mage"

View File

@ -26,8 +26,8 @@
#include "sprite.h" #include "sprite.h"
typedef struct TEXT_MENU_ITEM { typedef struct TEXT_MENU_ITEM {
char *label; char label[20];
char *description; char description[100];
void (*callback)(void*); void (*callback)(void*);
} TEXT_MENU_ITEM; } TEXT_MENU_ITEM;

View File

@ -114,7 +114,7 @@ mixer_toggle_sound(void)
} }
bool bool
mixer_toggle_music(const GameState *state) mixer_toggle_music(GameState *state)
{ {
Settings *settings = settings_get(); Settings *settings = settings_get();
settings->music_enabled = !settings->music_enabled; settings->music_enabled = !settings->music_enabled;

View File

@ -79,7 +79,7 @@ bool
mixer_toggle_sound(void); mixer_toggle_sound(void);
bool bool
mixer_toggle_music(const GameState*); mixer_toggle_music(GameState*);
void void
mixer_play_effect(Fx fx); mixer_play_effect(Fx fx);

View File

@ -474,7 +474,7 @@ monster_coward_walk(Monster *m, RoomMatrix *rm)
} }
static void static void
on_monster_move(Monster *m, const Position *origPos, Map *map, RoomMatrix *rm) on_monster_move(Monster *m, Position *origPos, Map *map, RoomMatrix *rm)
{ {
Position currentTilePos = position_to_matrix_coords(&m->sprite->pos); Position currentTilePos = position_to_matrix_coords(&m->sprite->pos);
Player *player = rm->spaces[rm->playerRoomPos.x][rm->playerRoomPos.y].player; Player *player = rm->spaces[rm->playerRoomPos.x][rm->playerRoomPos.y].player;

View File

@ -181,7 +181,7 @@ on_monster_collision(Player *player,
action_spent(player); action_spent(player);
} }
static void static void
player_pickup_artifacts(Player *player, RoomSpace *space) player_pickup_artifacts(Player *player, RoomSpace *space)
{ {
LinkedList *artifacts = space->artifacts; LinkedList *artifacts = space->artifacts;
@ -191,7 +191,7 @@ player_pickup_artifacts(Player *player, RoomSpace *space)
} }
} }
static void static void
player_interact_objects(Player *player, RoomSpace *space) player_interact_objects(Player *player, RoomSpace *space)
{ {
LinkedList *objects = space->objects; LinkedList *objects = space->objects;
@ -201,7 +201,7 @@ player_interact_objects(Player *player, RoomSpace *space)
} }
} }
static void static void
player_collect_items(Player *player, RoomSpace *space) player_collect_items(Player *player, RoomSpace *space)
{ {
LinkedList *items = space->items; LinkedList *items = space->items;
@ -212,7 +212,7 @@ player_collect_items(Player *player, RoomSpace *space)
} }
} }
static void static void
player_interact_traps_and_pits(Player *player, RoomSpace *space) player_interact_traps_and_pits(Player *player, RoomSpace *space)
{ {
if (space->lethal) { if (space->lethal) {
@ -224,7 +224,7 @@ player_interact_traps_and_pits(Player *player, RoomSpace *space)
} }
} }
static bool static bool
player_has_collided(Player *p, RoomSpace *space) player_has_collided(Player *p, RoomSpace *space)
{ {
if (space->occupied) if (space->occupied)
@ -233,7 +233,7 @@ player_has_collided(Player *p, RoomSpace *space)
return !p->phase_count && space->monster && space->monster->sprite->state != SPRITE_STATE_FALLING; return !p->phase_count && space->monster && space->monster->sprite->state != SPRITE_STATE_FALLING;
} }
static bool static bool
has_collided(Player *player, RoomMatrix *matrix, Vector2d direction) has_collided(Player *player, RoomMatrix *matrix, Vector2d direction)
{ {
Position roomCoord = position_to_room_coords(&player->sprite->pos); Position roomCoord = position_to_room_coords(&player->sprite->pos);
@ -276,7 +276,7 @@ has_collided(Player *player, RoomMatrix *matrix, Vector2d direction)
} }
} }
static void static void
set_clip_for_direction(Player *player, Vector2d *direction) set_clip_for_direction(Player *player, Vector2d *direction)
{ {
if (vector2d_equals(*direction, VECTOR2D_LEFT)) if (vector2d_equals(*direction, VECTOR2D_LEFT))
@ -289,7 +289,7 @@ set_clip_for_direction(Player *player, Vector2d *direction)
player->sprite->clip.y = 0; player->sprite->clip.y = 0;
} }
void void
player_turn(Player *player, Vector2d *direction) player_turn(Player *player, Vector2d *direction)
{ {
set_clip_for_direction(player, direction); set_clip_for_direction(player, direction);
@ -316,7 +316,7 @@ player_turn(Player *player, Vector2d *direction)
} }
} }
static void static void
move(Player *player, RoomMatrix *matrix, Vector2d direction) move(Player *player, RoomMatrix *matrix, Vector2d direction)
{ {
player_turn(player, &direction); player_turn(player, &direction);
@ -343,7 +343,7 @@ move(Player *player, RoomMatrix *matrix, Vector2d direction)
} }
} }
void void
player_sip_health(Player *player) player_sip_health(Player *player)
{ {
bool hasSips = player->class == MAGE ? bool hasSips = player->class == MAGE ?
@ -362,7 +362,7 @@ player_sip_health(Player *player)
} }
} }
static Vector2d static Vector2d
read_direction_from(Input *input) read_direction_from(Input *input)
{ {
if (input_key_is_pressed(input, KEY_LEFT)) if (input_key_is_pressed(input, KEY_LEFT))
@ -377,7 +377,7 @@ read_direction_from(Input *input)
return VECTOR2D_NODIR; return VECTOR2D_NODIR;
} }
static void static void
handle_next_move(UpdateData *data) handle_next_move(UpdateData *data)
{ {
static unsigned int step = 1; static unsigned int step = 1;
@ -417,7 +417,7 @@ handle_next_move(UpdateData *data)
} }
} }
static void static void
use_skill(Skill *skill, SkillData *skillData) use_skill(Skill *skill, SkillData *skillData)
{ {
skill->active = false; skill->active = false;
@ -427,7 +427,7 @@ use_skill(Skill *skill, SkillData *skillData)
skill->resetCountdown = skill->resetTime; skill->resetCountdown = skill->resetTime;
} }
static void static void
check_skill_activation(UpdateData *data) check_skill_activation(UpdateData *data)
{ {
// TODO(Linus): This could be "smarter" // TODO(Linus): This could be "smarter"
@ -468,7 +468,7 @@ check_skill_activation(UpdateData *data)
} }
} }
static bool static bool
check_skill_trigger(UpdateData *data) check_skill_trigger(UpdateData *data)
{ {
Player *player = data->player; Player *player = data->player;
@ -496,7 +496,7 @@ check_skill_trigger(UpdateData *data)
return true; return true;
} }
static void static void
build_sword_animation(Player *p, SDL_Renderer *renderer) build_sword_animation(Player *p, SDL_Renderer *renderer)
{ {
animation_load_texture(p->swordAnimation, "Extras/SwordSwing.png", renderer); animation_load_texture(p->swordAnimation, "Extras/SwordSwing.png", renderer);
@ -514,7 +514,7 @@ build_sword_animation(Player *p, SDL_Renderer *renderer)
p->swordAnimation->sprite->rotationPoint = (SDL_Point) { 16, 16 }; p->swordAnimation->sprite->rotationPoint = (SDL_Point) { 16, 16 };
} }
Player* Player*
player_create(class_t class, Camera *cam) player_create(class_t class, Camera *cam)
{ {
Player *player = malloc(sizeof(Player)); Player *player = malloc(sizeof(Player));
@ -524,7 +524,6 @@ player_create(class_t class, Camera *cam)
player->gold = 500; player->gold = 500;
#else #else
player->daggers = 0; player->daggers = 0;
player->gold = 0;
#endif #endif
player->stat_data.total_steps = 0; player->stat_data.total_steps = 0;
player->stat_data.steps = 0; player->stat_data.steps = 0;
@ -532,6 +531,7 @@ player_create(class_t class, Camera *cam)
player->stat_data.kills = 0; player->stat_data.kills = 0;
player->stat_data.misses = 0; player->stat_data.misses = 0;
player->xp = 0; player->xp = 0;
player->gold = 0;
player->potion_sips = 0; player->potion_sips = 0;
player->phase_count = 0; player->phase_count = 0;
player->class = class; player->class = class;
@ -596,7 +596,7 @@ player_create(class_t class, Camera *cam)
return player; return player;
} }
void void
player_reset_on_levelchange(Player *player) player_reset_on_levelchange(Player *player)
{ {
player->sprite->pos = (Position) { player->sprite->pos = (Position) {
@ -604,8 +604,7 @@ player_reset_on_levelchange(Player *player)
player->equipment.keys = 0; player->equipment.keys = 0;
} }
ExperienceData ExperienceData player_get_xp_data(Player *p)
player_get_xp_data(Player *p)
{ {
ExperienceData data; ExperienceData data;
data.previousLevel = next_level_threshold(p->stats.lvl - 1); data.previousLevel = next_level_threshold(p->stats.lvl - 1);
@ -615,7 +614,7 @@ player_get_xp_data(Player *p)
return data; return data;
} }
void void
player_monster_kill_check(Player *player, Monster *monster) player_monster_kill_check(Player *player, Monster *monster)
{ {
if (!monster) if (!monster)
@ -655,7 +654,7 @@ player_monster_kill_check(Player *player, Monster *monster)
} }
} }
void void
player_hit(Player *p, unsigned int dmg) player_hit(Player *p, unsigned int dmg)
{ {
if (dmg > 0) { if (dmg > 0) {
@ -679,7 +678,7 @@ player_hit(Player *p, unsigned int dmg)
} }
void void
player_render(Player *player, Camera *cam) player_render(Player *player, Camera *cam)
{ {
sprite_set_alpha(player->sprite, player->phase_count ? 150 : 255); sprite_set_alpha(player->sprite, player->phase_count ? 150 : 255);
@ -692,25 +691,25 @@ player_render(Player *player, Camera *cam)
} }
} }
void void
player_render_toplayer(Player *player, Camera *camera) player_render_toplayer(Player *player, Camera *camera)
{ {
animation_render(player->swordAnimation, camera); animation_render(player->swordAnimation, camera);
} }
void void
player_reset_steps(Player *p) player_reset_steps(Player *p)
{ {
p->stat_data.steps = 0; p->stat_data.steps = 0;
} }
static void static void
reset_dagger_skill(Player *p) reset_dagger_skill(Player *p)
{ {
p->skills[3]->resetCountdown = 0; p->skills[3]->resetCountdown = 0;
} }
void void
player_update(UpdateData *data) player_update(UpdateData *data)
{ {
Player *player = data->player; Player *player = data->player;
@ -750,7 +749,7 @@ player_update(UpdateData *data)
animation_update(player->swordAnimation); animation_update(player->swordAnimation);
} }
static void static void
player_reset(Player *player) player_reset(Player *player)
{ {
for (size_t i = 0; i < LAST_ARTIFACT_EFFECT; ++i) for (size_t i = 0; i < LAST_ARTIFACT_EFFECT; ++i)
@ -761,7 +760,7 @@ player_reset(Player *player)
projectile_destroy(linkedlist_pop(&player->projectiles)); projectile_destroy(linkedlist_pop(&player->projectiles));
} }
void void
player_destroy(Player *player) player_destroy(Player *player)
{ {
player_reset(player); player_reset(player);
@ -781,19 +780,19 @@ player_destroy(Player *player)
free(player); free(player);
} }
bool bool
player_turn_over(Player *player) player_turn_over(Player *player)
{ {
return player->stat_data.steps >= player->stats.speed; return player->stat_data.steps >= player->stats.speed;
} }
Uint32 Uint32
player_has_artifact(Player *p, MagicalEffect effect) player_has_artifact(Player *p, MagicalEffect effect)
{ {
return p->equipment.artifacts[effect].level; return p->equipment.artifacts[effect].level;
} }
void void
player_add_artifact(Player *p, Artifact *a) player_add_artifact(Player *p, Artifact *a)
{ {
if (a->price > p->gold) { if (a->price > p->gold) {
@ -823,7 +822,7 @@ player_add_artifact(Player *p, Artifact *a)
p->equipment.hasArtifacts = true; p->equipment.hasArtifacts = true;
} }
void void
player_set_falling(Player *player) player_set_falling(Player *player)
{ {
mixer_play_effect(FALL0 + get_random(1)); mixer_play_effect(FALL0 + get_random(1));

View File

@ -1,166 +0,0 @@
/*
* BreakHack - A dungeone crawler RPG
* Copyright (C) 2018 Linus Probert <linus.probert@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "save.h"
#include "sqlite3.h"
#include "db.h"
#include "defines.h"
#include "util.h"
static sqlite3 *db = NULL;
static bool loaded = false;
static Save save;
static
DbQuery MIGRATE_COMMAND = {
"CREATE TABLE IF NOT EXISTS saves("
"major_version INTEGER, "
"minor_version INTEGER, "
"patch_version INTEGER, "
"arch INTEGER, "
"save BLOB)",
NULL, NULL
};
static
DbQuery CLEAR_SAVE = {
"DELETE FROM saves "
#ifdef _WIN32
"WHERE arch = 1",
#else // _WIN32
"WHERE arch = 2",
#endif // _WIN32
NULL,
NULL };
static void
create_table(void)
{
db_execute(db, &MIGRATE_COMMAND);
}
void
save_load(void)
{
debug("Loading save");
const char *query =
"SELECT save FROM saves "
"WHERE major_version = ? "
"AND minor_version = ? "
"AND patch_version = ? "
#ifdef _WIN32
"AND arch = 1 "
#else // _WIN32
"AND arch = 2 "
#endif // _WIN32
"LIMIT 1";
sqlite3_stmt *stmt = db_prepare(db, query);
sqlite3_bind_int(stmt, 1, MAJOR_VERSION);
sqlite3_bind_int(stmt, 2, MINOR_VERSION);
sqlite3_bind_int(stmt, 3, PATCH_VERSION);
if (SQLITE_ROW == sqlite3_step(stmt)) {
int size = sqlite3_column_bytes(stmt, 0);
debug("Reading save bytes: %d", size);
memcpy(&save, sqlite3_column_blob(stmt, 0), size);
loaded = true;
} else {
loaded = false;
}
sqlite3_finalize(stmt);
}
void
save_init(void)
{
if (!db_open(DB_FILE, &db)) {
db_close(&db);
fatal("Exiting");
}
create_table();
save_load();
}
const Save *
save_get(void)
{
return &save;
}
bool
save_exists(void)
{
return loaded;
}
void
save_save(unsigned int seed,
unsigned int map_level,
bool quickGame,
bool arcadeGame,
Player *player)
{
debug("Saving game, Seed: %d, Map level: %d", seed, map_level);
save_clear();
save.seed = seed;
save.map_level = map_level;
save.quickGame = quickGame;
save.arcadeGame = arcadeGame;
save.player_stats = player->stats;
save.player_daggers = player->daggers;
save.player_gold = player->gold;
save.player_xp = player->xp;
save.player_potion_sips = player->potion_sips;
save.player_player_stats = player->stat_data;
save.player_state = player->stateData;
save.player_class = player->class;
save.player_equipment = player->equipment;
const char *query =
"INSERT INTO saves"
"(major_version, minor_version, patch_version, arch, save) "
"VALUES(?, ?, ?, ?, ?)";
sqlite3_stmt *stmt = db_prepare(db, query);
sqlite3_bind_int(stmt, 1, MAJOR_VERSION);
sqlite3_bind_int(stmt, 2, MINOR_VERSION);
sqlite3_bind_int(stmt, 3, PATCH_VERSION);
#ifdef _WIN32
sqlite3_bind_int(stmt, 4, 1);
#else // _WIN32
sqlite3_bind_int(stmt, 4, 2);
#endif // _WIN32
sqlite3_bind_blob(stmt, 5, &save, sizeof(Save), SQLITE_STATIC);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
void
save_clear(void)
{
db_execute(db, &CLEAR_SAVE);
}
void
save_close(void)
{
db_close(&db);
}

View File

@ -1,67 +0,0 @@
/*
* BreakHack - A dungeone crawler RPG
* Copyright (C) 2018 Linus Probert <linus.probert@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SAVE_H_
#define SAVE_H_
#include <stdbool.h>
#include "player.h"
#include "artifact.h"
typedef struct Save {
int seed;
bool quickGame;
bool arcadeGame;
unsigned int map_level;
unsigned int player_daggers;
unsigned int player_xp;
unsigned int player_potion_sips;
unsigned int potion_sips;
Stats player_stats;
PlayerStatData player_player_stats;
double player_gold;
PlayerStateData player_state;
class_t player_class;
PlayerEquipment player_equipment;
} Save;
void
save_init(void);
void
save_load(void);
const Save *
save_get(void);
bool
save_exists(void);
void
save_save(unsigned int seed,
unsigned int map_level,
bool quickGame,
bool arcadeGame,
Player *player);
void
save_clear(void);
void
save_close(void);
#endif // SAVE_H_

View File

@ -69,13 +69,8 @@ screen_create_credits(SDL_Renderer *renderer)
linkedlist_push(&screen->sprites, credit_txt("liquidityc.github.io", C_WHITE, x + columnOffset, y, renderer)); linkedlist_push(&screen->sprites, credit_txt("liquidityc.github.io", C_WHITE, x + columnOffset, y, renderer));
y += 20; y += 20;
linkedlist_push(&screen->sprites, credit_txt("@LiquidityC", C_WHITE, x + columnOffset, y, renderer)); linkedlist_push(&screen->sprites, credit_txt("@LiquidityC", C_WHITE, x + columnOffset, y, renderer));
y += 20;
linkedlist_push(&screen->sprites, credit_txt("AmigaOS 4", C_YELLOW, x, y, renderer));
y += 20;
linkedlist_push(&screen->sprites, credit_txt("port:", C_YELLOW, x, y, renderer));
linkedlist_push(&screen->sprites, credit_txt("George Sokianos", C_WHITE, x + columnOffset, y, renderer));
y += 40; y += 60;
linkedlist_push(&screen->sprites, credit_txt(" - Graphics -", C_BLUE, x, y, renderer)); linkedlist_push(&screen->sprites, credit_txt(" - Graphics -", C_BLUE, x, y, renderer));
y += 30; y += 30;
linkedlist_push(&screen->sprites, credit_txt("Tileset:", C_YELLOW, x, y, renderer)); linkedlist_push(&screen->sprites, credit_txt("Tileset:", C_YELLOW, x, y, renderer));
@ -214,4 +209,3 @@ screen_destroy(Screen *screen)
sprite_destroy(linkedlist_pop(&screen->sprites)); sprite_destroy(linkedlist_pop(&screen->sprites));
free(screen); free(screen);
} }

View File

@ -888,11 +888,10 @@ skill_blink(Skill *skill, SkillData *data)
// Find collider // Find collider
destination.x += (int) data->direction.x; destination.x += (int) data->direction.x;
destination.y += (int) data->direction.y; destination.y += (int) data->direction.y;
RoomSpace *space = &matrix->spaces[destination.x][destination.y];
Position lastAvailableDest = playerStartPos; Position lastAvailableDest = playerStartPos;
while (position_in_roommatrix(&destination)) while (position_in_roommatrix(&destination))
{ {
RoomSpace *space = &matrix->spaces[destination.x][destination.y];
if (space->occupied) { if (space->occupied) {
break; break;
} }
@ -901,9 +900,10 @@ skill_blink(Skill *skill, SkillData *data)
lastAvailableDest = destination; lastAvailableDest = destination;
} }
perform_pickups_for_space(space, player);
destination.x += (int) data->direction.x; destination.x += (int) data->direction.x;
destination.y += (int) data->direction.y; destination.y += (int) data->direction.y;
space = &matrix->spaces[destination.x][destination.y];
perform_pickups_for_space(space, player);
} }
destination = lastAvailableDest; destination = lastAvailableDest;

View File

@ -64,7 +64,7 @@ load_texture(SkillBar *bar, const char *path, SDL_Renderer *renderer)
s->dim = (Dimension) { 8, 8 }; s->dim = (Dimension) { 8, 8 };
s->fixed = true; s->fixed = true;
sprite_load_text_texture(s, "GUI/SDS_8x8.ttf", 0, 8, 0); sprite_load_text_texture(s, "GUI/SDS_8x8.ttf", 0, 8, 0);
m_sprintf(buffer, 4, "%u", i + 1); m_sprintf(buffer, 4, "%u", i + 1 < 10 ? i + 1 : 0);
texture_load_from_text(s->textures[0], buffer, C_YELLOW, C_BLACK, renderer); texture_load_from_text(s->textures[0], buffer, C_YELLOW, C_BLACK, renderer);
linkedlist_append(&bar->sprites, s); linkedlist_append(&bar->sprites, s);
} }

View File

@ -160,11 +160,13 @@ texture_load_from_text(Texture *t,
{ {
SDL_Surface *bg_surface = NULL; SDL_Surface *bg_surface = NULL;
SDL_Surface *fg_surface = NULL; SDL_Surface *fg_surface = NULL;
fg_surface = TTF_RenderText_Blended(t->font, text, c);
if (t->outlineFont) { if (t->outlineFont) {
bg_surface = TTF_RenderText_Blended(t->outlineFont, text, oc); bg_surface = TTF_RenderText_Blended(t->outlineFont, text, oc);
fg_surface = TTF_RenderText_Blended(t->font, text, c);
}
else {
fg_surface = TTF_RenderText_Solid(t->font, text, c);
} }
SDL_Surface *surface = fg_surface; SDL_Surface *surface = fg_surface;
if (bg_surface) { if (bg_surface) {
int outline = TTF_GetFontOutline(t->outlineFont); int outline = TTF_GetFontOutline(t->outlineFont);
@ -285,4 +287,3 @@ void texture_destroy(Texture *texture)
TTF_CloseFont(texture->outlineFont); TTF_CloseFont(texture->outlineFont);
free(texture); free(texture);
} }

View File

@ -51,6 +51,8 @@ texturecache_add(const char *path)
texture_load_from_file(tc->texture, path, renderer); texture_load_from_file(tc->texture, path, renderer);
ht_set(textures, path, tc); ht_set(textures, path, tc);
debug("Cached texture: %s", path); debug("Cached texture: %s", path);
} else {
debug("Retrieved cached texture: %s", path);
} }
return tc->texture; return tc->texture;

View File

@ -27,12 +27,16 @@ vector2d_to_direction(const Vector2d *vec)
if (new.x > 0) if (new.x > 0)
new.x = 1; new.x = 1;
else if (new.x < 0) else if (new.x == 0)
new.x = 0;
else
new.x = -1; new.x = -1;
if (new.y > 0) if (new.y > 0)
new.y = 1; new.y = 1;
else if (new.y < 0) else if (new.y == 0)
new.y = 0;
else
new.y = -1; new.y = -1;
return new; return new;