44 Commits

Author SHA1 Message Date
4b1a80ec40 Cleaned up Tileson and TilemapComponent 2023-07-26 15:47:36 -04:00
1a0bd2ea4e Tileson fully refactored into engine 2023-07-26 15:13:45 -04:00
b4b83f098d TileSet Parsing and Setup Refactored 2023-07-25 16:48:12 -04:00
b15316c40e More work on Tileson integration 2023-07-24 13:41:02 -04:00
bbab18d361 Tileson working with tsj tileset 2023-07-21 00:08:23 -04:00
9432b68efe added tileson still debugging 2023-07-20 12:31:37 -04:00
352034790c integrating tileson with the project for tmx parsing 2023-07-19 17:10:10 -04:00
8aa79741e4 Cleanup on aisle everywhere 2023-07-19 13:16:14 -04:00
8d6fe8556c Kdevelop included, libtmxparser excluded 2023-07-15 18:05:24 -04:00
e4c270a81d Kdevelop included, libtmxparser excluded 2023-07-15 18:05:24 -04:00
fd17014eef SDL libs back to dynamic, libtmxparser fixed 2023-07-15 18:05:23 -04:00
391fcedc37 libSDL2 static build and link 2022-09-30 16:09:12 -04:00
1dec4347e0 Built SDL2_image and _mixer static 2022-09-30 15:49:16 -04:00
e2605bf6c1 Changed to static libraries for libTmxParser 2022-07-18 18:09:09 -04:00
21c30b7f52 Before changing to static libraries 2022-07-04 09:42:42 -04:00
70402c5382 udpated SDL_GetTicks() to SDL_GetTicks64() 2022-05-30 14:02:21 -04:00
4aa7fe1692 predictCollisions working in debug mode 2022-05-14 17:52:05 -04:00
36adcdeac7 predictCollisions func added to Game.cpp 2022-05-13 23:20:08 -04:00
e28a9cebdb TileMap Debug Colliders Drawing 2022-05-01 17:35:58 -04:00
b94c2cff38 Debug menu scale fixed, Player Tile Position 2022-05-01 15:38:55 -04:00
fb20b8d868 Camera and Tilemaps fixed at 1x res 2022-05-01 11:00:51 -04:00
9f4007bb79 TileMaps and camera tuning 2022-04-29 21:31:34 -04:00
bc4262d552 Continued work on tilemaps/debug 2022-04-08 18:19:27 -04:00
2331110c71 TileMaps and cam debug added 2022-04-07 23:20:19 -04:00
c8aae59f26 TileMaps now render and move with camera 2022-04-04 18:16:20 -04:00
871e6d19c6 TileMaps now render each row correctly 2022-03-27 23:59:12 -04:00
72b4ac9229 TileMapComponent now takes a TMX to render tilemap 2022-03-24 23:34:17 -04:00
dc43e59ff6 halsafar/libtmx-parser added to project 2022-03-21 15:26:13 -04:00
66b8de6f40 Cleaned up UITextComponent and SpriteComponent 2022-02-06 20:12:12 -05:00
b5639e4f41 Basic WordWrap for UIText feature 2022-02-04 17:08:01 -05:00
72a941810d New UITextComponent implemented 2022-02-03 17:59:50 -05:00
40095cb8b7 Minor tweaks for debug text 2022-01-02 14:05:52 -05:00
af393e8acb a,d keys implemented and screen for 1080p 2021-12-30 13:42:55 -05:00
b9e9c04235 UI tweaks for more layers and debug 2021-11-07 20:47:58 -05:00
0cc31be0c7 Fixed Gravity to scale correctly with global scale 2021-11-05 21:54:18 -04:00
bd0c49b3ae Collider debug boxes with SDL_Rect 2021-11-03 17:37:56 -04:00
165052a617 Worked on Colliders 2021-08-25 17:11:46 -04:00
1e5beb5b88 ColliderComponent hidden prop 2021-08-16 17:36:21 -04:00
8713b76f83 added hidden property to Collider Component 2021-08-16 17:29:50 -04:00
586a774cde cleanup on aisle everywhere 2021-08-02 18:18:04 -04:00
fde99ef76b added Nic's collision pseudocode 2021-08-02 17:46:06 -04:00
363f28cb9c Fixed UIText class for non-uniform scale 2021-07-29 08:21:45 -04:00
31e16585d1 added a debug file with console output 2021-07-10 21:24:44 -04:00
10e5be7a65 Working on Collisions 2021-07-10 21:23:45 -04:00
51 changed files with 11589 additions and 451 deletions

10
.gitignore vendored
View File

