Compare commits

...

25 Commits

Author SHA1 Message Date
George Sokianos c076098ad9 Fixed hiscore date and compiled with latest SDL 2023-07-04 20:52:03 +01:00
George Sokianos 5dd814e452 Prepare first release 2022-12-21 17:46:45 +00:00
George Sokianos 43c8bd610f Some more fixes and minor changes 2022-09-10 11:57:02 +01:00
George Sokianos 6a78b47ae6 Cleaned up the makefile.os4 2022-09-09 23:38:37 +01:00
George Sokianos 2b1fd35298 Added makefile for OS4 and some fixes to make texts show right 2022-08-31 22:39:46 +01:00
lprobert fc6bb50460
Fixes a bunch of lint errors 2022-08-24 16:00:13 +02:00
lprobert 2aba6c4338
Adds setup/teardown to Makefile 2022-08-24 15:26:02 +02:00
Linus Probert 39bc060a77
Adds maintenance badge 2021-10-05 09:28:01 +02:00
Linus Probert abef4ed9a6
Patches all CMakeLists.txt to new CMake version 2021-10-05 09:15:29 +02:00
Linus Probert 26c5448a30
Fixes linting and some lint warnings 2020-07-11 10:16:57 +02:00
Linus Probert 1a559741e2
Create FUNDING.yml 2020-05-27 21:25:12 +02:00
Linus Probert 38207e03d1 Patch version raised to 3 2020-03-04 21:51:31 +01:00
Linus Probert e636ec1e53 Don't delete saves from other architectures on death 2020-03-04 21:50:51 +01:00
417e7d3cc8 Patch version raised to 2 2020-03-04 17:06:57 +01:00
Linus Probert 4edeb17ddc Fixes cross save problems due to architecture differences 2020-03-04 17:03:02 +01:00
Linus Probert de770ccc9f Patch version raised to 1 2020-03-04 12:50:39 +01:00
Linus Probert 8a347790c1 Update major version 2020-03-04 12:50:20 +01:00
Linus Probert 5a9335576a Completes game saving and resuming 2020-03-03 23:50:11 +01:00
Linus Probert b385f6e73a Don't want to store compile commands like this 2020-03-03 13:57:44 +01:00
Linus Probert 4106a856fc Begin an idea for "continue game" functionality 2020-03-03 13:07:32 +01:00
Linus Probert 8221304df8 Fixes some odd indentations 2019-12-03 15:18:47 +01:00
Linus Probert 4ceb82f171 Fixes MAGICAL achievemnt 2019-06-10 11:37:13 +02:00
Linus Probert 9e5e1d0a1e Patch version raised to 2 2019-06-10 11:20:24 +02:00
Linus Probert 6d323ca500 Adds steam achievements and LB for the Mage class 2019-06-10 11:19:40 +02:00
Linus Probert 9aefed0d00 Adds an dev env setup script 2019-06-10 09:43:39 +02:00
46 changed files with 1154 additions and 187 deletions

12
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,12 @@
# 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']

6
.gitignore vendored
View File

@ -14,4 +14,8 @@
*~
/steam_appid.txt
/*.so
/breakhack*.run
/breakhack*.run
compile_commands.json
*.o
breakhack

View File

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

View File

@ -7,12 +7,12 @@ release:
.PHONY: release
clean:
@make clean -sC _build/debug
@make clean -sC _build/release
@make -sC _build/debug clean
@make -sC _build/release clean
.PHONY: clean
test:
@make test -sC _build/debug
@make -sC _build/debug test
.PHONY: test
run: $(all)
@ -24,9 +24,27 @@ playtest: $(all)
.PHONY: playtest
lint:
@make lint -sC _build/debug
@make -sC _build/debug lint
.PHONY: lint
package:
@make package -sC _build/release
@make -sC _build/release 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

503
Makefile.os4 Normal file
View File

@ -0,0 +1,503 @@
#
# 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,3 +1,4 @@
[![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://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)

48
README_Amiga.md Normal file
View File

@ -0,0 +1,48 @@
# 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

BIN
README_Amiga.md.info Normal file

Binary file not shown.

View File

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

View File

@ -0,0 +1,2 @@
6d323ca Adds steam achievements and LB for the Mage class
9aefed0 Adds an dev env setup script

View File

View File

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

View File

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

View File

@ -0,0 +1,12 @@
#!/bin/sh
mkdir -p _build/debug
mkdir -p _build/release
cd _build/debug
cmake -DCMAKE_BUILD_TYPE=Debug ../..
cd -
cd _build/release
cmake -DCMAKE_BUILD_TYPE=Release ../..
cd -

View File

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

View File

@ -9,7 +9,7 @@
# compile, using preprocessor checks for platform-specific bits instead of
# testing in here.
cmake_minimum_required(VERSION 2.8.4)
cmake_minimum_required(VERSION 3.6)
project(PhysicsFS)
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)
return;
if (!t->dead && !timer_started(t->timer))
if (!timer_started(t->timer))
timer_start(t->timer);
if (timer_get_ticks(t->timer) < 500) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

36
src/config.h Normal file
View File

@ -0,0 +1,36 @@
/*
* 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
save_hiscore(double gold, int lvl, int dlvl)
{
const char *query = "INSERT INTO hiscore(gold, playerLevel, dungeonLevel) values (?, ?, ?)";
const char *query = "INSERT INTO hiscore(time, gold, playerLevel, dungeonLevel) values (datetime('now','+8 years'), ?, ?, ?)";
sqlite3_stmt *stmt = db_prepare(db, query);
debug("Saving high score: %dg %dpl %dl",

View File

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

View File

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

View File

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

View File

@ -58,19 +58,28 @@
#include "sprite_util.h"
#include "event.h"
#include "config.h"
#include "save.h"
#ifdef STEAM_BUILD
#include "checksum.h"
#include "steam/steamworks_api_wrapper.h"
#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[] = {
"CONGRATULATIONS!", "",
"",
" You just picked up your first artifact!", "",
"",
" 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", "",
@ -94,8 +103,8 @@ static char *skills_tooltip[] = {
"",
"",
" SKILL INFO: SHIFT + <N>", "",
" Where <N> is the number corresponding to the skill", "",
" Eg. 1, 2, 3, 4, 5", "",
" Where <N> is the number corresponding to", "",
" the skill, i.e. 1, 2, 3, 4, 5", "",
"",
" DISABLE TOOLTIPS: CTRL + D", "",
"",
@ -237,7 +246,7 @@ bool initSDL(void)
m_sprintf(title_buffer, 100, "%s %d.%d.%d %s", GAME_TITLE, MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION, RELEASE_TYPE);
gWindow = SDL_CreateWindow(title_buffer,
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
(int)(SCREEN_WIDTH * renderScale),
(int)(SCREEN_HEIGHT * renderScale),
SDL_WINDOW_SHOWN);
@ -272,7 +281,7 @@ bool initSDL(void)
debug("Disabling text input");
SDL_StopTextInput();
}
return true;
}
@ -420,6 +429,56 @@ goToCharacterMenu(void *unused)
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
startRegularGame(void *unused)
{
@ -459,6 +518,7 @@ static void
goToMainMenu(void *unused)
{
UNUSED(unused);
save_load();
gui_clear_message_log();
gGameState = MENU;
menu_destroy(inGameMenu);
@ -474,37 +534,47 @@ static void
goToGameSelectMenu(void *unused)
{
UNUSED(unused);
static TEXT_MENU_ITEM menuItems[] = {
{
"STANDARD GAME",
"Standard 20 level game, recommended for new players",
startRegularGame
},
int item_count = 3;
#ifdef STEAM_BUILD
{
"WEEKLY CHALLENGE",
"Quick game with weekly leaderboards at breakhack.net",
startWeeklyGame
},
item_count += 1;
#endif
{
"QUICK GAME",
"Shorter 12 level game, with more action earlier in the game",
startQuickGame
},
{
"ARCADE GAME",
"One big level with lots of action",
startArcadeGame
}
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 20 level game, recommended for new players",
startRegularGame
};
#ifdef STEAM_BUILD
menuItems[i++] = (TEXT_MENU_ITEM) {
"WEEKLY CHALLENGE",
"Quick game with weekly leaderboards at breakhack.net",
startWeeklyGame
};
#endif
menuItems[i++] = (TEXT_MENU_ITEM) {
"QUICK GAME",
"Shorter 12 level game, with more action earlier in the game",
startQuickGame
};
menuItems[i++] = (TEXT_MENU_ITEM) {
"ARCADE GAME",
"One big level with lots of action",
startArcadeGame
};
#ifdef STEAM_BUILD
int count = 4;
#else
int count = 3;
#endif
menu_create_text_menu(&gameSelectMenu, &menuItems[0], count, gRenderer);
menu_create_text_menu(&gameSelectMenu, menuItems, item_count, gRenderer);
free(menuItems);
gGameState = GAME_SELECT;
}
@ -691,6 +761,7 @@ init(void)
event_register_listener(on_event_callback);
settings_init();
save_init();
hiscore_init();
initMainMenu();
@ -851,7 +922,7 @@ end_game_details(void)
{
gui_log("You earned %.2f gold", gPlayer->gold);
gui_event_message("You earned %.2f gold", gPlayer->gold);
if (hiscore_get_top_gold() < gPlayer->gold) {
gui_event_message("NEW HIGHSCORE");
gui_log("NEW HIGHSCORE");
@ -874,17 +945,17 @@ check_next_level(void)
return;
}
if (tile->levelExit) {
mixer_play_effect(NEXT_LEVEL);
++cLevel;
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));
if (!weeklyGame) {
save_save(get_random_seed(),
cLevel,
quickGame,
arcadeGame,
gPlayer);
}
mixer_play_effect(NEXT_LEVEL);
choose_music();
if (!gameCompleted()) {
resetGame();
}
@ -1086,10 +1157,13 @@ register_scores(void)
steam_set_achievement(ROGUE_LIKE);
steam_register_rogue_score((int) gPlayer->gold,
(int32_t*) &details, 1);
}
else if (gPlayer->class == WARRIOR) {
} else if (gPlayer->class == WARRIOR) {
steam_register_warrior_score((int) gPlayer->gold,
(int32_t*) &details, 1);
} else if (gPlayer->class == MAGE) {
steam_set_achievement(MAGICAL);
steam_register_mage_score((int) gPlayer->gold,
(int32_t*) &details, 1);
}
}
#endif
@ -1113,6 +1187,7 @@ run_game(void)
camera_shake(VECTOR2D_RIGHT, 800);
gui_log("The dungeon consumed you");
gui_event_message("You died!");
save_clear();
end_game_details();
mixer_play_effect(SPLAT);
gGameState = GAME_OVER;
@ -1346,6 +1421,7 @@ void close(void)
texturecache_close();
settings_close();
hiscore_close();
save_close();
#ifdef STEAM_BUILD
steam_shutdown();
@ -1380,7 +1456,7 @@ validate_lib_checksum(void)
fatal("Unable to open %s for reading\n", file);
}
unsigned calculated = checksum_fp(fp);
unsigned calculated = checksum_fp(fp);
fclose(fp);
if (calculated != expected) {
@ -1400,7 +1476,7 @@ int main(int argc, char *argv[])
#endif // STEAM_BUILD
PHYSFS_init(argv[0]);
#ifndef DEBUG
#if !defined(DEBUG) && !defined(__amigaos4__)
PHYSFS_mount("assets.pack", NULL, 0);
PHYSFS_mount("data.pack", NULL, 0);
#else
@ -1416,7 +1492,7 @@ int main(int argc, char *argv[])
return 1;
if (settings_get()->fullscreen_enabled) {
// Game starts in windowed mode so this will
// Game starts in windowed mode so this will
// change to fullscreen
toggle_fullscreen();
}
@ -1426,3 +1502,4 @@ int main(int argc, char *argv[])
return 0;
}

View File

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

View File

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

View File

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

View File

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

View File

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

166
src/save.c Normal file
View File

@ -0,0 +1,166 @@
/*
* 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);
}

67
src/save.h Normal file
View File

@ -0,0 +1,67 @@
/*
* 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,8 +69,13 @@ screen_create_credits(SDL_Renderer *renderer)
linkedlist_push(&screen->sprites, credit_txt("liquidityc.github.io", C_WHITE, x + columnOffset, y, renderer));
y += 20;
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 += 60;
y += 40;
linkedlist_push(&screen->sprites, credit_txt(" - Graphics -", C_BLUE, x, y, renderer));
y += 30;
linkedlist_push(&screen->sprites, credit_txt("Tileset:", C_YELLOW, x, y, renderer));
@ -209,3 +214,4 @@ screen_destroy(Screen *screen)
sprite_destroy(linkedlist_pop(&screen->sprites));
free(screen);
}

View File

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

View File

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

View File

@ -12,6 +12,7 @@ static const char *LB_HIGHSCORE = "Highscore";
static const char *LB_QUICKPLAY_HIGHSCORE = "Quickplay Highscore";
static const char *LB_ARCADE_HIGHSCORE = "Arcade Highscore";
static const char *LB_ROGUE_HIGHSCORE = "Rogue Highscore";
static const char *LB_MAGE_HIGHSCORE = "Mage Highscore";
static const char *LB_WARRIOR_HIGHSCORE = "Warrior Highscore";
static const char *LB_KILLS = "Most Kills";
static char *lb_weekly = NULL;
@ -22,9 +23,10 @@ static Achievement g_Achievements[] = {
_ACH_ID(LIGHTS_ON, "Omnidirectional light"),
_ACH_ID(BACK_TO_WORK, "Back to work"),
_ACH_ID(DRAGON_SLAYER, "Platinum dragon slayer"),
_ACH_ID(ROGUE_LIKE, "Rogue-like")
_ACH_ID(ROGUE_LIKE, "Rogue-like"),
_ACH_ID(MAGICAL, "Magical")
};
static Uint8 numAchievements = 6;
static Uint8 numAchievements = 7;
static bool m_Initiated = false;
static bool m_bStatsReceived = false;
@ -35,6 +37,7 @@ static Sint64 m_hArcadeHighscoreLeaderboard = 0;
static Sint64 m_hKillsLeaderboard = 0;
static Sint64 m_hRogueHighscore = 0;
static Sint64 m_hWarriorHighscore = 0;
static Sint64 m_hMageHighscore = 0;
static Sint64 m_hWeeklyHighscore = 0;
static Timer *requestDataTimer = NULL;
@ -70,6 +73,8 @@ leaderboard_received(Sint64 hLeaderboard, const char *name)
m_hKillsLeaderboard = hLeaderboard;
else if (strcmp(LB_ROGUE_HIGHSCORE, name) == 0)
m_hRogueHighscore = hLeaderboard;
else if (strcmp(LB_MAGE_HIGHSCORE, name) == 0)
m_hMageHighscore = hLeaderboard;
else if (strcmp(LB_WARRIOR_HIGHSCORE, name) == 0)
m_hWarriorHighscore = hLeaderboard;
else if (strcmp(LB_QUICKPLAY_HIGHSCORE, name) == 0)
@ -124,6 +129,8 @@ request_data_queue_run(void)
c_SteamUserStats_FindLeaderboard(LB_KILLS);
else if (!m_hRogueHighscore)
c_SteamUserStats_FindLeaderboard(LB_ROGUE_HIGHSCORE);
else if (!m_hMageHighscore)
c_SteamUserStats_FindLeaderboard(LB_MAGE_HIGHSCORE);
else if (!m_hWarriorHighscore)
c_SteamUserStats_FindLeaderboard(LB_WARRIOR_HIGHSCORE);
else if (!m_hWeeklyHighscore)
@ -183,6 +190,13 @@ void steam_register_arcade_score(Sint32 nScore, const int32_t * details, int32_t
c_SteamUserStats_UploadLeaderboardScore(m_hArcadeHighscoreLeaderboard, nScore, details, nDetails);
}
void steam_register_mage_score(Sint32 nScore, const int32_t * details, int32_t nDetails)
{
if (!m_hMageHighscore)
return;
c_SteamUserStats_UploadLeaderboardScore(m_hMageHighscore, nScore, details, nDetails);
}
void steam_register_warrior_score(Sint32 nScore, const int32_t * details, int32_t nDetails)
{
if (!m_hWarriorHighscore)

View File

@ -13,7 +13,8 @@ typedef enum EAchievement
BUGGFIXER = 7,
BUGGCREATOR = 8,
ROGUE_LIKE = 9,
ARCADE_HACK = 10
MAGICAL = 10,
ARCADE_HACK = 11
} EAchievement;
@ -45,6 +46,8 @@ void steam_register_weekly_score(Sint32 nScore, const int32_t *details, int32_t
void steam_register_arcade_score(Sint32 nScore, const int32_t *details, int32_t nDetails);
void steam_register_mage_score(Sint32 nScore, const int32_t *details, int32_t nDetails);
void steam_register_warrior_score(Sint32 nScore, const int32_t *details, int32_t nDetails);
void steam_register_rogue_score(Sint32 nScore, const int32_t *details, int32_t nDetails);

View File

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

View File

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

View File

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