@ -1,6 +1,9 @@
# ---> KDevelop4
*.kdev4
.kdev4/
#*.kdev4
#.kdev4/
# ---> build artifacts
build/*
# ---> C++
# Prerequisites
@ -89,3 +92,6 @@ Module.symvers
Mkfile.old
dkms.conf
# CMake artifacts
CMakeCache.txt

View File

@ -0,0 +1,62 @@
[Buildset]
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x18\x00B\x00e\x00a\x00g\x00l\x00e\x00R\x00e\x00s\x00c\x00u\x00e)
[CMake]
Build Directory Count=1
Current Build Directory Index-Host System=0
[CMake][CMake Build Directory 0]
Build Directory Path=/home/ayoungblood/BeagleRescue.git/build
Build Type=Release
CMake Binary=/usr/bin/cmake
CMake Executable=/usr/bin/cmake
Environment Profile=
Extra Arguments=
Install Directory=/usr/local
Runtime=Host System
[CustomDefinesAndIncludes][ProjectPath0]
Path=.
parseAmbiguousAsCPP=true
parserArguments=-ferror-limit=100 -fspell-checking -Wdocumentation -Wunused-parameter -Wunreachable-code -Wall -std=c++17
parserArgumentsC=-ferror-limit=100 -fspell-checking -Wdocumentation -Wunused-parameter -Wunreachable-code -Wall -std=c99
parserArgumentsCuda=-ferror-limit=100 -fspell-checking -Wdocumentation -Wunused-parameter -Wunreachable-code -Wall -std=c++11
parserArgumentsOpenCL=-ferror-limit=100 -fspell-checking -Wdocumentation -Wunused-parameter -Wunreachable-code -Wall -cl-std=CL1.1
[CustomDefinesAndIncludes][ProjectPath0][Compiler]
Name=GCC
[Launch]
Launch Configurations=Launch Configuration 0
[Launch][Launch Configuration 0]
Configured Launch Modes=execute,debug
Configured Launchers=nativeAppLauncher,lldb
Name=BeagleRescue
Type=Native Application
[Launch][Launch Configuration 0][Data]
Arguments=
Break on Start=false
Dependencies=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x00)
Dependency Action=Nothing
EnvironmentGroup=
Executable=file:///home/ayoungblood/BeagleRescue.git/build/BeagleRescue
External Terminal=konsole --noclose --workdir %workdir -e %exe
Kill Before Executing Again=4194304
LLDB Arguments=
LLDB Config Script=
LLDB Environment=
LLDB Executable=
LLDB Inherit System Env=true
LLDB Remote Debugging=false
LLDB Remote Path=
LLDB Remote Server=
Project Target=BeagleRescue,BeagleRescue
Start With=ApplicationOutput
Use External Terminal=false
Working Directory=file:///home/ayoungblood/BeagleRescue.git
isExecutable=true
[Project]
VersionControlSupport=kdevgit

51
.kdev4/BeagleRescue.kdev4 Normal file
View File

@ -0,0 +1,51 @@
[Buildset]
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x18\x00B\x00e\x00a\x00g\x00l\x00e\x00R\x00e\x00s\x00c\x00u\x00e)
[CMake]
Build Directory Count=2
Current Build Directory Index-Host System=0
Temporary Build Directory Index=1
[CMake][CMake Build Directory 0]
Build Directory Path=/home/ayoungblood/projects/BeagleRescue/build
Build Type=Release
CMake Binary=/usr/bin/cmake
CMake Executable=/usr/bin/cmake
Environment Profile=
Extra Arguments=
Install Directory=/usr/local
Runtime=Host System
[CMake][CMake Build Directory 1]
Build Directory Path=/home/ayoungblood/Projects/BeagleRescue/build
Build Type=Release
CMake Binary=/usr/bin/cmake
CMake Executable=/usr/bin/cmake
Environment Profile=
Extra Arguments=
Install Directory=
[Launch]
Launch Configurations=Launch Configuration 0
[Launch][Launch Configuration 0]
Configured Launch Modes=execute
Configured Launchers=nativeAppLauncher
Name=BeagleRescue
Type=Native Application
[Launch][Launch Configuration 0][Data]
Arguments=
Dependencies=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x00)
Dependency Action=Nothing
EnvironmentGroup=
Executable=file:///home/ayoungblood/Projects/BeagleRescue
External Terminal=konsole --noclose --workdir %workdir -e %exe
Kill Before Executing Again=4194304
Project Target=BeagleRescue,BeagleRescue
Use External Terminal=false
Working Directory=file:///home/ayoungblood/projects/BeagleRescue
isExecutable=true
[Project]
VersionControlSupport=kdevgit

4
BeagleRescue.git.kdev4 Normal file
View File

@ -0,0 +1,4 @@
[Project]
CreatedFrom=CMakeLists.txt
Manager=KDevCMakeManager
Name=BeagleRescue

5
BeagleRescue.kdev4 Normal file
View File

@ -0,0 +1,5 @@
[Project]
CreatedFrom=CMakeLists.txt
Manager=KDevCMakeManager
Name=BeagleRescue
VersionControl=%{VERSIONCONTROLPLUGIN}

58
CMakeLists.txt Normal file
View File

@ -0,0 +1,58 @@
cmake_minimum_required(VERSION 3.25.1)
project(BeagleRescue VERSION 1.0.0 )
#set(CMAKE_CXX_STANDARD 11) # old requirements
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to be used") # new requirements for tileson
set(CMAKE_CXX_REQUIRED ON)
include(FetchContent)
include(FindPkgConfig)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image>=2.0.0)
PKG_SEARCH_MODULE(SDL2MIXER REQUIRED SDL2_mixer>=2.0.0)
# Point to our own cmake modules
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2)
# Find SDL2
# find_package(SDL2 REQUIRED)
#find_file(SDL2_INCLUDE_DIR NAME SDL.h HINTS SDL2)
#find_library(SDL2_LIBRARY NAME SDL2)
#find_package(SDL2_image REQUIRED)
#find_package(SDL2_mixer REQUIRED)
#add_subdirectory(libtmx-parser)
#add_library(libtmx-parser)
# target_sources(libtmx-parser
# PRIVATE
# $(CMAKE_CURRENT_LIST_DIR)/libtmx-parser/src/base64.h
# $(CMAKE_CURRENT_LIST_DIR)/libtmx-parser/src/base64.cpp
# $(CMAKE_CURRENT_LIST_DIR)/libtmx-parser/src/tmxparser.cpp
# PUBLIC
# $(CMAKE_CURRENT_LIST_DIR)/libtmx-parser/src/tmxparser.h
# )
#set(TMXPARSER "tmxparser")
#FetchContent_Declare(
# tmxparser
# GIT_REPOSITORY "https://github.com/halsafar/libtmx-parser"
# GIT_TAG "master"
# )
#FetchContent_MakeAvailable(tmxparser)
# Add global definitions
add_definitions("-Wall")
include_directories(${PROJECT_NAME} ${SDL2_INCLUDE_DIRS} ${SDL2IMAGE_INCLUDE_DIRS} ${SDL2MIXER_INCLUDE_DIRS})
#add_custom_target(${TMXPARSER})
# add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libtmx-parser/)
file(GLOB_RECURSE CSOURCES src/cjson/*.c)
file(GLOB_RECURSE CPPSOURCES src/*.cpp)
# file(GLOB_RECURSE TMXSOURCES libtmx-parser/src/*.cpp)
#add_dependencies(${PROJECT_NAME} ${TMXPARSER})
add_executable(${PROJECT_NAME} ${CSOURCES} ${CPPSOURCES})
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
target_link_libraries(${PROJECT_NAME} PRIVATE ${SDL2_LIBRARIES} ${SDL2IMAGE_LIBRARIES} ${SDL2MIXER_LIBRARIES})

624
Makefile
View File

@ -1,46 +1,608 @@
# Special Thanks to Job Vranish at Atomic Object for the base Makefile that was modified slightly to work with this project's needs
# https://spin.atomicobject.com/2016/08/26/makefile-c-projects/
TARGET_EXEC ?= BeagleRescue
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.25
BUILD_DIR ?= ./build
SRC_DIRS ?= ./src
# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *.s)
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
#=============================================================================
# Special targets provided by cmake.
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP -w
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
LINKER_FLAGS = -lSDL2 -lSDL2_image -lSDL2_mixer
# Disable VCS-based implicit rules.
% : %,v
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
# $(CC) $(OBJS) -o $@ $(LDFLAGS)
$(CXX) $(OBJS) $(LINKER_FLAGS) -o $@
# Disable VCS-based implicit rules.
% : RCS/%
# assembly
$(BUILD_DIR)/%.s.o: %.s
$(MKDIR_P) $(dir $@)
$(AS) $(ASFLAGS) -c $< -o $@
# Disable VCS-based implicit rules.
% : RCS/%,v
# c source
$(BUILD_DIR)/%.c.o: %.c
$(MKDIR_P) $(dir $@)
$(CXX) $(CPPFLAGS) $(CFLAGS) $(LINKER_FLAGS) -c $< -o $@
# Disable VCS-based implicit rules.
% : SCCS/s.%
# c++ source
$(BUILD_DIR)/%.cpp.o: %.cpp
$(MKDIR_P) $(dir $@)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LINKER_FLAGS) -c $< -o $@
# Disable VCS-based implicit rules.
% : s.%
.SUFFIXES: .hpux_make_needs_suffix_list
.PHONY: clean
# Command-line flag to silence nested $(MAKE).
$(VERBOSE)MAKESILENT = -s
#Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake
# The command to remove a file.
RM = /usr/bin/cmake -E rm -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/ayoungblood/Projects/BeagleRescue
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /home/ayoungblood/Projects/BeagleRescue
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..."
/usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
.PHONY : edit_cache
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast
# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
/usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast
# Special rule for the target list_install_components
list_install_components:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\""
.PHONY : list_install_components
# Special rule for the target list_install_components
list_install_components/fast: list_install_components
.PHONY : list_install_components/fast
# Special rule for the target install
install: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
/usr/bin/cmake -P cmake_install.cmake
.PHONY : install
# Special rule for the target install
install/fast: preinstall/fast
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
/usr/bin/cmake -P cmake_install.cmake
.PHONY : install/fast
# Special rule for the target install/local
install/local: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
/usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
.PHONY : install/local
# Special rule for the target install/local
install/local/fast: preinstall/fast
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
/usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
.PHONY : install/local/fast
# Special rule for the target install/strip
install/strip: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
/usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
.PHONY : install/strip
# Special rule for the target install/strip
install/strip/fast: preinstall/fast
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
/usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
.PHONY : install/strip/fast
# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /home/ayoungblood/Projects/BeagleRescue/CMakeFiles /home/ayoungblood/Projects/BeagleRescue//CMakeFiles/progress.marks
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /home/ayoungblood/Projects/BeagleRescue/CMakeFiles 0
.PHONY : all
# The main clean target
clean:
$(RM) -r $(BUILD_DIR)
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean
.PHONY : clean
-include $(DEPS)
# The main clean target
clean/fast: clean
.PHONY : clean/fast
# Prepare targets for installation.
preinstall: all
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall
# Prepare targets for installation.
preinstall/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast
# clear depends
depend:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend
#=============================================================================
# Target rules for targets named BeagleRescue
# Build rule for target.
BeagleRescue: cmake_check_build_system
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 BeagleRescue
.PHONY : BeagleRescue
# fast build rule for target.
BeagleRescue/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/build
.PHONY : BeagleRescue/fast
src/assetmgr/AssetManager.o: src/assetmgr/AssetManager.cpp.o
.PHONY : src/assetmgr/AssetManager.o
# target to build an object file
src/assetmgr/AssetManager.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/AssetManager.cpp.o
.PHONY : src/assetmgr/AssetManager.cpp.o
src/assetmgr/AssetManager.i: src/assetmgr/AssetManager.cpp.i
.PHONY : src/assetmgr/AssetManager.i
# target to preprocess a source file
src/assetmgr/AssetManager.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/AssetManager.cpp.i
.PHONY : src/assetmgr/AssetManager.cpp.i
src/assetmgr/AssetManager.s: src/assetmgr/AssetManager.cpp.s
.PHONY : src/assetmgr/AssetManager.s
# target to generate assembly for a file
src/assetmgr/AssetManager.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/AssetManager.cpp.s
.PHONY : src/assetmgr/AssetManager.cpp.s
src/assetmgr/GameObject.o: src/assetmgr/GameObject.cpp.o
.PHONY : src/assetmgr/GameObject.o
# target to build an object file
src/assetmgr/GameObject.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/GameObject.cpp.o
.PHONY : src/assetmgr/GameObject.cpp.o
src/assetmgr/GameObject.i: src/assetmgr/GameObject.cpp.i
.PHONY : src/assetmgr/GameObject.i
# target to preprocess a source file
src/assetmgr/GameObject.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/GameObject.cpp.i
.PHONY : src/assetmgr/GameObject.cpp.i
src/assetmgr/GameObject.s: src/assetmgr/GameObject.cpp.s
.PHONY : src/assetmgr/GameObject.s
# target to generate assembly for a file
src/assetmgr/GameObject.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/GameObject.cpp.s
.PHONY : src/assetmgr/GameObject.cpp.s
src/assetmgr/Map.o: src/assetmgr/Map.cpp.o
.PHONY : src/assetmgr/Map.o
# target to build an object file
src/assetmgr/Map.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/Map.cpp.o
.PHONY : src/assetmgr/Map.cpp.o
src/assetmgr/Map.i: src/assetmgr/Map.cpp.i
.PHONY : src/assetmgr/Map.i
# target to preprocess a source file
src/assetmgr/Map.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/Map.cpp.i
.PHONY : src/assetmgr/Map.cpp.i
src/assetmgr/Map.s: src/assetmgr/Map.cpp.s
.PHONY : src/assetmgr/Map.s
# target to generate assembly for a file
src/assetmgr/Map.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/Map.cpp.s
.PHONY : src/assetmgr/Map.cpp.s
src/assetmgr/MusicManager.o: src/assetmgr/MusicManager.cpp.o
.PHONY : src/assetmgr/MusicManager.o
# target to build an object file
src/assetmgr/MusicManager.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/MusicManager.cpp.o
.PHONY : src/assetmgr/MusicManager.cpp.o
src/assetmgr/MusicManager.i: src/assetmgr/MusicManager.cpp.i
.PHONY : src/assetmgr/MusicManager.i
# target to preprocess a source file
src/assetmgr/MusicManager.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/MusicManager.cpp.i
.PHONY : src/assetmgr/MusicManager.cpp.i
src/assetmgr/MusicManager.s: src/assetmgr/MusicManager.cpp.s
.PHONY : src/assetmgr/MusicManager.s
# target to generate assembly for a file
src/assetmgr/MusicManager.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/MusicManager.cpp.s
.PHONY : src/assetmgr/MusicManager.cpp.s
src/assetmgr/TextureManager.o: src/assetmgr/TextureManager.cpp.o
.PHONY : src/assetmgr/TextureManager.o
# target to build an object file
src/assetmgr/TextureManager.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/TextureManager.cpp.o
.PHONY : src/assetmgr/TextureManager.cpp.o
src/assetmgr/TextureManager.i: src/assetmgr/TextureManager.cpp.i
.PHONY : src/assetmgr/TextureManager.i
# target to preprocess a source file
src/assetmgr/TextureManager.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/TextureManager.cpp.i
.PHONY : src/assetmgr/TextureManager.cpp.i
src/assetmgr/TextureManager.s: src/assetmgr/TextureManager.cpp.s
.PHONY : src/assetmgr/TextureManager.s
# target to generate assembly for a file
src/assetmgr/TextureManager.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/assetmgr/TextureManager.cpp.s
.PHONY : src/assetmgr/TextureManager.cpp.s
src/cjson/cJSON.o: src/cjson/cJSON.c.o
.PHONY : src/cjson/cJSON.o
# target to build an object file
src/cjson/cJSON.c.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/cjson/cJSON.c.o
.PHONY : src/cjson/cJSON.c.o
src/cjson/cJSON.i: src/cjson/cJSON.c.i
.PHONY : src/cjson/cJSON.i
# target to preprocess a source file
src/cjson/cJSON.c.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/cjson/cJSON.c.i
.PHONY : src/cjson/cJSON.c.i
src/cjson/cJSON.s: src/cjson/cJSON.c.s
.PHONY : src/cjson/cJSON.s
# target to generate assembly for a file
src/cjson/cJSON.c.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/cjson/cJSON.c.s
.PHONY : src/cjson/cJSON.c.s
src/ecs/ECS.o: src/ecs/ECS.cpp.o
.PHONY : src/ecs/ECS.o
# target to build an object file
src/ecs/ECS.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/ecs/ECS.cpp.o
.PHONY : src/ecs/ECS.cpp.o
src/ecs/ECS.i: src/ecs/ECS.cpp.i
.PHONY : src/ecs/ECS.i
# target to preprocess a source file
src/ecs/ECS.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/ecs/ECS.cpp.i
.PHONY : src/ecs/ECS.cpp.i
src/ecs/ECS.s: src/ecs/ECS.cpp.s
.PHONY : src/ecs/ECS.s
# target to generate assembly for a file
src/ecs/ECS.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/ecs/ECS.cpp.s
.PHONY : src/ecs/ECS.cpp.s
src/game/Collision.o: src/game/Collision.cpp.o
.PHONY : src/game/Collision.o
# target to build an object file
src/game/Collision.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/Collision.cpp.o
.PHONY : src/game/Collision.cpp.o
src/game/Collision.i: src/game/Collision.cpp.i
.PHONY : src/game/Collision.i
# target to preprocess a source file
src/game/Collision.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/Collision.cpp.i
.PHONY : src/game/Collision.cpp.i
src/game/Collision.s: src/game/Collision.cpp.s
.PHONY : src/game/Collision.s
# target to generate assembly for a file
src/game/Collision.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/Collision.cpp.s
.PHONY : src/game/Collision.cpp.s
src/game/Game.o: src/game/Game.cpp.o
.PHONY : src/game/Game.o
# target to build an object file
src/game/Game.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/Game.cpp.o
.PHONY : src/game/Game.cpp.o
src/game/Game.i: src/game/Game.cpp.i
.PHONY : src/game/Game.i
# target to preprocess a source file
src/game/Game.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/Game.cpp.i
.PHONY : src/game/Game.cpp.i
src/game/Game.s: src/game/Game.cpp.s
.PHONY : src/game/Game.s
# target to generate assembly for a file
src/game/Game.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/Game.cpp.s
.PHONY : src/game/Game.cpp.s
src/game/GameStateManager.o: src/game/GameStateManager.cpp.o
.PHONY : src/game/GameStateManager.o
# target to build an object file
src/game/GameStateManager.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/GameStateManager.cpp.o
.PHONY : src/game/GameStateManager.cpp.o
src/game/GameStateManager.i: src/game/GameStateManager.cpp.i
.PHONY : src/game/GameStateManager.i
# target to preprocess a source file
src/game/GameStateManager.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/GameStateManager.cpp.i
.PHONY : src/game/GameStateManager.cpp.i
src/game/GameStateManager.s: src/game/GameStateManager.cpp.s
.PHONY : src/game/GameStateManager.s
# target to generate assembly for a file
src/game/GameStateManager.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/GameStateManager.cpp.s
.PHONY : src/game/GameStateManager.cpp.s
src/game/Main.o: src/game/Main.cpp.o
.PHONY : src/game/Main.o
# target to build an object file
src/game/Main.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/Main.cpp.o
.PHONY : src/game/Main.cpp.o
src/game/Main.i: src/game/Main.cpp.i
.PHONY : src/game/Main.i
# target to preprocess a source file
src/game/Main.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/Main.cpp.i
.PHONY : src/game/Main.cpp.i
src/game/Main.s: src/game/Main.cpp.s
.PHONY : src/game/Main.s
# target to generate assembly for a file
src/game/Main.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/Main.cpp.s
.PHONY : src/game/Main.cpp.s
src/game/StateMachine.o: src/game/StateMachine.cpp.o
.PHONY : src/game/StateMachine.o
# target to build an object file
src/game/StateMachine.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/StateMachine.cpp.o
.PHONY : src/game/StateMachine.cpp.o
src/game/StateMachine.i: src/game/StateMachine.cpp.i
.PHONY : src/game/StateMachine.i
# target to preprocess a source file
src/game/StateMachine.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/StateMachine.cpp.i
.PHONY : src/game/StateMachine.cpp.i
src/game/StateMachine.s: src/game/StateMachine.cpp.s
.PHONY : src/game/StateMachine.s
# target to generate assembly for a file
src/game/StateMachine.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/StateMachine.cpp.s
.PHONY : src/game/StateMachine.cpp.s
src/game/Vector2D.o: src/game/Vector2D.cpp.o
.PHONY : src/game/Vector2D.o
# target to build an object file
src/game/Vector2D.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/Vector2D.cpp.o
.PHONY : src/game/Vector2D.cpp.o
src/game/Vector2D.i: src/game/Vector2D.cpp.i
.PHONY : src/game/Vector2D.i
# target to preprocess a source file
src/game/Vector2D.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/Vector2D.cpp.i
.PHONY : src/game/Vector2D.cpp.i
src/game/Vector2D.s: src/game/Vector2D.cpp.s
.PHONY : src/game/Vector2D.s
# target to generate assembly for a file
src/game/Vector2D.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/game/Vector2D.cpp.s
.PHONY : src/game/Vector2D.cpp.s
src/ui/UINineSlice.o: src/ui/UINineSlice.cpp.o
.PHONY : src/ui/UINineSlice.o
# target to build an object file
src/ui/UINineSlice.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/ui/UINineSlice.cpp.o
.PHONY : src/ui/UINineSlice.cpp.o
src/ui/UINineSlice.i: src/ui/UINineSlice.cpp.i
.PHONY : src/ui/UINineSlice.i
# target to preprocess a source file
src/ui/UINineSlice.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/ui/UINineSlice.cpp.i
.PHONY : src/ui/UINineSlice.cpp.i
src/ui/UINineSlice.s: src/ui/UINineSlice.cpp.s
.PHONY : src/ui/UINineSlice.s
# target to generate assembly for a file
src/ui/UINineSlice.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/ui/UINineSlice.cpp.s
.PHONY : src/ui/UINineSlice.cpp.s
src/ui/UIText.o: src/ui/UIText.cpp.o
.PHONY : src/ui/UIText.o
# target to build an object file
src/ui/UIText.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/ui/UIText.cpp.o
.PHONY : src/ui/UIText.cpp.o
src/ui/UIText.i: src/ui/UIText.cpp.i
.PHONY : src/ui/UIText.i
# target to preprocess a source file
src/ui/UIText.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/ui/UIText.cpp.i
.PHONY : src/ui/UIText.cpp.i
src/ui/UIText.s: src/ui/UIText.cpp.s
.PHONY : src/ui/UIText.s
# target to generate assembly for a file
src/ui/UIText.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/BeagleRescue.dir/build.make CMakeFiles/BeagleRescue.dir/src/ui/UIText.cpp.s
.PHONY : src/ui/UIText.cpp.s
# Help Target
help:
@echo "The following are some of the valid targets for this Makefile:"
@echo "... all (the default if no target is provided)"
@echo "... clean"
@echo "... depend"
@echo "... edit_cache"
@echo "... install"
@echo "... install/local"
@echo "... install/strip"
@echo "... list_install_components"
@echo "... rebuild_cache"
@echo "... BeagleRescue"
@echo "... src/assetmgr/AssetManager.o"
@echo "... src/assetmgr/AssetManager.i"
@echo "... src/assetmgr/AssetManager.s"
@echo "... src/assetmgr/GameObject.o"
@echo "... src/assetmgr/GameObject.i"
@echo "... src/assetmgr/GameObject.s"
@echo "... src/assetmgr/Map.o"
@echo "... src/assetmgr/Map.i"
@echo "... src/assetmgr/Map.s"
@echo "... src/assetmgr/MusicManager.o"
@echo "... src/assetmgr/MusicManager.i"
@echo "... src/assetmgr/MusicManager.s"
@echo "... src/assetmgr/TextureManager.o"
@echo "... src/assetmgr/TextureManager.i"
@echo "... src/assetmgr/TextureManager.s"
@echo "... src/cjson/cJSON.o"
@echo "... src/cjson/cJSON.i"
@echo "... src/cjson/cJSON.s"
@echo "... src/ecs/ECS.o"
@echo "... src/ecs/ECS.i"
@echo "... src/ecs/ECS.s"
@echo "... src/game/Collision.o"
@echo "... src/game/Collision.i"
@echo "... src/game/Collision.s"
@echo "... src/game/Game.o"
@echo "... src/game/Game.i"
@echo "... src/game/Game.s"
@echo "... src/game/GameStateManager.o"
@echo "... src/game/GameStateManager.i"
@echo "... src/game/GameStateManager.s"
@echo "... src/game/Main.o"
@echo "... src/game/Main.i"
@echo "... src/game/Main.s"
@echo "... src/game/StateMachine.o"
@echo "... src/game/StateMachine.i"
@echo "... src/game/StateMachine.s"
@echo "... src/game/Vector2D.o"
@echo "... src/game/Vector2D.i"
@echo "... src/game/Vector2D.s"
@echo "... src/ui/UINineSlice.o"
@echo "... src/ui/UINineSlice.i"
@echo "... src/ui/UINineSlice.s"
@echo "... src/ui/UIText.o"
@echo "... src/ui/UIText.i"
@echo "... src/ui/UIText.s"
.PHONY : help
#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system
MKDIR_P ?= mkdir -p

BIN
assets/maps/br-tiles.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

338
assets/maps/br-tiles.tsj Normal file
View File

@ -0,0 +1,338 @@
{ "columns":10,
"image":"..\/..\/..\/Projects\/BeagleRescue\/assets\/maps\/br-tiles.png",
"imageheight":80,
"imagewidth":160,
"margin":0,
"name":"br-tiles",
"spacing":0,
"tilecount":50,
"tiledversion":"1.8.2",
"tileheight":16,
"tiles":[
{
"id":10,
"objectgroup":
{
"draworder":"index",
"id":2,
"name":"",
"objects":[
{
"height":16,
"id":1,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}
},
{
"id":11,
"objectgroup":
{
"draworder":"index",
"id":2,
"name":"",
"objects":[
{
"height":16,
"id":1,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}
},
{
"id":12,
"objectgroup":
{
"draworder":"index",
"id":2,
"name":"",
"objects":[
{
"height":16,
"id":1,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}
},
{
"id":13,
"objectgroup":
{
"draworder":"index",
"id":2,
"name":"",
"objects":[
{
"height":16,
"id":1,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}
},
{
"id":15,
"objectgroup":
{
"draworder":"index",
"id":2,
"name":"",
"objects":[
{
"height":16,
"id":1,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}
},
{
"id":19,
"objectgroup":
{
"draworder":"index",
"id":2,
"name":"",
"objects":[
{
"height":16,
"id":1,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}
},
{
"id":20,
"objectgroup":
{
"draworder":"index",
"id":2,
"name":"",
"objects":[
{
"height":16,
"id":1,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}
},
{
"id":21,
"objectgroup":
{
"draworder":"index",
"id":2,
"name":"",
"objects":[
{
"height":16,
"id":1,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}
},
{
"id":28,
"objectgroup":
{
"draworder":"index",
"id":2,
"name":"",
"objects":[
{
"height":16,
"id":1,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}
},
{
"id":43,
"objectgroup":
{
"draworder":"index",
"id":2,
"name":"",
"objects":[
{
"height":16,
"id":2,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
},
{
"height":14.2813,
"id":3,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":14.4375,
"x":0.96875,
"y":0.875
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}
},
{
"id":44,
"objectgroup":
{
"draworder":"index",
"id":2,
"name":"",
"objects":[
{
"height":16,
"id":1,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}
},
{
"id":45,
"objectgroup":
{
"draworder":"index",
"id":2,
"name":"",
"objects":[
{
"height":16,
"id":1,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}
}],
"tilewidth":16,
"type":"tileset",
"version":"1.8"
}

65
assets/maps/br-tiles.tsx Normal file
View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.8" tiledversion="1.8.2" name="br-tiles" tilewidth="16" tileheight="16" tilecount="50" columns="10">
<image source="br-tiles.png" width="160" height="80"/>
<tile id="10">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="11">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="12">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="13">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="15">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="19">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="20">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="21">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="28">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="43">
<objectgroup draworder="index" id="2">
<object id="2" x="0" y="0" width="16" height="16"/>
<object id="3" x="0.96875" y="0.875" width="14.4375" height="14.2813"/>
</objectgroup>
</tile>
<tile id="44">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="45">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
</tileset>

44
assets/maps/testmap Normal file

File diff suppressed because one or more lines are too long

48
assets/maps/testmap.json Normal file

File diff suppressed because one or more lines are too long

96
assets/maps/testmap.tmx Normal file
View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="42" height="42" tilewidth="16" tileheight="16" infinite="0" nextlayerid="4" nextobjectid="1">
<tileset firstgid="1" source="br-tiles.tsx"/>
<layer id="1" name="TileMap" width="42" height="42">
<data encoding="csv">
11,12,13,35,35,35,36,36,36,35,36,35,35,9,35,35,35,35,35,35,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,35,35,35,35,36,36,35,35,35,35,10,35,35,35,35,35,35,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,35,35,37,35,35,35,35,41,42,43,35,35,35,35,35,35,35,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,35,35,35,35,35,35,38,38,35,35,35,35,35,35,35,35,35,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,35,35,35,35,35,38,38,35,35,35,35,35,35,35,35,35,35,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,35,35,35,35,38,38,35,35,37,35,35,35,35,35,35,35,35,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,35,35,35,38,38,35,35,35,37,37,35,35,35,35,35,35,35,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,35,35,38,38,35,35,35,37,37,37,35,35,35,35,35,35,35,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,35,38,38,35,35,35,35,35,35,37,35,35,35,35,35,35,35,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,34,45,46,34,34,34,45,46,44,45,46,44,45,46,44,45,46,44,45,46,44,45,44,45,44,45,46,45,44,44,44,44,44,44,44,44,14,15,16,
14,15,16,34,34,34,34,34,34,34,34,34,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,34,34,34,34,34,34,34,34,34,34,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,34,34,34,41,42,43,34,34,34,34,34,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,34,34,34,34,34,34,34,34,34,34,34,34,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,34,34,34,34,34,34,34,34,34,34,34,34,34,34,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,34,34,34,34,34,34,34,34,34,34,34,34,34,34,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,34,34,34,34,34,34,34,34,34,34,34,34,34,34,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,44,45,46,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,44,45,46,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,11,12,13,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,11,12,13,40,40,40,40,40,14,15,16,40,40,40,40,40,40,14,15,16,
14,15,16,17,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,17,18,19,40,40,40,40,40,14,15,16,40,40,40,40,40,40,14,15,16,
20,21,22,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,11,12,13
</data>
</layer>
<layer id="3" name="Collision" width="42" height="42" visible="0">
<data encoding="csv">
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,2,2,2,0,0,0,0,0,0,2,2,2,
2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
</data>
</layer>
</map>

File diff suppressed because one or more lines are too long

View File

View File

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.8" tiledversion="1.8.2" name="br-tiles" tilewidth="16" tileheight="16" tilecount="50" columns="10">
<image source="br-tiles.png" width="160" height="80"/>
<tile id="8"/>
<tile id="1"/>
<tile id="0"/>
<tile id="2"/>
<tile id="3"/>
<tile id="4"/>
<tile id="5"/>
<tile id="6"/>
<tile id="7"/>
<tile id="10">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="9"/>
<tile id="11">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="12">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="13">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="14"/>
<tile id="15">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="16"/>
<tile id="17"/>
<tile id="18"/>
<tile id="19">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="20">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="21">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="22"/>
<tile id="23"/>
<tile id="24"/>
<tile id="25"/>
<tile id="26"/>
<tile id="27"/>
<tile id="28">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="29"/>
<tile id="30"/>
<tile id="31"/>
<tile id="32"/>
<tile id="33"/>
<tile id="34"/>
<tile id="35"/>
<tile id="36"/>
<tile id="37"/>
<tile id="38"/>
<tile id="39"/>
<tile id="40"/>
<tile id="41"/>
<tile id="42"/>
<tile id="43">
<objectgroup draworder="index" id="2">
<object id="2" x="0" y="0" width="16" height="16"/>
<object id="3" x="0.96875" y="0.875" width="14.4375" height="14.2813"/>
</objectgroup>
</tile>
<tile id="44">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="45">
<objectgroup draworder="index" id="2">
<object id="1" x="0" y="0" width="16" height="16"/>
</objectgroup>
</tile>
<tile id="46"/>
<tile id="47"/>
<tile id="48"/>
<tile id="49"/>
</tileset>

View File

@ -0,0 +1 @@
{"requests": [{"kind": "codemodel", "version": 2}, {"kind": "cmakeFiles", "version": 1}]}

BIN
build/.ninja_deps Normal file

Binary file not shown.

66
build/.ninja_log Normal file
View File

@ -0,0 +1,66 @@
# ninja log v5
5 1257 1680995986388821260 CMakeFiles/BeagleRescue.dir/src/ecs/ECS.cpp.o 2b68ee632af548aa
4 4614 1680995989752187549 CMakeFiles/BeagleRescue.dir/src/assetmgr/AssetManager.cpp.o eb4c2e382e340f10
4 68 1666035599307923948 libtmx-parser/liblibtmxparser.a 4a03bfde239caf5d
1829 5506 1680995990645529632 CMakeFiles/BeagleRescue.dir/src/ui/UIText.cpp.o 2e1a08cbe2ad039c
5 803 1665858094321634764 CMakeFiles/BeagleRescue.dir/libtmx-parser/src/base64.cpp.o 4bbee0e045ced8b2
8176 8273 1680995073021895354 libtmx-parser/liblibtmxparser.so 9df69ecfe8aa882a
3771 6588 1680995071338547771 libtmx-parser/CMakeFiles/libtmxparser.dir/libs/tinyxml2/tinyxml2.cpp.o 96043e32043d331c
13 8224 1680995993362222899 CMakeFiles/BeagleRescue.dir/src/game/Game.cpp.o 4ba02c1268a57ad0
5 3446 1665858096961659219 CMakeFiles/BeagleRescue.dir/libtmx-parser/src/tmxparser.cpp.o 15f574a728100366
4 1896 1680995987032160899 CMakeFiles/BeagleRescue.dir/src/cjson/cJSON.c.o 77f7fe5671dba050
5 4075 1680995989215515625 CMakeFiles/BeagleRescue.dir/src/assetmgr/TextureManager.cpp.o 811f88fdfc09263c
6990 7109 1680995071858552173 libtmx-parser/libs/tinyxml2/xmltest c7f1f4ebf26757c2
4036 6875 1680995071625216864 libtmx-parser/libs/tinyxml2/CMakeFiles/tinyxml2.dir/tinyxml2.cpp.o 660491a0c7495e62
1258 5876 1680995991015533256 CMakeFiles/BeagleRescue.dir/src/ui/UINineSlice.cpp.o 203c7ee19411f630
2059 8176 1680995072928561230 libtmx-parser/CMakeFiles/libtmxparser.dir/src/tmxparser.cpp.o ead5f95e0e72b1e0
4 794 1665858094311634671 CMakeFiles/BeagleRescue.dir/libtmx-parser/libs/tinyxml2/xmltest.cpp.o ee2e170a3bac274c
6978 6990 1680995071728551073 libtmx-parser/libs/tinyxml2/libtinyxml2.so d0fad9500a04c852
4 1088 1665858094604970721 CMakeFiles/BeagleRescue.dir/libtmx-parser/main.cpp.o 86331d80cf701d8d
13 638 1680995985768815183 CMakeFiles/BeagleRescue.dir/src/game/GameStateManager.cpp.o e18efa52ba3b4829
638 874 1680995986008817536 CMakeFiles/BeagleRescue.dir/src/game/StateMachine.cpp.o c995c41f2f407d79
5 3575 1680995988715510727 CMakeFiles/BeagleRescue.dir/src/assetmgr/MusicManager.cpp.o 743e525b8bc7e022
874 1829 1680995986968826945 CMakeFiles/BeagleRescue.dir/src/game/Vector2D.cpp.o d6bbbe0fad885aeb
6978 6990 1680995071728551073 libtmx-parser/libs/tinyxml2/libtinyxml2.so.2 d0fad9500a04c852
5127 6527 1680995071278547263 libtmx-parser/libs/tinyxml2/CMakeFiles/xmltest.dir/xmltest.cpp.o 88e42020838dcd8e
2957 4036 1680995068778526099 libtmx-parser/CMakeFiles/libtmxparser.dir/src/base64.cpp.o e84a5ef1b712902d
9777 9902 1680995074651909151 BeagleRescue e5cb768adc438473
4 4132 1680995989272182847 CMakeFiles/BeagleRescue.dir/src/assetmgr/GameObject.cpp.o ced4d92dc065c0bf
2 730 1681062043486327943 build.ninja bd959f8df49bfbdd
6 3453 1680995988588842819 CMakeFiles/BeagleRescue.dir/src/game/Collision.cpp.o d59bce856486c23e
6875 6978 1680995071728551073 libtmx-parser/libs/tinyxml2/libtinyxml2.so.2.2.0 8aed3caeabaa38d5
20 4401 1680995989538852126 CMakeFiles/BeagleRescue.dir/src/game/Main.cpp.o c1352eaae73a833f
4 2192 1665858095708314276 CMakeFiles/BeagleRescue.dir/libtmx-parser/libs/tinyxml2/tinyxml2.cpp.o 60acd5a4117a4833
4 2488 1681062059289774035 CMakeFiles/BeagleRescue.dir/src/assetmgr/MusicManager.cpp.o 743e525b8bc7e022
4 2608 1681062059413108248 CMakeFiles/BeagleRescue.dir/src/assetmgr/TextureManager.cpp.o 811f88fdfc09263c
4 2703 1681062059509775604 CMakeFiles/BeagleRescue.dir/src/game/Collision.cpp.o d59bce856486c23e
3 2706 1681062059513108961 CMakeFiles/BeagleRescue.dir/src/assetmgr/GameObject.cpp.o ced4d92dc065c0bf
5 2815 1681062059623109746 CMakeFiles/BeagleRescue.dir/src/game/Main.cpp.o c1352eaae73a833f
5 2962 1681062059769777459 CMakeFiles/BeagleRescue.dir/src/ui/UIText.cpp.o 2e1a08cbe2ad039c
5 3207 1681062060013112528 CMakeFiles/BeagleRescue.dir/src/ui/UINineSlice.cpp.o 203c7ee19411f630
3 3347 1681062060153113527 CMakeFiles/BeagleRescue.dir/src/assetmgr/AssetManager.cpp.o eb4c2e382e340f10
5 4194 1681062060999786234 CMakeFiles/BeagleRescue.dir/src/game/Game.cpp.o 4ba02c1268a57ad0
4194 4286 1681062061093120232 BeagleRescue e58e98489844e561
6 591 1681062457555937468 CMakeFiles/BeagleRescue.dir/src/game/GameStateManager.cpp.o e18efa52ba3b4829
591 742 1681062457719271959 CMakeFiles/BeagleRescue.dir/src/game/StateMachine.cpp.o c995c41f2f407d79
5 1761 1681062458725945758 CMakeFiles/BeagleRescue.dir/src/ecs/ECS.cpp.o 2b68ee632af548aa
3 1777 1681062458739279185 CMakeFiles/BeagleRescue.dir/src/cjson/cJSON.c.o 77f7fe5671dba050
742 1911 1681062458882613534 CMakeFiles/BeagleRescue.dir/src/game/Vector2D.cpp.o d6bbbe0fad885aeb
4 2480 1681062459459284286 CMakeFiles/BeagleRescue.dir/src/assetmgr/TextureManager.cpp.o 811f88fdfc09263c
4 2628 1681062459609285349 CMakeFiles/BeagleRescue.dir/src/assetmgr/MusicManager.cpp.o 743e525b8bc7e022
4 2658 1681062459635952204 CMakeFiles/BeagleRescue.dir/src/assetmgr/GameObject.cpp.o ced4d92dc065c0bf
5 2882 1681062459862620477 CMakeFiles/BeagleRescue.dir/src/game/Collision.cpp.o d59bce856486c23e
13 3065 1681062460045955109 CMakeFiles/BeagleRescue.dir/src/game/Main.cpp.o c1352eaae73a833f
3 3323 1681062460302623594 CMakeFiles/BeagleRescue.dir/src/assetmgr/AssetManager.cpp.o eb4c2e382e340f10
1777 4185 1681062461165963044 CMakeFiles/BeagleRescue.dir/src/ui/UIText.cpp.o 2e1a08cbe2ad039c
1761 4194 1681062461172629758 CMakeFiles/BeagleRescue.dir/src/ui/UINineSlice.cpp.o 203c7ee19411f630
5 4476 1681062461455965099 CMakeFiles/BeagleRescue.dir/src/game/Game.cpp.o 4ba02c1268a57ad0
4476 4568 1681062461545965736 BeagleRescue e58e98489844e561
6 3541 1689099824178728855 CMakeFiles/BeagleRescue.dir/src/assetmgr/GameObject.cpp.o ced4d92dc065c0bf
7 3541 1689099824178728855 CMakeFiles/BeagleRescue.dir/src/assetmgr/TextureManager.cpp.o 811f88fdfc09263c
7 3604 1689099824242062276 CMakeFiles/BeagleRescue.dir/src/assetmgr/MusicManager.cpp.o 743e525b8bc7e022
8 3817 1689099824455395905 CMakeFiles/BeagleRescue.dir/src/game/Main.cpp.o c1352eaae73a833f
7 3968 1689099824605396113 CMakeFiles/BeagleRescue.dir/src/game/Collision.cpp.o d59bce856486c23e
14 4213 1689099824852063121 CMakeFiles/BeagleRescue.dir/src/ui/UIText.cpp.o 2e1a08cbe2ad039c
6 4495 1689099825135396846 CMakeFiles/BeagleRescue.dir/src/assetmgr/AssetManager.cpp.o eb4c2e382e340f10
9 4558 1689099825195396929 CMakeFiles/BeagleRescue.dir/src/ui/UINineSlice.cpp.o 203c7ee19411f630

Binary file not shown.

View File

@ -0,0 +1,27 @@
checkCollision(movingRect, moveVector, solidRect)
{
// Need to make additional similar checks for each side
if (moveVector.x > 0)
{
if (movingRect.xMax < solidRect.xMin &&
movingRect.xMax + moveVector.x > solidRect.xMin)
{
xHitRatio = (solidRect.xMin - moveingRect.xMax) / moveVector.x
}
}
// Also find hit ratio of y movement and see which one will hit first if either does.
if (xHitRatio < yHitRatio)
{
yHitPosMin = movingRect.yMin + moveVector.y * xHitRatio
yHitPosMax = movingRect.yMax + moveVector.y * xHitRatio
if (yHitPosMin < solidRect.yMax &&
yHitPosMax > solidRect.yMin)
{
// We know here now where we should collide, however if we stop here the collision will feel 'sticky'
// rather than just applying the ratio to the movement vector, we want to instead slide along the collision
output.x = movingRect.xOrigin + moveVector.x * xHitRatio
output.y = movingRect.yOrigin + moveVector.y // Here is where we should split off a new movement vector to check collision again really, since it is a new direction to check, so return the hit position with a new smaller vector to 'finish' the movement.
}
}
}

7
design/debug.txt Normal file
View File

@ -0,0 +1,7 @@
Collision Stats:
Player Center
x: 871
y: 690
ObjectCollider Center
x: 872
y: 696

View File

@ -48,6 +48,7 @@ SDL_Texture* AssetManager::GetTexture(std::string id)
}
//Sound Mixer
//Sound Clips
void AssetManager::AddSoundClip(std::string id, const char* path)
{

View File

@ -14,7 +14,6 @@
#include "../game/Vector2D.h"
#include "../ecs/ECS.h"
#include "../game/Game.hpp"
//#include <SDL2/SDL_mixer.h>
#include "MusicManager.h"
class AssetManager

View File

@ -33,7 +33,7 @@ void Map::LoadMap(std::string path, int sizeX, int sizeY, int scale)
std::fstream mapFile;
mapFile.open(path);
int srcX, srcY;
width = tSize*scale*sizeX;
height = tSize*scale*sizeY;
@ -45,7 +45,6 @@ void Map::LoadMap(std::string path, int sizeX, int sizeY, int scale)
srcY = atoi(&c) * tileSize;
mapFile.get(c);
srcX = atoi(&c) * tileSize;
AddTile(srcX, srcY, x*scaledSize, y*scaledSize);
mapFile.ignore(2,',');
}
}
@ -60,7 +59,7 @@ void Map::LoadMap(std::string path, int sizeX, int sizeY, int scale)
if (c == '1')
{
auto& tcol(manager.addEntity());
tcol.addComponent<ColliderComponent>("terrain",x*scaledSize,y*scaledSize,tileSize,scale);
tcol.addComponent<ColliderComponent>("terrain",x*scaledSize,y*scaledSize,tileSize,scale,texID);
tcol.addGroup(Game::groupColliders);
}
mapFile.ignore(2,',');

View File

@ -6,7 +6,7 @@
*/
#include "MusicManager.h"
#include "SDL2/SDL_mixer.h"
#include <SDL2/SDL_mixer.h>
Mix_Music* MusicManager::LoadMusic(const char* path){
Mix_Music* music = Mix_LoadMUS(path);

View File

@ -9,7 +9,7 @@
#define SRC_MUSICMANAGER_H_
#include "../game/Game.hpp"
#include "SDL2/SDL_mixer.h"
#include <SDL2/SDL_mixer.h>
class MusicManager
{

View File

@ -1,7 +1,7 @@
{
"GameName":"Beagle Rescue",
"WindowName":"Beagle Rescue",
"WindowSize":{"w":320,"h":240},
"WindowSize":{"w":427,"h":240},
"WindowFullScreen": 0,
"GlobalScale": 3
"GlobalScale": 2
}

View File

@ -1,6 +1,6 @@
{
"GameName":"Beagle Rescue",
"Developers": "Alan Youngblood, Simon Zaleski, Daniel Rinaldi",
"LibraryDevelopers": "Sam Lantinga, Dave Gamble, Carl Birch, Job Vranish, David Lafreniere",
"SpecialThanks":"Nic Allen, Brian Lhota"
"LibraryDevelopers": "Sam Lantinga, Dave Gamble, Carl Birch, Job Vranish, David Lafreniere, Bayle Jonathan, Robin Berg Pettersen",
"SpecialThanks":"Nic Allen, Brian Lhota, Rodrigo Monteiro"
}

View File

@ -9,15 +9,18 @@
#define SRC_ECS_COLLIDERCOMPONENT_H_
#include <string>
#include "SDL2/SDL.h"
#include <SDL2/SDL.h>
#include "Components.h"
#include "ECS.h"
#include "../assetmgr/TextureManager.h"
#include <iostream>
#include "../game/Vector2D.h"
class ColliderComponent : public Component
{
public:
SDL_Rect collider;
std::string tag;
@ -26,32 +29,44 @@ public:
int offsetX = 0;
int offsetY = 0;
bool hidden = true;
Vector2D center;
TransformComponent* transform;
ColliderComponent()
{
center.Zero();
}
ColliderComponent(std::string t)
{
tag = t;
// collider.x = 10;
// collider.y = 52;
// collider.w = collider.h = 12;
}
ColliderComponent(std::string t, int xpos, int ypos, int size, int scale)
ColliderComponent(std::string t, int xpos, int ypos, int size, int scale, std::string texture)
{
tag = t;
collider.x = xpos;
collider.y = ypos;
collider.w = collider.h = size*scale;
setTex(texture);
center.x = collider.x+collider.w/2;
center.y = collider.y+collider.h/2;
}
ColliderComponent(std::string t, int width, int height, bool hasOffset, int oX, int oY)
ColliderComponent(std::string t, int width, int height, bool hasOffset, int oX, int oY, std::string texture)
{
tag = t;
collider.w = width;
collider.h = height;
offsetX = oX;
offsetY = oY;
setTex(texture);
center.x = collider.x+collider.w/2;
center.y = collider.y+collider.h/2;
}
void init() override
@ -66,17 +81,6 @@ public:
tex = TextureManager::LoadTexture("assets/ColTex.png");
srcR = { 0, 0, 16, 16};
destR = { collider.x, collider.y, collider.w, collider.h };
// if(tag == "player"){
// destR = { 18, 28, 24, 24 };
// collider.w = 16;
// collider.h = 16;
// transform->height = 24;
// transform->width = 24;
// std::cout << "player collider init() ran" << std::endl;
// std::cout << "destR.w: " << destR.w << std::endl;
// std::cout << "destR.h: " << destR.h << std::endl;
// }
// Game::colliders.push_back(this);
}
void update() override
@ -85,22 +89,33 @@ public:
{
collider.x = static_cast<int>(transform->position.x+offsetX);
collider.y = static_cast<int>(transform->position.y+offsetY);
// collider.w = transform->width * transform->scale;
// collider.h = transform->height * transform->scale;
// collider.w = 12 * transform->scale;
// collider.h = 12 * transform->scale;
}
destR.x = collider.x - Game::camera.x;
destR.y = collider.y - Game::camera.y;
center.x = collider.x+collider.w/2;
center.y = collider.y+collider.h/2;
// collider.x = transform->position.x;
// collider.y = transform->position.y;
}
void draw() override
{
if(tag == "terrain")
{
TextureManager::Draw(tex, srcR, destR, SDL_FLIP_NONE);
// TextureManager::DrawCollider(destR);
// if(tag == "terrain")
// {
// TextureManager::Draw(tex, srcR, destR, SDL_FLIP_NONE);
// }
if(hidden == false)
{
// TextureManager::Draw(tex, srcR,destR,SDL_FLIP_NONE);
SDL_SetRenderDrawColor(Game::renderer,255,0,255,134);
SDL_RenderDrawRect(Game::renderer, &destR);
// SDL_RenderDrawPoint(Game::renderer, center.x, center.y);
}
}
void setTex(std::string id)
{
tex = Game::assets->GetTexture(id);
}

View File

@ -13,11 +13,10 @@
#include "SpriteComponent.h"
#include "KeyboardController.h"
#include "ColliderComponent.h"
#include "PlayerController.h"
#include "ProjectileComponent.h"
#include "TileComponent.h"
#include "UIFontComponent.h"
#include "TileMapComponent.h"
#include "UITextComponent.h"
#endif /* SRC_COMPONENTS_H_ */

View File

@ -11,21 +11,29 @@
#include "../game/Game.hpp"
#include "ECS.h"
#include "Components.h"
#include "PlayerController.h"
#include "../assetmgr/AssetManager.h"
#include "ColliderComponent.h"
#include <cmath>
// #include "../game/Vector2D.h"
class KeyboardController : public Component
{
public:
// bool keyIsAlreadyPressed[];
TransformComponent *transform;
SpriteComponent *sprite;
PlayerController *playerCtrl;
ColliderComponent *collider;
Game *game;
void init() override
{
transform = &entity->getComponent<TransformComponent>();
sprite = &entity->getComponent<SpriteComponent>();
// collider = &entity->getComponent<ColliderComponent>();
// playerCtrl = &entity->getComponent<PlayerController>();
}
void update() override
@ -34,43 +42,134 @@ public:
{
switch (Game::event.key.keysym.sym)
{
case SDLK_UP:
break;
case SDLK_DOWN:
break;
case SDLK_LEFT:
case SDLK_UP:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
transform->velocity.x = -1;
if(Game::playerIsGrounded){
sprite->Play("Walk");
}
// if(transform->position.y>0){
// ====== Get Player.yTile and scan column up ScreenTilesHeight/2 on Player.xTile-1, Player.xTile, and Player.xTile+1 return first hit that is > 0 for each row.
// transform->tilePos.x
transform->velocity.y = -1;
// if(Game::playerIsGrounded){
sprite->Play("Walk");
// }
sprite->spriteFlip = SDL_FLIP_NONE;
// }
}
break;
case SDLK_RIGHT:
case SDLK_DOWN:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
transform->velocity.x = 1;
if(Game::playerIsGrounded){
if(transform->position.y<Game::levelMap.h){
transform->velocity.y = 1;
// if(Game::playerIsGrounded){
sprite->Play("Walk");
// }
int *borders;
borders = Game::predictCollisions();
sprite->spriteFlip = SDL_FLIP_NONE;
}
sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
}
break;
case SDLK_LEFT:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
if(transform->position.x>Game::levelMap.x){
transform->velocity.x = -1;
// if(Game::playerIsGrounded){
sprite->Play("Walk");
// }
sprite->spriteFlip = SDL_FLIP_NONE;
}
// if (playerCtrl == NULL){
// printf("No player controller found\n");
// } else {
// printf("playerctrl.lastsafepos .x: %g .y: %g \n",playerCtrl->lastSafePosition.x,playerCtrl->lastSafePosition.y);
// playerCtrl->lastSafePosition.x = transform->position.x;
// }
// transform->lastSafePos = Vector2D(transform->position.x,transform->position.y);
// printf("lastSafePos .x: %g .y: %g \n",transform->lastSafePos.x,transform->lastSafePos.y);
// Game::pTileX
// if(transform->position.x>0){
/*int *borders;
borders = Game::predictCollisions();
float max = borders[0];
for (int b=0;b<3;b++){
if (borders[b]>max){
max = borders[b];
}
}
float desiredMovement = -1*transform->speed*0.016; // 0.016 is the FrameTime from the Main.cpp core game loop. later, we will pass in the variable
float difference = std::abs(max-transform->position.x);
if(max*transform->scale<desiredMovement+transform->position.x){
Game::playerIsGrounded = false;
transform->velocity.x = -1;
sprite->Play("Walk");
sprite->spriteFlip = SDL_FLIP_NONE;
}else{
// transform->velocity.x = -difference/desiredMovement;
Game::playerIsGrounded = true;
transform->velocity.x = 0;
sprite->Play("Idle");
sprite->spriteFlip = SDL_FLIP_NONE;
}*/
}
break;
case SDLK_RIGHT:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
// &entity->getComponent<PlayerController>().setLastSafePos(Vector2D(transform->position.x,transform->position.y));
// playerCtrl->lastSafePosition.x = transform->position.x;
// transform->lastSafePos = Vector2D(transform->position.x,transform->position.y);
// =========
// Do a pre-check for tile-based smooth algorithm
// =========
// int intersectionTileX = collider->center.x;
if(transform->position.x<Game::levelMap.w){
transform->velocity.x = 1;
// if(Game::playerIsGrounded){
sprite->Play("Walk");
// }
sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
}
}
break;
// case SDLK_a:
// if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
// transform->velocity.x = -1;
// if(Game::playerIsGrounded){
// sprite->Play("Walk");
// }
// sprite->spriteFlip = SDL_FLIP_NONE;
// }
// break;
// case SDLK_d:
// if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
// transform->velocity.x = 1;
// if(Game::playerIsGrounded){
// sprite->Play("Walk");
// }
// sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
// }
// break;
case SDLK_k:
if (!Game::debugCollisionBoxes)
{ Game::debugCollisionBoxes = true; }
else
{Game::debugCollisionBoxes = false; }
if (!Game::debugMenu)
{ Game::debugMenu = true; }
else
{ Game::debugMenu = false; }
break;
case SDLK_j:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
if (Mix_PlayChannel(-1, Game::assets->GetSoundClip("bwoop"),0) == 0)
{
Mix_PlayChannel(-1, Game::assets->GetSoundClip("bwoop"),0);
if(Game::playerIsGrounded){
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
if (Mix_PlayChannel(-1, Game::assets->GetSoundClip("bwoop"),0) == 0)
{
Mix_PlayChannel(-1, Game::assets->GetSoundClip("bwoop"),0);
}
// transform->lastSafePos = Vector2D(transform->position.x,transform->position.y);
Game::gravityOnPlayer = true;
sprite->Play("Jump");
transform->velocity.y = -2;
}
Game::gravityOnPlayer = true;
sprite->Play("Jump");
transform->velocity.y = -2;
}
break;
case SDLK_u:
@ -83,39 +182,71 @@ public:
break;
}
}
// ===============================================
// ON KEY UP
// ===============================================
else if (Game::event.type == SDL_KEYUP)
{
switch (Game::event.key.keysym.sym)
{
case SDLK_UP:
// transform->velocity.y = 0;
// sprite->Play("idle");
// sprite->spriteFlip = SDL_FLIP_NONE;
break;
case SDLK_DOWN:
// transform->velocity.y = 0;
// sprite->Play("idle");
// sprite->spriteFlip = SDL_FLIP_NONE;
break;
case SDLK_LEFT:
case SDLK_LEFT:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
transform->velocity.x = 0;
sprite->Play("Idle");
if (!Game::gravityOnPlayer){
Game::gravityOnPlayer = true;
// sprite->Play("Fall");
}
Game::playerIsGrounded = false;
// if (!Game::gravityOnPlayer){
// Game::gravityOnPlayer = true;
// // sprite->Play("Fall");
// }
}
break;
case SDLK_RIGHT:
case SDLK_RIGHT:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
transform->velocity.x = 0;
sprite->Play("Idle");
if (!Game::gravityOnPlayer){
Game::gravityOnPlayer = true;
}
// if (!Game::gravityOnPlayer){
// Game::gravityOnPlayer = true;
// }
}
break;
case SDLK_UP:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
transform->velocity.y = 0;
sprite->Play("Idle");
// if (!Game::gravityOnPlayer){
// Game::gravityOnPlayer = true;
// // sprite->Play("Fall");
// }
}
break;
case SDLK_DOWN:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
transform->velocity.y = 0;
sprite->Play("Idle");
// if (!Game::gravityOnPlayer){
// Game::gravityOnPlayer = true;
// }
}
break;
// case SDLK_a:
// if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
// transform->velocity.x = 0;
// sprite->Play("Idle");
// if (!Game::gravityOnPlayer){
// Game::gravityOnPlayer = true;
// // sprite->Play("Fall");
// }
// }
// break;
// case SDLK_d:
// if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
// transform->velocity.x = 0;
// sprite->Play("Idle");
// if (!Game::gravityOnPlayer){
// Game::gravityOnPlayer = true;
// }
// }
// break;
case SDLK_k:
break;
case SDLK_j:
@ -129,6 +260,13 @@ public:
break;
case SDLK_i:
break;
// case SDLK_d:
// if (Game::debugMenu == false){
// Game::debugMenu = true;}
// else {
// Game::debugMenu = false;
// }
// break;
case SDLK_ESCAPE: // exit the game when Escape pressed
Game::isRunning = false;
break;

View File

@ -0,0 +1,77 @@
/*
* PlayerController.h
*
* Created on: Aug 27, 2021
* Author: ayoungblood
*/
#ifndef SRC_ECS_PlayerController_H_
#define SRC_ECS_PlayerController_H_
#include "Components.h"
#include "../game/Vector2D.h"
class PlayerController : public Component
{
public:
Vector2D lastSafePosition;
float jumpTime;
float jumpForce;
bool isJumping;
bool isGrounded;
PlayerController()
{
jumpTime = 0.0f;
jumpForce = 0.0f;
bool isJumping = false;
bool isGrounded = false;
lastSafePosition = Vector2D();
}
PlayerController(float jumpT, float jumpF, bool jumping, bool grounded, Vector2D lastPos)
{
jumpTime = jumpT;
jumpForce = jumpF;
bool isJumping = jumping;
bool isGrounded = grounded;
lastSafePosition = lastPos;
}
~PlayerController()
{
}
void init() override
{
lastSafePosition.Zero();
}
void update() override
{
}
void setLastSafePos(Vector2D prevSafePos)
{
lastSafePosition = prevSafePos;
}
// void init() override
// {
//
// }
};
#endif /* SRC_ECS_PlayerController_H_ */

View File

@ -24,7 +24,6 @@ public:
{
transform = &entity->getComponent<TransformComponent>();
transform->velocity = velocity;
// std::cout << transform->position << std::endl;
}
void update() override

View File

@ -8,12 +8,8 @@
#ifndef SRC_ECS_SPRITECOMPONENT_H_
#define SRC_ECS_SPRITECOMPONENT_H_
#define ASCII_START_IDX 32
#define ASCII_COUNT 96
#define ASCII_ROW_COUNT 16
#include "Components.h"
#include "SDL2/SDL.h"
#include <SDL2/SDL.h>
#include "../assetmgr/TextureManager.h"
#include "Animation.h"
#include <map>
@ -69,20 +65,17 @@ public:
{
spriteType = sType;
if(sType == spriteAnimation)
{
std::string bogusPath = "src/config/credits.json";
std::ifstream fin(bogusPath);
{
std::ifstream fin(json);
if(fin.is_open()){
std::cout<<"file is open"<<std::endl;
} else {
std::cout<<"file is NOT open"<<std::endl;
std::cout<<"json file is NOT open"<<std::endl;
}
if(fin.fail()){
std::cout<<"file open fail"<<std::endl;
std::cout<<"json file open fail"<<std::endl;
} else{
std::cout<<"file open success"<<std::endl;
}
std::ifstream jsonText(json);
@ -92,35 +85,20 @@ public:
cJSON * animJson = cJSON_Parse(aJson.c_str());
cJSON * meta = cJSON_GetObjectItem(animJson, "meta");
cJSON * frameTags = cJSON_GetObjectItem(meta,"frameTags");
// printf("frameTags:\n%s\n",cJSON_Print(frameTags));
int tagsCount = cJSON_GetArraySize(frameTags);
// printf("number of tags: \n%d\n",tagsCount);
// cJSON * arrItem = cJSON_GetArrayItem(frameTags,0);
// cJSON * animItem = cJSON_GetArrayItem(frameTags, 0);
// printf("Animation item: \n%s\n",cJSON_Print(animItem));
// printf("arrItem: \n%s\n",cJSON_Print(arrItem));
for (int t = 0; t < tagsCount; t++)
{
// printf("Tag: \n%d\n",t);
// printf("tag number: \n%d\n",t);
cJSON * animItem = cJSON_GetArrayItem(frameTags,t);
// printf("Animation item: \n%s\n",cJSON_Print(animItem));
cJSON * nameJson = cJSON_GetObjectItem(animItem, "name");
const char * name = cJSON_Print(nameJson);
int fromFrame = cJSON_GetObjectItem(animItem, "from")->valueint;
int toFrame = cJSON_GetObjectItem(animItem, "to")->valueint;
Animation anim = Animation(fromFrame,toFrame,100);
animations.emplace(name, anim);
// printf("Playing animation named: %s fromFrame:%d toFrame:%d \n",name,fromFrame,toFrame);
Play(name);
}
// if(!animations.empty()){
// printf("animations found!\n");
// }else{
// printf("No animations\n");
// }
// Play("idle");
Animation idle = Animation(0,3,100);
animations.emplace("Idle", idle);
Animation walk = Animation(1,3,100);
@ -134,19 +112,6 @@ public:
setTex(id);
}
SpriteComponent(std::string id, SpriteType sType, char fontLetter, int letterW, int letterH, int letterScale)
{
spriteType = sType;
setTex(id);
// text = isText;
letter = fontLetter;
letterWidth = letterW;
letterHeight = letterH;
scale = letterScale;
destRect.w = letterW*letterScale;
destRect.h = letterH*letterScale;
}
SpriteComponent(std::string id, SpriteType sType, SDL_Rect srcR, SDL_Rect destR)
{
spriteType = sType;
@ -171,14 +136,6 @@ public:
switch(spriteType)
{
case spriteText:
srcRect.x = ((letter-ASCII_START_IDX) % ASCII_ROW_COUNT)*letterWidth;
srcRect.y = ((letter-ASCII_START_IDX)/ASCII_ROW_COUNT)*letterHeight;
srcRect.w = letterWidth;
srcRect.h = letterHeight;
destRect.w = letterWidth*scale;
destRect.h = letterHeight*scale;
break;
case spriteUIL0: case spriteUIL1: case spriteBackground:
break;
case spriteActor: case spriteAnimation: case spriteAtlas: case spriteObject: case spriteTileMap:

View File

@ -9,7 +9,7 @@
#define SRC_ECS_TILECOMPONENT_H_
#include "ECS.h"
#include "SDL2/SDL.h"
#include <SDL2/SDL.h>
#include "../assetmgr/AssetManager.h"
class TileComponent : public Component

163
src/ecs/TileMapComponent.h Normal file
View File

@ -0,0 +1,163 @@
/*
*
* TileMapComponent.h
*
* Created on: Mar 21, 2020
* Author: ayoungblood
*/
#ifndef SRC_ECS_TILEMAPCOMPONENT_H_
#define SRC_ECS_TILEMAPCOMPONENT_H_
#include "ECS.h"
#include <SDL2/SDL.h>
#include "../assetmgr/AssetManager.h"
#include <fstream>
#include <iostream>
#include <string>
#include <tuple>
#include "../tileson/tileson.hpp"
class TileMapComponent : public Component
{
public:
SDL_Texture* texture;
SDL_Rect srcRect, destRect;
tson::Tileson t;
std::unique_ptr<tson::Map> map;
int globalScale;
std::vector<SDL_Rect> tileSet;
std::vector<SDL_Rect> destRects;
std::vector<std::tuple<int,int>> initialPositions;
int tileSetTotal;
std::vector<std::vector<int>> colliders;
int tilesWide;
int tilesHigh;
int tileWidth;
TileMapComponent() = default;
~TileMapComponent()
{
SDL_DestroyTexture(texture);
}
TileMapComponent(std::string mapPath, int gScale, int offsetX, int offsetY)
{
// TILESON ~~~~~~~~~~~
const std::filesystem::path jsonPath = std::filesystem::u8path(mapPath);
map = t.parse(jsonPath);
if(map->getStatus() == tson::ParseStatus::OK)
{
tson::Tileset *tileset = map->getTileset("br-tiles");
std::string fullPath = tileset->getImage();
size_t charPos = fullPath.find("assets");
fullPath.erase(0,charPos);
tson::Layer *tileLayer = map->getLayer("Tile Layer 1"); //This is a Layer
std::string texName = tileLayer->getName();
Game::assets->AddTexture(texName, fullPath.c_str());
setTex(texName);
globalScale = gScale;
tson::Layer *collisionLayer = map->getLayer("Collision");
tilesWide = map->getSize().x;
tilesHigh = map->getSize().y;
tileWidth = map->getTileSize().x;
Game::levelMap.w = tilesWide*tileWidth*globalScale;
Game::levelMap.h = tilesHigh*tileWidth*globalScale;
// =========== Setup Tile Set ===========
tileSetTotal = tileset->getTileCount();
tileSet.resize(tileSetTotal);
int tileSetCols = tileset->getColumns();
int tileSetRows = tileSetTotal/tileSetCols;
for (int r=0;r<tileSetRows;r++){
for (int c=0;c<tileSetCols;c++){
srcRect.x = c*tileWidth;
srcRect.y = r*tileWidth;
srcRect.w = srcRect.h = tileWidth;
int element = r*tileSetCols+c;
tileSet[element] = srcRect;
}
}
if(tileLayer->getType() == tson::LayerType::TileLayer)
{
destRects.resize(tilesWide*tilesHigh);
initialPositions.resize(tilesWide*tilesHigh);
for (int r=0;r<tilesHigh;r++){
for (int c=0;c<tilesWide;c++){
int elem = c+r*tilesWide;
SDL_Rect thisRect = SDL_Rect();
thisRect.x = c*tileWidth*globalScale;
thisRect.y = r*tileWidth*globalScale;
thisRect.w = thisRect.h = tileWidth*globalScale;
std::tuple<int,int> ogPos = std::make_tuple(thisRect.x,thisRect.y);
initialPositions[elem] = ogPos;
thisRect.x = thisRect.x-offsetX*globalScale;
thisRect.y = thisRect.y=offsetY*globalScale;
destRects[elem] = thisRect;
}
}
destRect.w = destRect.h = tileWidth * gScale;
}
} else {
printf("Failed to load Tileson map\n");
std::cout << map->getStatusMessage();
}
}
void update() override
{
// if (Game::gsm->currentState == GameStateManager::ST_COREGAME){
for (int i=0;i<destRects.size();i++){
destRects[i].x = std::get<0>(initialPositions[i]) - Game::camera.x;
destRects[i].y = std::get<1>(initialPositions[i]) - Game::camera.y;
}
// }
}
void draw() override
{
//iterate through rows and columns of the map to draw the tiles
// First cycle through rows
tson::Layer *myLayer = map->getLayer("Tile Layer 1");
tson::Layer *collisionLayer = map->getLayer("Collision");
for (int r = 0;r<map->getSize().y;r++){
// Next cycle through each column or tile in that row:
for (int c = 0;c<map->getSize().x;c++){
int i = r*map->getSize().x+c;
int elem = c+r*map->getSize().x;
tson::Tile *myTile = myLayer->getTileData(c,r);
int tid = myTile->getId()-1;
int tileToDraw = tid;
TextureManager::Draw(texture, tileSet[tileToDraw], destRects[elem], SDL_FLIP_NONE);
if (Game::debugMenu){
if (collisionLayer->getTileData(c,r)) {
SDL_SetRenderDrawColor(Game::renderer,255,0,255,134);
SDL_RenderDrawRect(Game::renderer, &destRects[elem]);
}
}
}
}
}
void setTex(std::string id)
{
texture = Game::assets->GetTexture(id);
}
};
#endif /* SRC_ECS_TILEMAPCOMPONENT_H_ */

View File

@ -18,11 +18,13 @@ public:
Vector2D position;
Vector2D velocity;
// Vector2D lastSafePos;
Vector2D tilePos;
int height = 40;
int width = 30;
int scale = 1;
int speed = 2;
int speed = 1;
TransformComponent()
{
@ -37,10 +39,10 @@ public:
speed = speed*sc;
}
TransformComponent(float x, float y)
{
position.Zero();
}
// TransformComponent(float x, float y)
// {
// position.Zero();
// }
TransformComponent(int x, int y, int w, int h, int sc)
{
@ -52,16 +54,32 @@ public:
speed = speed*sc;
}
TransformComponent(int x, int y, int w, int h, int sc, int spd)
{
position.x = x;
position.y = y;
width = w;
height = h;
scale = sc;
speed = spd*sc;
}
void init() override
{
velocity.Zero();
tilePos.Zero();
// lastSafePos.Zero();
}
void update() override
{
position.x += velocity.x * speed;
position.y += velocity.y * speed;
}
void updateTilePosition(int x,int y){
tilePos.x = x;
tilePos.y = y;
}
};

View File

@ -1,83 +0,0 @@
/*
* UIFontComponent.h
*
* Created on: May 14, 2020
* Author: ayoungblood
*/
#ifndef SRC_ECS_UIFONTCOMPONENT_H_
#define SRC_ECS_UIFONTCOMPONENT_H_
#define ASCII_START_IDX 32
#define ASCII_COUNT 96
#define ASCII_ROW_COUNT 16
#include "Components.h"
#include "SDL2/SDL.h"
#include "../assetmgr/AssetManager.h"
class UIFontComponent : public Component
{
private:
// SDL_Texture * texture;
// Font dimensions
int _LetterWidth;
int _LetterHeight;
// Track current letter on texture
SDL_Rect _LetterClips[ASCII_COUNT];
public:
// SDL_RendererFlip spriteFlip = SDL_FLIP_NONE;
SDL_Texture* texture;
SDL_Rect srcRect, destRect;
Vector2D position;
// UIFontComponent() = default;
UIFontComponent(std::string id, int letterW, int letterH, int xpos, int ypos, int scale)
{
texture = Game::assets->GetTexture(id);
srcRect = UIFontComponent::SetCharClips(texture, xpos, ypos);
position.x = xpos;
position.y = ypos;
destRect.x = xpos;
destRect.y = ypos;
destRect.w = letterW * scale;
destRect.h = letterH * scale;
}
~UIFontComponent()
{
SDL_DestroyTexture(texture);
}
void update() override
{
}
void draw() override
{
TextureManager::Draw(texture, srcRect, destRect, SDL_FLIP_NONE);
}
SDL_Rect SetCharClips(SDL_Texture* fontTex, int x, int y)
{
SDL_Rect letterClip;
for (int i = 0; i < ASCII_COUNT; ++i)
{
_LetterClips[i].x = x + ((i % ASCII_ROW_COUNT) * _LetterWidth);
_LetterClips[i].y = y + ((i / ASCII_ROW_COUNT) * _LetterHeight);
_LetterClips[i].w = _LetterWidth;
_LetterClips[i].h = _LetterHeight;
letterClip = _LetterClips[i];
}
return letterClip;
}
};
#endif /* SRC_ECS_UIFONTCOMPONENT_H_ */

101
src/ecs/UITextComponent.h Normal file
View File

@ -0,0 +1,101 @@
/*
* UITextComponent.h
*
* Created on: Feb 22, 2020
* Author: ayoungblood
*/
#ifndef SRC_ECS_UITEXTCOMPONENT_H_
#define SRC_ECS_UITEXTCOMPONENT_H_
#define ASCII_START_IDX 32
#define ASCII_COUNT 96
#define ASCII_ROW_COUNT 16
#include "Components.h"
#include <SDL2/SDL.h>
#include "../assetmgr/TextureManager.h"
#include "../assetmgr/AssetManager.h"
#include <stdio.h>
#include <string>
#include <iostream>
#include <tuple>
#include <cmath>
class UITextComponent : public Component
{
private:
TransformComponent *transform;
SDL_Texture *texture;
SDL_Rect srcRect, destRect;
std::string text;
int letterWidth, letterHeight;
int scale = 1;
SDL_RendererFlip spriteFlip = SDL_FLIP_NONE;
std::tuple <SDL_Rect, SDL_Rect> letter;
public:
UITextComponent(std::string id, std::string textToPrint, int letterW, int letterH, int letterScale)
{
setTex(id);
text = textToPrint;
letterWidth = letterW;
letterHeight = letterH;
scale = letterScale;
}
~UITextComponent()
{
SDL_DestroyTexture(texture);
}
void setTex(std::string id)
{
texture = Game::assets->GetTexture(id);
}
void init() override
{
transform = &entity->getComponent<TransformComponent>();
}
void update() override
{
destRect.x = static_cast<int>(transform->position.x);
destRect.y = static_cast<int>(transform->position.y);
}
void draw() override
{
for (int l = 0; l < text.length(); l++)
{
std::tuple<SDL_Rect, SDL_Rect> lttr = getLetterTexture(text[l],l);
TextureManager::Draw(texture, std::get<0>(lttr), std::get<1>(lttr), spriteFlip);
}
}
std::tuple<SDL_Rect, SDL_Rect> getLetterTexture(char currentLetter, int i)
{
std::tuple<SDL_Rect, SDL_Rect> letterTuple;
int charsPerLine = std::floor(transform->width/(letterWidth*scale));
srcRect.x = ((currentLetter-ASCII_START_IDX) % ASCII_ROW_COUNT)*letterWidth;
srcRect.y = ((currentLetter-ASCII_START_IDX)/ASCII_ROW_COUNT)*letterHeight;
srcRect.w = letterWidth;
srcRect.h = letterHeight;
destRect.x = static_cast<int>(transform->position.x)*scale+(i%charsPerLine)*letterWidth*scale;
destRect.y = static_cast<int>(transform->position.y)*scale+std::floor(i/charsPerLine)*letterHeight*scale*1.1;
destRect.w = letterWidth*scale;
destRect.h = letterHeight*scale;
letterTuple = std::make_tuple(srcRect,destRect);
return letterTuple;
}
void updateString(std::string newString)
{
text = newString;
}
};
#endif /* SRC_ECS_UITEXTCOMPONENT_H_ */

View File

@ -11,15 +11,14 @@
bool Collision::AABB(const SDL_Rect& recA, const SDL_Rect& recB)
{
if(
recA.x + recA.w >= recB.x &&
recB.x + recB.w >= recA.x &&
recA.y + recA.h >= recB.y &&
recB.y + recB.h >= recA.y
recA.x + recA.w > recB.x &&
recB.x + recB.w > recA.x &&
recA.y + recA.h > recB.y &&
recB.y + recB.h > recA.y
)
{
{
return true;
}
return false;
}
@ -27,7 +26,6 @@ bool Collision::AABB(const ColliderComponent& colA, const ColliderComponent& col
{
if(AABB(colA.collider, colB.collider))
{
// std::cout << colA.tag << " hit: " << colB.tag << std::endl;
return true;
}
else

View File

@ -9,6 +9,7 @@
#define SRC_COLLISION_H_
#include <SDL2/SDL.h>
// #include "Vector2D.h"
class ColliderComponent;

View File

@ -21,44 +21,74 @@
#include "../ui/UIText.h"
#include "../ui/UINineSlice.h"
#include "../cjson/cJSON.h"
#include "../tileson/tileson.hpp"
#include <cmath>
#include <filesystem>
Map* map;
Manager manager;
UIText* text;
UINineSlice* my9Slice;
UIText* scoreboardText;
UINineSlice* scoreboard9Slice;
UINineSlice* debugBox;
GameStateManager* Game::gsm = new GameStateManager();
SDL_Renderer* Game::renderer = nullptr;
SDL_Event Game::event;
SDL_Rect Game::camera;
SDL_Rect Game::levelMap;
AssetManager* Game::assets = new AssetManager(&manager);
bool Game::isRunning = false;
bool Game::debugMenu = false;
auto& player(manager.addEntity());
Vector2D Game::playerPosition;
Vector2D Game::pVel;
// auto& enemy(manager.addEntity());
auto& puppy(manager.addEntity());
// auto& scoreboard(manager.addEntity());
auto& uiInfo(manager.addEntity());
auto& uiJumpInfo(manager.addEntity());
auto& uiCamXInfo(manager.addEntity());
auto& uiCamYInfo(manager.addEntity());
auto& uiPlayerXInfo(manager.addEntity());
auto& uiPlayerYInfo(manager.addEntity());
auto& uiBoundary1Info(manager.addEntity());
auto& uiBoundary2Info(manager.addEntity());
auto& uiBoundary3Info(manager.addEntity());
auto& uiTextInstructions(manager.addEntity());
auto& gameScene(manager.addEntity());
bool Game::debugCollisionBoxes = false;
bool Game::gravityOnPlayer = true;
bool Game::playerIsGrounded = false;
bool Game::playerIsJumping = false;
int gScale = 0;
int last_time;
int current_time;
int diff_time;
tson::Tileson t;
int Game::pTileX = 0;
int Game::pTileY = 0;
std::string Game::BoolToString(bool b) {
std::string myString;
if (b) {
myString = "true";
} else {
myString = "false";
}
return myString;
}
Game::Game() {
// TODO Auto-generated constructor stub
@ -82,6 +112,7 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
if(SDL_Init(SDL_INIT_EVERYTHING) == 0)
{
window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, flags);
SDL_SetWindowBordered(window,SDL_FALSE);
if(!window)
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Couldn't create window: %s", SDL_GetError());
@ -103,14 +134,12 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
{
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Couldn't initialize SDL audio mixer!, Error: %s", SDL_GetError());
}
// current_time = SDL_GetTicks();
assets->AddTexture("terrain", "assets/textures/tiles/br-tiles.png");
assets->AddTexture("player", "assets/textures/actors/firefighter.png");
assets->AddTexture("font", "assets/textures/ui/ui-font-cloud-sans.png");
assets->AddTexture("textBox", "assets/textures/ui/ui-element-cloud.png");
assets->AddTexture("puppy","assets/textures/actors/beaglepuppy.png");
assets->AddTexture("collider","assets/textures/ColTex.png");
assets->AddMusicTrack("simonZ","assets/audio/music/sillypuppy.ogg");
assets->AddMusicTrack("simonZ","assets/audio/music/victory.ogg");
@ -119,57 +148,98 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
assets->AddSoundClip("bark1","assets/audio/sfx/Bark1.wav");
assets->AddSoundClip("bark2","assets/audio/sfx/Bark2.wav");
map = new Map("terrain",globalScale,16);
std::string myText = "Find lost puppies!\nThey need your help!";
text = new UIText(myText, "font", 0, 0, 8, 12, globalScale);
text->ParseString(myText, 12, 22, globalScale, "text");
// map = new Map("terrain",globalScale,16);
// std::string myText = "Find lost puppies!\nThey need your help!";
std::string myText = "Press U to Start";
uiTextInstructions.addComponent<TransformComponent>(18,22,138*gScale,20*gScale,gScale);
uiTextInstructions.addComponent<UITextComponent>("font",myText,8,12,gScale);
uiTextInstructions.addGroup(groupUI_Layer1);
SDL_Rect myDestRect = SDL_Rect();
myDestRect.x = 12;
myDestRect.y = 8;
myDestRect.w = 160;
myDestRect.h = 40;
my9Slice = new UINineSlice("textBox");
my9Slice->MakeSlices("textBox",32,32,14,16,14,16,myDestRect,globalScale);
my9Slice->MakeSlices("textBox",32,32,14,16,14,16,myDestRect,globalScale,Game::groupUI_Layer0);
// std::cout << "camera.w " << camera.w << std::endl;
uiInfo.addComponent<TransformComponent>(camera.w/gScale-94,10,72*gScale,96*gScale,gScale);
// uiInfo.addComponent<UITextComponent>("font", "CollisionHori: Vert: Jump: P.y : P.dy: YVec: ", 8, 12, 1);
// uiInfo.addComponent<UITextComponent>("font", "Player PTiX: PTiY: P.x: P.y : coll: Px2: tson: ", 8, 12, gScale);
uiInfo.addComponent<UITextComponent>("font", "Player PTiX: PTiY: P.x: P.y : coll: ", 8, 12, gScale);
uiInfo.addGroup(groupUI_Layer3);
uiCamXInfo.addComponent<TransformComponent>(camera.w/gScale-48,23,40*gScale,12*gScale,gScale);
uiCamXInfo.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
uiCamXInfo.addGroup(groupUI_Layer3);
uiCamYInfo.addComponent<TransformComponent>(camera.w/gScale-48,36,40*gScale,12*gScale,gScale);
uiCamYInfo.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
uiCamYInfo.addGroup(groupUI_Layer3);
uiPlayerXInfo.addComponent<TransformComponent>(camera.w/gScale-49,49,40*gScale,12*gScale,gScale);
uiPlayerXInfo.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
uiPlayerXInfo.addGroup(groupUI_Layer3);
uiPlayerYInfo.addComponent<TransformComponent>(camera.w/gScale-48,62,40*gScale,12*gScale,gScale);
uiPlayerYInfo.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
uiPlayerYInfo.addGroup(groupUI_Layer3);
uiBoundary1Info.addComponent<TransformComponent>(camera.w/gScale-48,75,128*gScale,12*gScale,gScale);
uiBoundary1Info.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
uiBoundary1Info.addGroup(groupUI_Layer3);
// uiBoundary2Info.addComponent<TransformComponent>(camera.w/gScale-64,88,128*gScale,12*gScale,gScale);
// uiBoundary2Info.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
// uiBoundary2Info.addGroup(groupUI_Layer3);
//
// uiBoundary3Info.addComponent<TransformComponent>(camera.w/gScale-64,101,128*gScale,12*gScale,gScale);
// uiBoundary3Info.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
// uiBoundary3Info.addGroup(groupUI_Layer3);
// debug UI box
SDL_Rect debugBoxRect = SDL_Rect();
debugBoxRect.x = camera.w-(100*gScale);
debugBoxRect.y = 4*gScale;
debugBoxRect.w = 98*gScale;
debugBoxRect.h = 112*gScale;
debugBox = new UINineSlice("textBox");
debugBox->MakeSlices("textBox",32,32,14,16,14,16,debugBoxRect,1,Game::groupUI_Layer2);
//ecs implementation
map->LoadMap("assets/maps/br-map-color.txt",70,45, globalScale);
player.addComponent<TransformComponent>(860*globalScale,630*globalScale,22,42,globalScale);
// player.addComponent<TransformComponent>(150*globalScale,80*globalScale,40,40,globalScale);
// player.addComponent<TransformComponent>(860*globalScale,640*globalScale,22,42,globalScale);
player.addComponent<TransformComponent>(150*gScale,100*gScale,22,42,globalScale,3); // 180,120
player.addComponent<SpriteComponent>("player", SpriteComponent::spriteAnimation, "assets/textures/actors/firefighter.json");
// player.addComponent<PlayerController>(0.0,0.0,false,false,Vector2D().Zero());
player.addComponent<ColliderComponent>("player",16*globalScale,32*globalScale, true, 2*globalScale,10*globalScale, "collider");
player.addComponent<KeyboardController>();
player.addComponent<ColliderComponent>("player",8*globalScale,8*globalScale, true, 7*globalScale,36*globalScale);
player.addGroup(groupPlayers);
levelMap.x = 0;
levelMap.y = 0;
gameScene.addComponent<TileMapComponent>("assets/maps/testmap.json",gScale,player.getComponent<TransformComponent>().position.x+player.getComponent<TransformComponent>().width/2,player.getComponent<TransformComponent>().position.y+player.getComponent<TransformComponent>().height/2); //150,100
gameScene.addGroup(groupMap);
playerPosition = Vector2D().Zero();
pVel = Vector2D().Zero();
puppy.addComponent<TransformComponent>(1024*globalScale,210*globalScale,36,30,globalScale);
puppy.addComponent<SpriteComponent>("puppy", SpriteComponent::spriteObject);
puppy.addGroup(groupObjects);
// const char* strA = "r";
// const char* strB = "r";
//
// if (strcmp(strA,strB)==0)
// {
// printf("strcomp evaluated to true");
// } else {
// printf("strcomp false or not evaluated");
// }
// enemy.addComponent<TransformComponent>(180*globalScale,180*globalScale,32,32,globalScale);
// enemy.addComponent<SpriteComponent>("robber", SpriteComponent::spriteAnimation, "assets/textures/actors/robberrodent.json");
// enemy.addGroup(groupEnemies);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't Initialize SDL: %s", SDL_GetError());
isRunning = false;
}
}
//camera.x = camera.x*globalScale;
// ====== Setup groups
auto& tiles(manager.getGroup(Game::groupMap));
auto& players(manager.getGroup(Game::groupPlayers));
auto& colliders(manager.getGroup(Game::groupColliders));
@ -178,7 +248,8 @@ auto& objects(manager.getGroup(Game::groupObjects));
// auto& projectiles(manager.getGroup(Game::groupProjectiles));
auto& gui(manager.getGroup(Game::groupUI_Layer0));
auto& uiText(manager.getGroup(Game::groupUI_Layer1));
auto& debugBG(manager.getGroup(Game::groupUI_Layer2));
auto& debugText(manager.getGroup(Game::groupUI_Layer3));
void Game::handleEvents()
{
@ -207,11 +278,10 @@ void Game::update()
// const char* gameOverText = "Game Over";
// }
if (Mix_PlayingMusic() == 0 && gsm->currentState == GameStateManager::ST_COREGAME)
{
// std::cout << "Play Music Now" << std::endl;
Mix_PlayMusic(assets->GetMusicTrack("simonZ"), -1);
// Mix_PlayMusic(assets->GetMusicTrack("simonZ"), -1);
}
if (Mix_PlayingMusic() != 0 && gsm->currentState != GameStateManager::ST_COREGAME)
{
@ -230,20 +300,25 @@ void Game::update()
SDL_Rect cCol = c->getComponent<ColliderComponent>().collider;
if(Collision::AABB(cCol, playerCol))
{
// printf("Collision detected!\nplayerIsGrounded:%d if 0: idle plays\n",playerIsGrounded);
if(!playerIsGrounded){
player.getComponent<SpriteComponent>().Play("Idle");
}
gravityOnPlayer = false;
playerIsGrounded = true;
// if(!playerIsGrounded){
// player.getComponent<SpriteComponent>().Play("Idle");
// }
// playerIsGrounded = true;
// player.getComponent<TransformComponent>().position.y = player.getComponent<TransformComponent>().lastSafePos.y;
// gravityOnPlayer = false;
}
}
// Gravity
if (gravityOnPlayer){
player.getComponent<TransformComponent>().position.y += 10;
}
// if (gravityOnPlayer){
// player.getComponent<TransformComponent>().position.y += 3*gScale;
// uiJumpInfo.getComponent<UITextComponent>().updateString("true");
// } else {
// uiJumpInfo.getComponent<UITextComponent>().updateString("false");
// }
// for(auto& p: projectiles)
// {
// if(Collision::AABB(player.getComponent<ColliderComponent>().collider, p->getComponent<ColliderComponent>().collider))
@ -253,17 +328,81 @@ void Game::update()
// }
// }
camera.x = player.getComponent<TransformComponent>().position.x - camera.w/2;
camera.y = player.getComponent<TransformComponent>().position.y - camera.h/2;
auto& tileMap = gameScene.getComponent<TileMapComponent>();
camera.x = player.getComponent<TransformComponent>().position.x - camera.w/2 + player.getComponent<TransformComponent>().width/2;
camera.y = player.getComponent<TransformComponent>().position.y - camera.h/2 + player.getComponent<TransformComponent>().height/2;
pTileX = (player.getComponent<TransformComponent>().position.x+player.getComponent<TransformComponent>().width/2)/gScale/tileMap.tileWidth;
pTileY = (player.getComponent<TransformComponent>().position.y+player.getComponent<TransformComponent>().height/2)/gScale/tileMap.tileWidth;
player.getComponent<TransformComponent>().updateTilePosition(pTileX,pTileY);
uiCamXInfo.getComponent<UITextComponent>().updateString(std::to_string((int)player.getComponent<TransformComponent>().tilePos.x));
uiCamYInfo.getComponent<UITextComponent>().updateString(std::to_string((int)player.getComponent<TransformComponent>().tilePos.y));
int playerX = player.getComponent<TransformComponent>().position.x;
int playerY = player.getComponent<TransformComponent>().position.y;
uiPlayerXInfo.getComponent<UITextComponent>().updateString(std::to_string(playerX));
uiPlayerYInfo.getComponent<UITextComponent>().updateString(std::to_string(playerY));
// int * foundBoundaries = predictCollisions();
// int max = foundBoundaries[0];
// for (int b=0;b<3;b++){
// if (foundBoundaries[b]>max){
// max = foundBoundaries[b];
// }
// }
float desiredMovementX = -1*player.getComponent<TransformComponent>().speed*0.016;
// int desiredMovementY = player.getComponent<TransformComponent>().velocity.y*player.getComponent<TransformComponent>().speed*player.getComponent<TransformComponent>().scale;
// uiBoundary1Info.getComponent<UITextComponent>().updateString(std::to_string((int)foundBoundaries[0]));
// uiBoundary1Info.getComponent<UITextComponent>().updateString(std::to_string((float)desiredMovementX));
if (playerIsGrounded) {
uiBoundary1Info.getComponent<UITextComponent>().updateString("yes");
} else {
uiBoundary1Info.getComponent<UITextComponent>().updateString("no");
}
// uiBoundary2Info.getComponent<UITextComponent>().updateString(std::to_string((int)foundBoundaries[1]));
float difference = player.getComponent<TransformComponent>().position.x+desiredMovementX;
//uiBoundary2Info.getComponent<UITextComponent>().updateString(std::to_string((float)difference));
//uiBoundary3Info.getComponent<UITextComponent>().updateString(std::to_string((int)(max*gScale)));
// uiBoundary3Info.getComponent<UITextComponent>().updateString(std::to_string((int)foundBoundaries[2]));
playerPosition.x = playerX;
playerPosition.y = playerY;
pVel.x = player.getComponent<TransformComponent>().velocity.x;
pVel.y = player.getComponent<TransformComponent>().velocity.y;
if(camera.x < 0)
camera.x = 0;
if (camera.y < 0)
camera.y = 0;
if (camera.x > map->width-camera.w)
camera.x = map->width-camera.w;
if (camera.y > map->height-camera.h)
camera.y = map->height-camera.h;
if (camera.x > levelMap.w-camera.w)
camera.x = levelMap.w-camera.w;
if (camera.y > levelMap.h-camera.h)
camera.y = levelMap.h-camera.h;
if (Game::debugCollisionBoxes)
{
for (auto& c: colliders)
{
c->getComponent<ColliderComponent>().hidden = false;
}
for (auto& p: players)
{
p->getComponent<ColliderComponent>().hidden = false;
}
} else {
for (auto& c: colliders)
{
c->getComponent<ColliderComponent>().hidden = true;
}
for (auto& p: players)
{
p->getComponent<ColliderComponent>().hidden = true;
}
}
}
void Game::render()
@ -277,14 +416,12 @@ void Game::render()
{
t->draw();
}
if (Game::debugCollisionBoxes)
for (auto& c : colliders)
{
for (auto& c : colliders)
{
c->draw();
}
c->draw();
}
for (auto& o : objects)
{
o->draw();
@ -304,13 +441,23 @@ void Game::render()
{
guiElement->draw();
}
for (auto& letter : uiText)
for (auto& text : uiText)
{
letter->draw();
text->draw();
}
}
if (debugMenu)
{
for (auto& guiElement : debugBG)
{
guiElement->draw();
}
for (auto& text : debugText)
{
text->draw();
}
}
SDL_RenderPresent(renderer);
}
@ -324,14 +471,84 @@ void Game::clean()
printf("Game Cleaned\n");
}
void Game::printDebug(char* debugInfo)
{
printf("%s",debugInfo);
printf("\n");
}
void Game::drawLine(Vector2D srcpt, Vector2D destpt, int red, int green, int blue)
{
SDL_SetRenderDrawColor(renderer, red, green, blue, 255);
SDL_SetRenderDrawColor(renderer, red, green, blue, 200);
SDL_RenderDrawLine(renderer, srcpt.x, srcpt.y, destpt.x, destpt.y);
}
int * Game::predictCollisions(){
static int boundaries[3];
// ===== LEFT =====
/*if (player.getComponent<TransformComponent>().velocity.x<0){
// ====== For Each Row ====
int i = 0;
for (int r=Game::pTileY-1;r<=Game::pTileY+1;r++){
// ====== For Each Tile (Column) =====
if(r<0){r=0;}
for (int c=Game::pTileX;c>Game::pTileX-Game::camera.w/gameScene.getComponent<TileMapComponent>().tileWidth;c--){
if(c<0){c=0;}
if(gameScene.getComponent<TileMapComponent>().colliders[r][c]>0){
boundaries[i] = c*gameScene.getComponent<TileMapComponent>().tileWidth+gameScene.getComponent<TileMapComponent>().tileWidth;
i++;
break;
}
}
}
}*/
/*
// ====== RIGHT ====
if (player.getComponent<TransformComponent>().velocity.x>0){
// ====== For Each Row ====
int i = 0;
for (int r=Game::pTileY-1;r<=Game::pTileY+1;r++){
if(r<0){r=0;}
// ====== For Each Tile (Column) =====
for (int c=Game::pTileX;c<Game::pTileX+Game::camera.w/gameScene.getComponent<TileMapComponent>().tileWidth;c++){
if(c<0){c=0;}
if(gameScene.getComponent<TileMapComponent>().colliders[r][c]>0){
boundaries[i] = c*gameScene.getComponent<TileMapComponent>().tileWidth;
i++;
break;
}
}
}
}
// ===== UP ====
if (player.getComponent<TransformComponent>().velocity.y<0){
// ====== For Each Column ====
int i = 0;
for (int c=Game::pTileX-1;c<=Game::pTileX+1;c++){
if(c<0){c=0;}
// ====== For Each Tile (Row) =====
for (int r=Game::pTileY;r>Game::pTileY-Game::camera.h/gameScene.getComponent<TileMapComponent>().tileWidth;r--){
if(r<0){r=0;}
if(gameScene.getComponent<TileMapComponent>().colliders[r][c]>0){
boundaries[i] = r*gameScene.getComponent<TileMapComponent>().tileWidth+gameScene.getComponent<TileMapComponent>().tileWidth;
i++;
break;
}
}
}
}
// ===== DOWN ====
if (player.getComponent<TransformComponent>().velocity.y>0){
// ====== For Each Column ====
int i = 0;
for (int c=Game::pTileX-1;c<=Game::pTileX+1;c++){
if(c<0){c=0;}
// ====== For Each Tile (Row) =====
for (int r=Game::pTileY;r<Game::pTileY+Game::camera.h/gameScene.getComponent<TileMapComponent>().tileWidth;r++){
if(r<0){r=0;}
if(gameScene.getComponent<TileMapComponent>().colliders[r][c]>0){
boundaries[i] = r*gameScene.getComponent<TileMapComponent>().tileWidth+gameScene.getComponent<TileMapComponent>().tileWidth;
i++;
break;
}
}
}
}
*/
return boundaries;
}

View File

@ -7,15 +7,18 @@
#ifndef GAME_HPP_
#define GAME_HPP_
#include "SDL2/SDL.h"
#include "SDL2/SDL_image.h"
#include "SDL2/SDL_mixer.h"
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_mixer.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include "Vector2D.h"
#include "../assetmgr/AssetManager.h"
#include "GameStateManager.h"
//#include "../../libtmx-parser/src/tmxparser.h"
//#include "libtmx-parser/src/tmxparser.h"
//#include <tmxparser.h>
class ColliderComponent;
class AssetManager;
@ -29,20 +32,32 @@ public:
void update();
void render();
void clean();
void printDebug(char* debugInfo);
// void printDebug(std::string debugInfo);
static void drawLine(Vector2D srcpt, Vector2D destpt, int red, int green, int blue);
static int * predictCollisions();
bool running() { return isRunning; }
// static void AddTile(int srcX, int srcY, int xpos, int ypos);
static SDL_Renderer *renderer;
static SDL_Event event;
// static std::vector<ColliderComponent*> colliders;
// static tmxparser::TmxMap map;
// gameScene;
static bool debugMenu;
static bool isRunning;
static bool debugCollisionBoxes;
static bool gravityOnPlayer;
static bool playerIsGrounded;
static bool playerIsJumping;
static Vector2D playerPosition;
static Vector2D pVel;
static SDL_Rect camera;
static SDL_Rect levelMap;
static AssetManager* assets;
static GameStateManager* gsm;
static int pTileX;
static int pTileY;
std::string BoolToString(bool b);
enum groupLabels : std::size_t
{
groupMap,
@ -53,7 +68,9 @@ public:
groupObjects,
groupBackground,
groupUI_Layer0,
groupUI_Layer1
groupUI_Layer1,
groupUI_Layer2,
groupUI_Layer3
};
private:
int counter = 0;

View File

@ -19,7 +19,7 @@ int main(int argc, const char * argv[])
const int FPS = 60;
const int frameDelay = 1000 / FPS;
Uint32 frameStart;
Uint64 frameStart;
int frameTime;
// =============================
@ -30,7 +30,6 @@ int main(int argc, const char * argv[])
std::ifstream fin(configPath);
if(fin.is_open()){
// std::cout<<"config.json is opened successfully"<<std::endl;
std::ifstream jsonText("src/config/config.json");
std::ostringstream tmp;
tmp << jsonText.rdbuf();
@ -59,13 +58,13 @@ int main(int argc, const char * argv[])
while (game->running())
{
frameStart = SDL_GetTicks();
frameStart = SDL_GetTicks64();
game->handleEvents();
game->update();
game->render();
frameTime = SDL_GetTicks() - frameStart;
frameTime = SDL_GetTicks64() - frameStart;
if(frameDelay > frameTime)
{
@ -80,9 +79,7 @@ int main(int argc, const char * argv[])
if(fin.fail()){
std::cout<<"config.json load failed"<<std::endl;
} else{
// std::cout<<"config.json loaded"<<std::endl;
}
}
return 0;
}

View File

@ -74,11 +74,3 @@ void StateMachine::StateEngine(void)
}
}
}
// unsigned char getCurrentState()
// {
// const StateStruct* pStateMap = GetStateMap();
// this->*pStateMap[currentState];
// unsigned char state = StateMachine.currentState;
// return state;
// }

8992
src/tileson/tileson.hpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ UINineSlice::~UINineSlice()
}
void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, int x1, int y0, int y1, SDL_Rect finalRect,int scale)
void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, int x1, int y0, int y1, SDL_Rect finalRect,int scale, Game::groupLabels group)
{
// Note about the variables: The source texture is what everything is drawn from, with srcW and srcH defining the size of that texture and x0 x1 being the vertical slices position across the x axis, and the y0, y1 being the horizontal slices. This is also in the project readme with an ASCII art diagram. finalRect refers to the Rectangle that describes the area of the screen in which we want the 9-sliced source to appear in it's final in-game rendering.
@ -49,20 +49,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
finalRect.w = finalRect.w*scale;
finalRect.h = finalRect.h*scale;
// x0 = x0*scale;
// x1 = x1*scale;
// y0 = y0*scale;
// y1 = y1*scale;
// printf("finalRect x:%d, y:%d, w:%d, h:%d \n",finalRect.x,finalRect.y,finalRect.w,finalRect.h);
// destRect.x = destRect.x*scale;
// destRect.y = destRect.y*scale;
// destRect.w = destRect.w*scale;
// destRect.h = destRect.h*scale;
// colsRemainder = colsRemainder*scale;
// rowsRemainder = rowsRemainder*scale;
for (int i=0; i<9; i++)
{
switch(i)
@ -72,7 +58,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
srcRect.y = 0;
srcRect.w = x0;
srcRect.h = y0;
// printf("tile zero.w or x0: %d\n",x0);
destRect.w = srcRect.w;
destRect.h = srcRect.h;
break;
@ -91,8 +76,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
srcRect.h = y0;
destRect.w = srcRect.w;
destRect.h = srcRect.h;
// printf("srcRect.x: %d",srcRect.x);
// printf("UI9Slice #2 srcRect x:%d y:%d w:%d h:%d \n",srcRect.x,srcRect.y,srcRect.w,srcRect.h);
break;
case 3:
srcRect.x = 0;
@ -150,14 +133,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
destRect.w = 0;
destRect.h = 0;
}
// These will be the same for each SDL_Rect except if there's a scaling int, which still needs to be implemented
// destRect.w = srcRect.w*scale;
// destRect.h = srcRect.h*scale;
// x0 = x0*scale;
// x1 = x1*scale;
// y0 = y0*scale;
// y1 = y1*scale;
// Calculate where and how many tiles to place
// We only need one instance of each of these in each corner or slices 0,2,6,8
@ -183,10 +158,7 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
destRect.x = finalRect.x+(finalRect.w-srcRect.w*scale);
destRect.y = finalRect.y+(finalRect.h-srcRect.h*scale);
}
AddSlice(srcRect,destRect,scale);
// printf("Corner Slice\n");
// printf("srcRect x:%d, y:%d, w:%d, h:%d \n",srcRect.x,srcRect.y,srcRect.w,srcRect.h);
// printf("destRect x:%d, y:%d, w:%d, h:%d \n\n",destRect.x,destRect.y,destRect.w,destRect.h);
AddSlice(srcRect,destRect,scale,group);
}
// Slices 1,7 need to be repeated in a row
if (i==1||i==7)
@ -197,20 +169,14 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
{
destRect.x = finalRect.x+(x0*scale+c*(x1*scale-x0*scale));
destRect.y = finalRect.y;
AddSlice(srcRect,destRect,scale);
// printf("Top Slice (1) \n");
// printf("srcRect x:%d, y:%d, w:%d, h:%d \n",srcRect.x,srcRect.y,srcRect.w,srcRect.h);
// printf("destRect x:%d, y:%d, w:%d, h:%d \n\n",destRect.x,destRect.y,destRect.w,destRect.h);
AddSlice(srcRect,destRect,scale,group);
}
if (colsRemainder>0){
destRect.x = finalRect.x+(x0*scale+cols*(x1*scale-x0*scale));
destRect.y = finalRect.y;
srcRect.w = colsRemainder;
destRect.w = colsRemainder;
AddSlice(srcRect,destRect,scale);
// printf("Top Slice (1) \n");
// printf("srcRect x:%d, y:%d, w:%d, h:%d \n",srcRect.x,srcRect.y,srcRect.w,srcRect.h);
// printf("destRect x:%d, y:%d, w:%d, h:%d \n\n",destRect.x,destRect.y,destRect.w,destRect.h);
AddSlice(srcRect,destRect,scale,group);
}
}
if (i==7)
@ -219,16 +185,14 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
{
destRect.x = finalRect.x+(x0*scale+c*(x1*scale-x0*scale));
destRect.y = finalRect.y+(finalRect.h-(srcH-y1)*scale);
AddSlice(srcRect,destRect,scale);
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
AddSlice(srcRect,destRect,scale,group);
}
if (colsRemainder>0){
destRect.x = finalRect.x+(x0*scale+cols*(x1*scale-x0*scale));
destRect.y = finalRect.y+(finalRect.h-(srcH-y1)*scale);
srcRect.w = colsRemainder;
destRect.w = colsRemainder;
AddSlice(srcRect,destRect,scale);
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
AddSlice(srcRect,destRect,scale,group);
}
}
}
@ -241,16 +205,14 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
{
destRect.x = finalRect.x;
destRect.y = finalRect.y+(y0*scale+r*(y1-y0)*scale);
AddSlice(srcRect,destRect,scale);
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
AddSlice(srcRect,destRect,scale,group);
}
if (rowsRemainder>0){
destRect.x = finalRect.x;
destRect.y = finalRect.y+(y0*scale+rows*(y1-y0)*scale);
srcRect.h = rowsRemainder;
destRect.h = rowsRemainder;
AddSlice(srcRect,destRect,scale);
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
AddSlice(srcRect,destRect,scale,group);
}
}
if (i==5)
@ -259,16 +221,14 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
{
destRect.x = finalRect.x+(finalRect.w-(srcW-x1)*scale);
destRect.y = finalRect.y+(y0*scale+r*(y1-y0)*scale);
AddSlice(srcRect,destRect,scale);
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
AddSlice(srcRect,destRect,scale,group);
}
if (rowsRemainder>0){
destRect.x = finalRect.x+(finalRect.w-(srcW-x1)*scale);
destRect.y = finalRect.y+(y0*scale+rows*(y1-y0)*scale);
srcRect.h = rowsRemainder;
destRect.h = rowsRemainder;
AddSlice(srcRect,destRect,scale);
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
AddSlice(srcRect,destRect,scale,group);
}
}
}
@ -283,8 +243,7 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
{
destRect.x = finalRect.x+(x0*scale+c*(x1-x0)*scale);
destRect.y = finalRect.y+(y0*scale+rowY*scale);
AddSlice(srcRect,destRect,scale);
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
AddSlice(srcRect,destRect,scale,group);
}
if (colsRemainder>0)
{
@ -292,8 +251,7 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
destRect.y = finalRect.y+(y0*scale+rowY*scale);
srcRect.w = colsRemainder;
destRect.w = colsRemainder;
AddSlice(srcRect,destRect,scale);
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
AddSlice(srcRect,destRect,scale,group);
}
}
if (rowsRemainder>0)
@ -306,8 +264,7 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
destRect.h = rowsRemainder;
srcRect.w = (srcW-x0-(srcW-x1));
destRect.w = (srcW-x0-(srcW-x1));
AddSlice(srcRect,destRect,scale);
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
AddSlice(srcRect,destRect,scale,group);
}
}
if(rowsRemainder>0&&colsRemainder>0)
@ -318,16 +275,14 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
srcRect.h = rowsRemainder;
destRect.w = colsRemainder;
destRect.h = rowsRemainder;
AddSlice(srcRect,destRect,scale);
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
AddSlice(srcRect,destRect,scale,group);
}
}
}
}
// Need to take in variables: (srcRect, desiredRect)
void UINineSlice::AddSlice(SDL_Rect srcRect, SDL_Rect destRect, int scale)
void UINineSlice::AddSlice(SDL_Rect srcRect, SDL_Rect destRect, int scale, Game::groupLabels group)
{
// printf("adding a 9slice element");
auto& slice(manager.addEntity());
SDL_Rect scaledRect = SDL_Rect();
scaledRect.x = destRect.x;
@ -336,5 +291,5 @@ void UINineSlice::AddSlice(SDL_Rect srcRect, SDL_Rect destRect, int scale)
scaledRect.h = destRect.h*scale;
slice.addComponent<TransformComponent>(scaledRect.x, scaledRect.y, scaledRect.w, scaledRect.h, 1);
slice.addComponent<SpriteComponent>("textBox",SpriteComponent::spriteUIL0,srcRect,scaledRect);
slice.addGroup(Game::groupUI_Layer0);
slice.addGroup(group);
}

View File

@ -8,8 +8,9 @@
#ifndef SRC_UININESLICE_H_
#define SRC_UININESLICE_H_
#include "SDL2/SDL.h"
#include <SDL2/SDL.h>
#include "string"
#include "../game/Game.hpp"
class UINineSlice
{
@ -18,8 +19,8 @@ public:
SDL_Rect destRect;
UINineSlice(std::string texID);
~UINineSlice();
void MakeSlices(std::string texture, int srcW, int srcH, int x0, int x1, int y0, int y1, SDL_Rect destRect, int scale);
void AddSlice(SDL_Rect srcRect, SDL_Rect destRect, int scale);
void MakeSlices(std::string texture, int srcW, int srcH, int x0, int x1, int y0, int y1, SDL_Rect destRect, int scale, Game::groupLabels label);
void AddSlice(SDL_Rect srcRect, SDL_Rect destRect, int scale, Game::groupLabels label);
private:
};

View File

@ -16,7 +16,7 @@
extern Manager manager;
UIText::UIText(std::string text, std::string texId, int x, int y, int letterW, int letterH, int lScale)
UIText::UIText(std::string text, std::string texId, int x, int y, int letterW, int letterH, int lScale, std::string tag, Game::groupLabels group)
{
inputText = text;
textureID = texId;
@ -25,34 +25,30 @@ UIText::UIText(std::string text, std::string texId, int x, int y, int letterW, i
letterWidth = letterW;
letterHeight = letterH;
scale = lScale;
// gameGroup = Game::groupLabels::groupUI_Layer3;
auto& uiLetters(manager.addEntity());
uiLetters.setTag(tag);
uiLetters.addGroup(group);
}
UIText::~UIText()
{
}
void UIText::ParseString(std::string inputText, int x, int y, int scale, std::string tag)
void UIText::ParseString(std::string inputText, int x, int y, int letterScale, std::string tag, Game::groupLabels group)
{
// gameGroup = group;
//Parse input text into an array of char
int posX = x;
int posY = y;
int i = 0;
// printf(inputText);
char current = inputText[i];
// const char* newLineChar{10};
int charsNumber = inputText.length();
// printf("Counting string \'%s\': \n",inputText.c_str());
// printf("%d\n",charsNumber);
// std::vector<char> writableStr(inputText.begin(), inputText.end());
// writableStr.push_back('\0');
do
{
// for (int i = 0; i < writableStr.size(); i++)
// {
// if (writableStr.at(i) == '\n')
// {
// printf("found new line");
// }
// }
++i;
if (strcmp(&current,"\n")!=0)
{
@ -60,26 +56,36 @@ void UIText::ParseString(std::string inputText, int x, int y, int scale, std::st
}
else
{
// printf("new line detected/n");
posX = x;
posY += letterHeight;
}
UIText::AddLetter(posX, posY, current, tag);
UIText::AddLetter(posX, posY, current, tag, letterScale, group);
current = inputText[i];
} while ((strcmp(&current,"\0"))!=0);
}
void UIText::AddLetter(int xpos, int ypos, char crnt, std::string tag)
void UIText::AddLetter(int xpos, int ypos, char crnt, std::string tag, int lttrScale, Game::groupLabels groupLabel)
{
auto& letter(manager.addEntity());
letter.addComponent<TransformComponent>(xpos*scale, ypos*scale, letterWidth, letterHeight, 1);
// printf("Scale: %d\n",scale);
letter.addComponent<SpriteComponent>("font", SpriteComponent::spriteText, crnt, letterWidth, letterHeight, scale);
letter.setTag(tag);
letter.addGroup(Game::groupUI_Layer1);
// =======THIS NEEDS TO BE REFACTORED TO NOT USE INDIVIDUAL ENTITIES FOR EACH LETTER============
// auto& letter(manager.addEntity());
// letter.addComponent<TransformComponent>(xpos*lttrScale, ypos*lttrScale, letterWidth, letterHeight, 1);
// letter.addComponent<SpriteComponent>("font", SpriteComponent::spriteText, crnt, letterWidth, letterHeight, lttrScale);
// letter.setTag(tag);
// letter.addGroup(groupLabel);
SDL_Texture* letterTexture;
letterTexture = Game::assets->GetTexture(textureID);
SDL_Rect srcRect,destRect;
srcRect.x = ((crnt-ASCII_START_IDX) % ASCII_ROW_COUNT)*letterWidth;
srcRect.y = ((crnt-ASCII_START_IDX)/ASCII_ROW_COUNT)*letterHeight;
srcRect.w = letterWidth;
srcRect.h = letterHeight;
destRect.x = xpos;
destRect.y = ypos;
destRect.w = letterWidth*scale;
destRect.h = letterHeight*scale;
TextureManager::Draw(letterTexture,srcRect,destRect,SDL_FLIP_NONE);
}
// void UIText::RemoveLetter()
// {
// }

View File

@ -8,25 +8,47 @@
#ifndef SRC_UITEXT_H_
#define SRC_UITEXT_H_
#include "SDL2/SDL.h"
#define ASCII_START_IDX 32
#define ASCII_COUNT 96
#define ASCII_ROW_COUNT 16
#include <SDL2/SDL.h>
#include <iostream>
#include "../game/Game.hpp"
#include "../assetmgr/TextureManager.h"
#include "../assetmgr/AssetManager.h"
class UIText
{
private:
// SDL_Texture *texture;
// SDL_Rect srcRect, destRect;
char letter;
// int frames = 0;
// int speed = 100;
int letterWidth, letterHeight;
int scale = 1;
public:
std::string inputText;
int letterHeight;
int letterWidth;
// int letterHeight;
// int letterWidth;
// virtual void init() {}
// virtual void update() {}
// virtual void draw() {}
Game::groupLabels gameGroup;
int posX;
int posY;
std::string textureID;
UIText(std::string inputText, std::string texID, int x, int y, int letterW, int letterH, int lScale);
UIText(std::string inputText, std::string texID, int x, int y, int letterW, int letterH, int lScale, std::string tag, Game::groupLabels group);
~UIText();
// void SetCharClips(SDL_Texture* fontTex, int x, int y, int letterW, int letterH);
void AddLetter(int xpos, int ypos, char crnt, std::string tag);
void ParseString(std::string inputText, int x, int y, int scale, std::string tag);
int scale;
void init() {}
void update() {}
void draw() {}
void AddLetter(int xpos, int ypos, char crnt, std::string tag, int lttrScale, Game::groupLabels groupLabel);
void ParseString(std::string inputText, int x, int y, int letterScale, std::string tag, Game::groupLabels group);
// void setTex(std::string id);
// int scale;
};
#endif /* SRC_UITEXT_H_ */