0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 21:23:41 +00:00

Compare commits

..

No commits in common. "5ffff57b5fcbbf7f596386d7e92a2f75b8250c4a" and "f5a94ac4b917f72b6b40502f51687e032c6c8db6" have entirely different histories.

126 changed files with 1371 additions and 1609 deletions

View File

@ -1,8 +0,0 @@
# allow game dev to overwrite settings
root=false
[*]
end_of_line = lf
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

View File

@ -1,24 +0,0 @@
on:
push:
branches: [ main ]
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'true' # might need recursive, tbd
- name: Doxygen Action
uses: mattnotmitt/doxygen-action@v1.1.0
with:
doxyfile-path: 'docs/Doxyfile'
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/html

22
.gitignore vendored
View File

@ -24,6 +24,7 @@ build/
*.app
# Generated by Visual Studio
.vscode/
.vs/
*.suo
*.user
@ -55,22 +56,7 @@ build/
# Sublime Text
*.sublime-workspace
# Created by https://www.gitignore.io/api/visualstudiocode
# Edit at https://www.gitignore.io/?templates=visualstudiocode
### VisualStudioCode ###
.vscode/* # Maybe .vscode/**/* instead - see comments
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
### VisualStudioCode Patch ###
# Ignore all local history of files
**/.history
# End of https://www.gitignore.io/api/visualstudiocode
*.sublime-project
# macOS
.DS_Store
@ -89,7 +75,3 @@ Desktop.ini
compile_commands.json
*.puml
docs/latex/
docs/html/
docs/diagrams/

14
.gitmodules vendored
View File

@ -1,22 +1,16 @@
[submodule "SDL"]
path = extern/SDL
url = https://github.com/libsdl-org/SDL.git
branch = release-2.28.x
[submodule "SDL_image"]
path = extern/SDL_image
url = https://github.com/libsdl-org/SDL_image.git
branch = release-2.8.x
[submodule "extern/SDL_mixer"]
path = extern/SDL_mixer
url = https://github.com/libsdl-org/SDL_mixer.git
branch = release-2.8.x
[submodule "extern/SDL_ttf"]
path = extern/SDL_ttf
url = https://github.com/libsdl-org/SDL_ttf.git
[submodule "extern/tmxlite"]
path = extern/tmxlite
url = https://github.com/fallahn/tmxlite.git
[submodule "docs/doxygen-awesome-css"]
path = docs/doxygen-awesome-css
url = https://github.com/jothepro/doxygen-awesome-css.git
[submodule "external/tmxlite"]
path = external/tmxlite
url = https://github.com/fallahn/tmxlite.git
branch = release-2.22.x

17
.vscode/launch.json vendored
View File

@ -1,17 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "debug",
"type": "cppdbg",
"miDebuggerPath": "c:\\mingw64\\bin\\gdb.exe",
"request": "launch",
"program": "${workspaceFolder}/build/SDL_Minigame.exe",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build-debug"
}
]
}

View File

@ -1,5 +0,0 @@
{
"cmake.configureOnOpen": true,
"editor.tabSize": 4,
"editor.insertSpaces": true,
}

67
.vscode/tasks.json vendored
View File

@ -1,67 +0,0 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "build-engine-debug",
"command": "cd build; cmake -DCMAKE_BUILD_TYPE=Debug; cmake --build .",
"problemMatcher": [],
"group": "build"
},
{
"type": "shell",
"label": "build-engine",
"command": "cd build; cmake -DCMAKE_BUILD_TYPE=Release; cmake --build .",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "docker-build",
"label": "build-doxygen",
"dockerBuild": {
"context": "${workspaceRoot}/docs/docker",
"tag": "vego_doxygen-docker",
},
"problemMatcher": [],
},
{
"type": "docker-run",
"label": "gen-doxygen",
"dockerRun": {
"image": "vego_doxygen-docker",
"remove": true,
"volumes": [
{
"localPath": "${workspaceFolder}",
"containerPath": "/source"
},
{
"localPath": "${workspaceFolder}/docs",
"containerPath": "/output"
},
{
"localPath": "${workspaceFolder}/docs/Doxyfile",
"containerPath": "/Doxyfile"
},
]
},
"problemMatcher": [],
},
{
"type": "process",
"label": "open-doxygen",
"command": "explorer",
"windows": {
"command": "explorer.exe"
},
"args": ["${workspaceFolder}\\docs\\html\\index.html"],
"problemMatcher": [],
"dependsOn": "gen-doxygen",
}
]
}

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15)
project(engine)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(ENGINE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
@ -17,14 +17,10 @@ set(SDL2TTF_VENDORED ON)
set(SDL2_SOURCE_DIR ${ENGINE_SOURCE_DIR}/extern/SDL”)
set(TMXLITE_STATIC_LIB TRUE)
add_subdirectory(extern/SDL EXCLUDE_FROM_ALL)
add_subdirectory(extern/SDL_image EXCLUDE_FROM_ALL)
add_subdirectory(extern/SDL_mixer EXCLUDE_FROM_ALL)
add_subdirectory(extern/SDL_ttf EXCLUDE_FROM_ALL)
add_subdirectory(extern/tmxlite/tmxlite EXCLUDE_FROM_ALL)
file(GLOB_RECURSE SOURCES ${ENGINE_SOURCE_DIR}/src/*.cpp)
add_library(${PROJECT_NAME} ${SOURCES})
@ -32,16 +28,15 @@ add_library(${PROJECT_NAME} ${SOURCES})
target_include_directories(${PROJECT_NAME} PUBLIC ${ENGINE_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PUBLIC # should be private when all SDL functionality has a wrapper
SDL3::SDL3-static
SDL3_image::SDL3_image-static
SDL3_mixer::SDL3_mixer-static
SDL3_ttf::SDL3_ttf-static
tmxlite
SDL2::SDL2main
SDL2::SDL2-static
SDL2_image::SDL2_image-static
SDL2_mixer::SDL2_mixer-static
SDL2_ttf::SDL2_ttf-static
)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") # -fsanitize=address -fno-omit-frame-pointer")
#target_link_libraries(${PROJECT_NAME} PRIVATE "-fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
endif()
# link/copy compile commands to root dir

View File

@ -42,13 +42,13 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
PROJECT_NAME = "VEGO-Engine"
PROJECT_NAME = "My Project"
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 0.1
PROJECT_NUMBER =
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
@ -67,14 +67,14 @@ PROJECT_LOGO =
# when the HTML document is shown. Doxygen will copy the logo to the output
# directory.
PROJECT_ICON = assets/chicken_neutral_knight.png
PROJECT_ICON =
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
# into which the generated documentation will be written. If a relative path is
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.
OUTPUT_DIRECTORY = docs
OUTPUT_DIRECTORY =
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096
# sub-directories (in 2 levels) under the output directory of each output format
@ -396,7 +396,7 @@ AUTOLINK_SUPPORT = YES
# diagrams that involve STL classes more complete and accurate.
# The default value is: NO.
BUILTIN_STL_SUPPORT = YES
BUILTIN_STL_SUPPORT = NO
# If you use Microsoft's C++/CLI language, you should set this option to YES to
# enable parsing support.
@ -842,7 +842,7 @@ CITE_BIB_FILES =
# messages are off.
# The default value is: NO.
QUIET = YES
QUIET = NO
# The WARNINGS tag can be used to turn on/off the warning messages that are
# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
@ -949,7 +949,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
INPUT = ./include ./src
INPUT =
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@ -989,15 +989,63 @@ INPUT_FILE_ENCODING =
# be provided as doxygen C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
# *.f18, *.f, *.for, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice.
FILE_PATTERNS = *.cpp \
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cxxm \
*.cpp \
*.cppm \
*.ccm \
*.c++ \
*.c++m \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.idl \
*.ddl \
*.odl \
*.h \
*.hpp
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.ixx \
*.l \
*.cs \
*.d \
*.php \
*.php4 \
*.php5 \
*.phtml \
*.inc \
*.m \
*.markdown \
*.md \
*.mm \
*.dox \
*.py \
*.pyw \
*.f90 \
*.f95 \
*.f03 \
*.f08 \
*.f18 \
*.f \
*.for \
*.vhd \
*.vhdl \
*.ucf \
*.qsf \
*.ice
# The RECURSIVE tag can be used to specify whether or not subdirectories should
# be searched for input files as well.
# The default value is: NO.
RECURSIVE = YES
RECURSIVE = NO
# The EXCLUDE tag can be used to specify files and/or directories that should be
# excluded from the INPUT source files. This way you can easily exclude a
@ -1036,17 +1084,14 @@ EXCLUDE_SYMBOLS =
# that contain example code fragments that are included (see the \include
# command).
EXAMPLE_PATH = ./include \
./src
EXAMPLE_PATH =
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
# *.h) to filter out the source-files in the directories. If left blank all
# files are included.
EXAMPLE_PATTERNS = *.cpp \
*.h \
*.hpp
EXAMPLE_PATTERNS = *
# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
# searched for input files to be used with the \include or \dontinclude commands
@ -1280,7 +1325,7 @@ HTML_FILE_EXTENSION = .html
# of the possible markers and block names see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_HEADER = docs/header.html
HTML_HEADER =
# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
# generated HTML page. If the tag is left blank doxygen will generate a standard
@ -1320,10 +1365,7 @@ HTML_STYLESHEET =
# documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_STYLESHEET = docs/doxygen-awesome-css/doxygen-awesome.css \
docs/doxygen-awesome-css/doxygen-awesome-sidebar-only.css \
docs/doxygen-awesome-css/doxygen-awesome-sidebar-only-darkmode-toggle.css \
docs/custom.css
HTML_EXTRA_STYLESHEET =
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
@ -1333,10 +1375,7 @@ HTML_EXTRA_STYLESHEET = docs/doxygen-awesome-css/doxygen-awesome.css \
# files will be copied as-is; there are no commands or markers available.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_FILES = docs/doxygen-awesome-css/doxygen-awesome-darkmode-toggle.js \
docs/doxygen-awesome-css/doxygen-awesome-fragment-copy-button.js \
docs/doxygen-awesome-css/doxygen-awesome-paragraph-link.js \
docs/doxygen-awesome-css/doxygen-awesome-interactive-toc.js
HTML_EXTRA_FILES =
# The HTML_COLORSTYLE tag can be used to specify if the generated HTML output
# should be rendered with a dark or light theme.
@ -1349,7 +1388,7 @@ HTML_EXTRA_FILES = docs/doxygen-awesome-css/doxygen-awesome-darkmode-toggl
# The default value is: AUTO_LIGHT.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_COLORSTYLE = LIGHT
HTML_COLORSTYLE = AUTO_LIGHT
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
# will adjust the colors in the style sheet and background images according to
@ -1677,7 +1716,7 @@ DISABLE_INDEX = NO
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_TREEVIEW = YES
GENERATE_TREEVIEW = NO
# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the
# FULL_SIDEBAR option determines if the side bar is limited to only the treeview
@ -2463,7 +2502,7 @@ HIDE_UNDOC_RELATIONS = YES
# set to NO
# The default value is: NO.
HAVE_DOT = YES
HAVE_DOT = NO
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
# to run in parallel. When set to 0 doxygen will base this on the number of
@ -2600,7 +2639,7 @@ DOT_WRAP_THRESHOLD = 17
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
TEMPLATE_RELATIONS = YES
TEMPLATE_RELATIONS = NO
# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
# YES then doxygen will generate a graph for each documented file showing the
@ -2688,7 +2727,7 @@ DIR_GRAPH_MAX_DEPTH = 1
# The default value is: png.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_IMAGE_FORMAT = SVG
DOT_IMAGE_FORMAT = png
# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
# enable generation of interactive SVG images that allow zooming and panning.
@ -2700,13 +2739,13 @@ DOT_IMAGE_FORMAT = SVG
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
INTERACTIVE_SVG = YES
INTERACTIVE_SVG = NO
# The DOT_PATH tag can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found in the path.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_PATH = /usr/bin/dot
DOT_PATH =
# The DOTFILE_DIRS tag can be used to specify one or more directories that
# contain dot files that are included in the documentation (see the \dotfile

View File

@ -1,35 +1,10 @@
# VEGO-Engine
A **VE**ry **GO**od engine, to develop small, lightweight minigames without calling all those SDL functions yourself. This project orginates as a university project at UAS Technikum Wien.
## Getting started
### Compiling
To compile this projects the following prerequisites need to be met:
- A C++ compiler, for example GCC
- On Windows you can use GCC via [MinGW](https://www.mingw-w64.org/)
- CMake
The project can be cloned and compiled with the following commands:
##### Compiling:
```sh
git clone --recurse-submodules -j8 https://github.com/VEGO-Engine/Engine.git
git submodule update --init --recursive # only needed once
cmake -S . -B build
cmake --build build
```
For Windows systems using MinGW the flag `-G "MinGW Makefiles"` has to be specified
Depending on the system, you might need to specify which generator to use, for example on a Windows system using MinGW:
```sh
git clone --recurse-submodules -j8 https://github.com/VEGO-Engine/Engine.git
cmake -S . -B build -G "MinGW Makefiles"
cmake --build build
```
Compiling the whole project might take a while, but the Engine by itself will not build to an executable. To do that you can compile the [project template](https://github.com/VEGO-Engine/Project_Template). If the template compiles without any errors, you can use the project template to start working on your own game.
### Usage
As mentioned above, we provide a [project template](https://github.com/VEGO-Engine/Project_Template). To use the template, simply clone it and start working. You can change the name for your project freely, see the documentation on the template for further information. To push to your own remote, create a new repository on the platform of your choice, and edit origin in the local git repository.
The executable can be found as `build/SDL_Minigame` after building

BIN
assets/Map.aseprite Normal file

Binary file not shown.

Binary file not shown.

BIN
assets/MapNew.aseprite Normal file

Binary file not shown.

106
assets/MapNew.json Normal file
View File

@ -0,0 +1,106 @@
{ "frames": [
{
"filename": "MapNew.aseprite",
"frame": { "x": 0, "y": 0, "w": 32, "h": 32 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
"sourceSize": { "w": 32, "h": 32 },
"duration": 100
},
{
"filename": "MapNew.aseprite",
"frame": { "x": 32, "y": 0, "w": 32, "h": 32 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
"sourceSize": { "w": 32, "h": 32 },
"duration": 100
},
{
"filename": "MapNew.aseprite",
"frame": { "x": 64, "y": 0, "w": 32, "h": 32 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
"sourceSize": { "w": 32, "h": 32 },
"duration": 100
},
{
"filename": "MapNew.aseprite",
"frame": { "x": 96, "y": 0, "w": 32, "h": 32 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
"sourceSize": { "w": 32, "h": 32 },
"duration": 100
},
{
"filename": "MapNew.aseprite",
"frame": { "x": 128, "y": 0, "w": 32, "h": 32 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
"sourceSize": { "w": 32, "h": 32 },
"duration": 100
},
{
"filename": "MapNew.aseprite",
"frame": { "x": 160, "y": 0, "w": 32, "h": 32 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
"sourceSize": { "w": 32, "h": 32 },
"duration": 100
},
{
"filename": "MapNew.aseprite",
"frame": { "x": 192, "y": 0, "w": 32, "h": 32 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
"sourceSize": { "w": 32, "h": 32 },
"duration": 100
},
{
"filename": "MapNew.aseprite",
"frame": { "x": 224, "y": 0, "w": 32, "h": 32 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
"sourceSize": { "w": 32, "h": 32 },
"duration": 100
},
{
"filename": "MapNew.aseprite",
"frame": { "x": 256, "y": 0, "w": 32, "h": 32 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
"sourceSize": { "w": 32, "h": 32 },
"duration": 100
},
{
"filename": "MapNew.aseprite",
"frame": { "x": 288, "y": 0, "w": 32, "h": 32 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
"sourceSize": { "w": 32, "h": 32 },
"duration": 100
}
],
"meta": {
"app": "https://www.aseprite.org/",
"version": "1.3.2-x64",
"format": "RGBA8888",
"size": { "w": 320, "h": 32 },
"scale": "1",
"frameTags": [
],
"layers": [
],
"slices": [
]
}
}

Binary file not shown.

BIN
assets/MapTest.aseprite Normal file

Binary file not shown.

BIN
assets/Player1Victory.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

BIN
assets/Player2Victory.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

20
assets/SDL_map_test.txt Normal file
View File

@ -0,0 +1,20 @@
3,3,3,3,3,3,3,3,3,3,7,1,1,1,9,3,3,3,3,3,3,3,3,3,3
3,3,3,3,3,3,3,3,3,3,7,1,1,1,9,3,3,3,3,3,3,3,2,3,3
3,3,3,3,3,3,3,3,3,3,7,1,1,1,9,3,3,3,3,3,3,2,2,2,3
3,3,3,2,3,3,3,3,2,3,7,1,1,1,9,3,3,3,3,3,3,3,2,2,3
3,3,2,2,3,3,3,3,3,3,7,1,1,1,9,3,3,3,3,3,3,3,3,3,3
3,3,2,2,2,3,3,3,3,3,7,1,1,1,9,3,3,2,3,3,3,3,3,3,3
3,3,2,2,2,3,3,3,3,3,7,1,1,1,9,3,3,3,3,3,3,3,3,3,3
3,3,3,2,2,3,3,3,3,3,7,1,1,1,9,3,3,3,3,3,3,3,3,3,3
3,3,3,3,2,3,3,3,3,3,7,1,1,1,9,3,3,3,3,3,3,3,3,3,3
3,3,3,3,3,3,3,3,3,3,7,1,1,1,9,3,3,3,3,3,3,3,3,3,3
3,3,3,3,3,3,3,3,3,3,7,1,1,1,9,3,3,3,3,3,3,3,3,3,3
3,3,3,3,3,3,3,3,3,3,7,1,1,1,9,3,3,3,3,3,2,3,3,3,3
3,3,3,2,2,3,3,3,3,3,7,1,1,1,9,3,3,3,3,2,2,3,3,3,3
3,3,3,3,3,3,3,3,3,3,7,1,1,1,9,3,3,3,3,2,2,2,3,3,3
3,3,3,3,3,3,3,3,3,3,7,1,1,1,9,3,3,3,3,2,2,3,3,3,3
3,3,3,3,3,3,3,2,3,3,7,1,1,1,9,3,2,3,3,2,3,3,3,3,3
3,3,3,3,3,3,3,3,3,3,7,1,1,1,9,3,2,3,3,3,3,3,3,3,3
2,2,3,3,3,3,3,3,3,3,7,1,1,1,9,3,3,3,3,3,3,3,3,3,3
3,2,2,3,3,3,3,3,3,3,7,1,1,1,9,3,3,3,3,3,3,3,3,3,3
3,3,3,3,3,3,3,3,3,3,7,1,1,1,9,3,3,3,3,3,3,3,3,3,3

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

BIN
assets/cat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
assets/chicken_neutral.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 836 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
assets/cow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
assets/dirt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 877 B

BIN
assets/egg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

BIN
assets/grass.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 B

BIN
assets/grass_water_left.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1011 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/heart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

BIN
assets/heart_powerup.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

BIN
assets/iconImage.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

BIN
assets/sound/steps.wav Normal file

Binary file not shown.

BIN
assets/sound/throw_egg.wav Normal file

Binary file not shown.

BIN
assets/startscreen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
assets/stone.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

BIN
assets/title_screen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

BIN
assets/water.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 914 B

BIN
assets/water1.ase Normal file

Binary file not shown.

BIN
assets/water1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,63 +0,0 @@
# Doxyfile
# Project information
PROJECT_NAME = "SDL Minigame"
PROJECT_NUMBER = "1.0"
PROJECT_ICON = assets/chicken_neutral_knight.png
OUTPUT_DIRECTORY = docs
OPTIMIZE_OUTPUT_FOR_C = YES
EXTRACT_ALL = NO
EXTRACT_LOCAL_CLASSES = YES
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
DOT_PATH = /usr/bin/dot
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
UML_LOOK = YES
UML_LIMIT_NUM_FIELDS = 50
TEMPLATE_RELATIONS = YES
DOT_TRANSPARENT = YES
# Source files
INPUT = ./include ./src
FILE_PATTERNS = *.cpp *.h *.hpp
EXAMPLE_PATH = ./include ./src
EXAMPLE_PATTERNS = *.cpp *.h *.hpp
# Output formats
GENERATE_XML = YES
GENERATE_HTML = YES
DOT_IMAGE_FORMAT = SVG
COLLABORATION_GRAPH = YES
GENERATE_LATEX = NO
# Extra settings
USE_MATHJAX = YES
CALL_GRAPH = YES
CALLER_GRAPH = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = YES
EXTRACT_ANON_NSPACES = YES
SHOW_FILES = YES
SHOW_INCLUDE_FILES = YES
SHOW_USED_FILES = YES
RECURSIVE = YES
# Class diagram options
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DISABLE_INDEX = YES
GENERATE_TREEVIEW = YES
HTML_COLLABORATION = YES
# idk everything else
TAB_SIZE = 4

View File

@ -1,54 +0,0 @@
html {
/* primary theme color. This will affect the entire websites color scheme: links, arrows, labels, ... */
--primary-color: #bd93f9;
--primary-dark-color: #9270e4;
--primary-light-color: #9270e4;
/* page base colors */
--page-background-color: #ffffff;
--page-foreground-color: #2f4153;
--page-secondary-foreground-color: #6f7e8e;
/* color for all separators on the website: hr, borders, ... */
--separator-color: #bd93f965;
/* border radius for all rounded components. Will affect many components, like dropdowns, memitems, codeblocks, ... */
--border-radius-large: 22px;
--border-radius-small: 9px;
--border-radius-medium: 14px;
/* default spacings. Most components reference these values for spacing, to provide uniform spacing on the page. */
--spacing-small: 8px;
--spacing-medium: 14px;
--spacing-large: 19px;
--top-height: 125px;
...
}
html.dark-mode {
color-scheme: dark;
--primary-color: #bd93f9;
--primary-dark-color: #9270e4;
--primary-light-color: #9270e4;
--primary-lighter-color: #191e21;
--primary-lightest-color: #191a1c;
--page-background-color: #21222c;
--page-foreground-color: #d2dbde;
--page-secondary-foreground-color: #859399;
--separator-color: #3a3246;
--side-nav-background: #282a36;
--side-nav-foreground: #f8f8f2;
--toc-background: #282A36;
--searchbar-background: var(--page-background-color);
...
}
.paramname em {
font-weight: 600;
color: var(--primary-dark-color);
}

62
docs/diagrams/.clang-uml Normal file
View File

@ -0,0 +1,62 @@
compilation_database_dir: ../..
output_directory: .
diagrams:
includes:
type: include
relative_to: ../..
glob:
- src/*.cpp
- include/*.h
generate_system_headers: true
include:
paths:
- src
- include
plantuml:
before:
- 'skinparam linetype ortho'
includes_no_external:
type: include
relative_to: ../..
glob:
- src/*.cpp
- include/*.h
include:
paths:
- src
- include
plantuml:
before:
- 'skinparam linetype ortho'
classes:
type: class
relative_to: ../..
glob:
- src/*.cpp
- include/*.h
include:
paths:
- src
- include
plantuml:
before:
- 'skinparam linetype ortho'
load_map_example_sequence:
type: sequence
relative_to: ../..
glob:
- src/*.cpp
- include/*.h
include:
paths:
- src
- include
start_from:
- function: "Map::loadMap(const char *,int,int)"
plantuml:
before:
- 'skinparam linetype ortho'

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 149 KiB

12
docs/diagrams/howto.md Normal file
View File

@ -0,0 +1,12 @@
Need [clang-uml](https://clang-uml.github.io/index.html)
```sh
clang-uml
clang-uml --add-compile-flag -I/usr/lib/clang/16/include # might need additional flags, example for my machine
clang-uml --print-from -n load_map_example_sequence # to get availabel commands for sequence diagram
```
then use plant uml to generate an actual `.svg` vector graphic
```sh
plantuml -tsvg *.puml
```

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 183 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 119 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 257 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.3 MiB

View File

@ -1,13 +0,0 @@
FROM alpine:latest
RUN apk --update --no-cache add doxygen graphviz git
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
WORKDIR /source
ENTRYPOINT ["/entrypoint.sh"]
CMD ["doxygen", "/Doxyfile_copy"]

View File

@ -1,6 +0,0 @@
#!/bin/sh
cp /Doxyfile /Doxyfile_copy
echo "OUTPUT_DIRECTORY = /output" >> /Doxyfile_copy
exec "$@"

@ -1 +0,0 @@
Subproject commit df88fe4fdd97714fadfd3ef17de0b4401f804052

View File

@ -1,110 +0,0 @@
<!-- HTML header for doxygen 1.10.0-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="$langISO">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=11" />
<meta name="generator" content="Doxygen $doxygenversion" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!--BEGIN PROJECT_NAME-->
<title>$projectname: $title</title>
<!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME-->
<title>$title</title>
<!--END !PROJECT_NAME-->
<!--BEGIN PROJECT_ICON-->
<link rel="icon" href="$relpath^$projecticon" type="image/x-icon" />
<!--END PROJECT_ICON-->
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css" />
<!--BEGIN DISABLE_INDEX-->
<!--BEGIN FULL_SIDEBAR-->
<script type="text/javascript">
var page_layout = 1;
</script>
<!--END FULL_SIDEBAR-->
<!--END DISABLE_INDEX-->
<script type="text/javascript" src="$relpath^jquery.js"></script>
<script type="text/javascript" src="$relpath^dynsections.js"></script>
<!--BEGIN COPY_CLIPBOARD-->
<script type="text/javascript" src="$relpath^clipboard.js"></script>
<!--END COPY_CLIPBOARD-->
<script type="text/javascript" src="$relpath^doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript">
DoxygenAwesomeDarkModeToggle.init()
</script>
<script type="text/javascript" src="$relpath^doxygen-awesome-fragment-copy-button.js"></script>
<script type="text/javascript">
DoxygenAwesomeFragmentCopyButton.init()
</script>
<script type="text/javascript" src="$relpath^doxygen-awesome-paragraph-link.js"></script>
<script type="text/javascript">
DoxygenAwesomeParagraphLink.init()
</script>
<script type="text/javascript" src="$relpath^doxygen-awesome-interactive-toc.js"></script>
<script type="text/javascript">
DoxygenAwesomeInteractiveToc.init()
</script>
$treeview
$search
$mathjax
$darkmode
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
$extrastylesheet
</head>
<body>
<!--BEGIN DISABLE_INDEX-->
<!--BEGIN FULL_SIDEBAR-->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<!-- do not remove this div, it is closed by doxygen! -->
<!--END FULL_SIDEBAR-->
<!--END DISABLE_INDEX-->
<div id="top">
<!-- do not remove this div, it is closed by doxygen! -->
<!--BEGIN TITLEAREA-->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<!--BEGIN PROJECT_LOGO-->
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo" $logosize /></td>
<!--END PROJECT_LOGO-->
<!--BEGIN PROJECT_NAME-->
<td id="projectalign">
<div id="projectname">$projectname
<!--BEGIN PROJECT_NUMBER--><span id="projectnumber">&#160;$projectnumber</span>
<!--END PROJECT_NUMBER-->
</div>
<!--BEGIN PROJECT_BRIEF-->
<div id="projectbrief">$projectbrief</div>
<!--END PROJECT_BRIEF-->
</td>
<!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME-->
<!--BEGIN PROJECT_BRIEF-->
<td>
<div id="projectbrief">$projectbrief</div>
</td>
<!--END PROJECT_BRIEF-->
<!--END !PROJECT_NAME-->
<!--BEGIN DISABLE_INDEX-->
<!--BEGIN SEARCHENGINE-->
<!--BEGIN !FULL_SIDEBAR-->
<td>$searchbox</td>
<!--END !FULL_SIDEBAR-->
<!--END SEARCHENGINE-->
<!--END DISABLE_INDEX-->
</tr>
<!--BEGIN SEARCHENGINE-->
<!--BEGIN FULL_SIDEBAR-->
<tr>
<td colspan="2">$searchbox</td>
</tr>
<!--END FULL_SIDEBAR-->
<!--END SEARCHENGINE-->
</tbody>
</table>
</div>
<!--END TITLEAREA-->
<!-- end header part -->

View File

@ -1,52 +0,0 @@
{
"folders":
[
{
"path": ".",
}
],
"settings":
{
"tab_size": 4,
},
"build_systems": [
{
"name": "Build engine",
"shell_cmd": "cmake --build build",
"working_dir": "$project_path",
"variants": [
{
"name": "Debug",
"shell_cmd": "cmake -DCMAKE_BUILD_TYPE=Debug build && cmake --build build",
},
{
"name": "Release",
"shell_cmd": "cmake -DCMAKE_BUILD_TYPE=Release build && cmake --build build",
},
],
},
{
"name": "Generate CMake",
"shell_cmd": "cmake -S . -B build",
"working_dir": "$project_path",
},
{
"name": "Doxygen",
"shell_cmd": "xdg-open $project_path/docs/html/index.html",
"working_dir": "$project_path",
"variants": [
{
"name": "Build image",
"shell_cmd": "docker build -t vego_engine-docker $project_path/docs/docker",
},
{
"name": "Generate documentation",
"shell_cmd": "docker run --rm -v \"$project_path:/source\" -v \"$project_path/docs:/output\" -v \"$project_path/docs/Doxyfile:/Doxyfile\" vego_engine-docker",
},
],
}
],
"debugger_configurations":
[
],
}

2
extern/SDL vendored

@ -1 +1 @@
Subproject commit e027b85cc457556071cbb2f3f1bcf8803c1bc001
Subproject commit 05eb08053d48fea9052ad02b3d619244aeb868d3

2
extern/SDL_image vendored

@ -1 +1 @@
Subproject commit b1c8ec7d75e3d8398940c9e04a8b82886ae6163d
Subproject commit abcf63aa71b4e3ac32120fa9870a6500ddcdcc89

2
extern/SDL_mixer vendored

@ -1 +1 @@
Subproject commit 5e2a70519294bc6ec44f1870b019ecd4760fde7d
Subproject commit 5bcd40ad962dc72a3c051084ce128d78f7656566

2
extern/SDL_ttf vendored

@ -1 +1 @@
Subproject commit 4a8bda9197cc4d6fafd188bc9df6c7e8749a43a2
Subproject commit 4a318f8dfaa1bb6f10e0c5e54052e25d3c7f3440

1
extern/tmxlite vendored

@ -1 +0,0 @@
Subproject commit fcef1a28ade8406e290d5fd168a8950e6996844f

View File

@ -1,6 +1,6 @@
#pragma once
#include <SDL3/SDL_render.h>
#include <SDL3_mixer/SDL_mixer.h>
#include <SDL_render.h>
#include <SDL_mixer.h>
#include <map>
#include <string>
#include <functional>
@ -24,24 +24,24 @@ public:
AssetManager(Manager* manager);
~AssetManager();
void createProjectile(Vector2D pos, Vector2D velocity, int scale, int range, float speed, Textures textureEnum, Entity* owner);
void createPowerup(Vector2D pos, std::function<void (Entity*)> pickupFunc, Textures texture);
void createProjectile(Vector2D pos, Vector2D velocity, int scale, int range, int speed, const char* texturePath, Entity::TeamLabel teamLabel);
void createPowerup(Vector2D pos, std::function<void (Entity*)> pickupFunc, std::string texturePath);
Vector2D calculateSpawnPosition();
PowerupType calculateType();
//texture management
void addTexture(std::string id, const char* path);
// sound management
void addSoundEffect(std::string id, const char* path);
void addMusic(std::string id, const char* path);
SDL_Texture* getTexture(std::string id);
Mix_Chunk* getSound(std::string id);
Mix_Music* getMusic(std::string id);
private:
Manager* man;
std::map<std::string, SDL_Texture*> textures;
std::map<std::string, Mix_Chunk*> soundEffects;
std::map<std::string, Mix_Music*> music;
};

View File

@ -1,6 +1,6 @@
#pragma once
#include <SDL3/SDL.h>
#include <SDL.h>
#include "Component.h"
#include "Vector2D.h"
@ -22,7 +22,7 @@ public:
ColliderComponent(const char* tag, float hitboxScale);
void init() override;
void update(uint_fast16_t diffTime) override;
void update() override;
void removeCollision();
void handleCollision(Vector2D& characterPos, SDL_Rect& characterCollider, SDL_Rect& componentCollider);

View File

@ -1,13 +1,9 @@
#pragma once
//! \file CollisionHandler.h
//! \file CollisionHandler.cpp
//! \file TransformComponent.cpp
#include "ColliderComponent.h"
#include "Constants.h"
#include "Entity.h"
#include <SDL3/SDL_rect.h>
#include "SDL_rect.h"
#include "SpriteComponent.h"
#include "Vector2D.h"
#include "Manager.h"
@ -21,11 +17,9 @@
class ColliderComponent;
class Entity;
// [IntersectionBitSet]
constexpr uint8_t DIRECTION_C = 4;
using IntersectionBitSet = std::bitset<DIRECTION_C>;
// [IntersectionBitSet]
class CollisionHandler
{
@ -50,28 +44,16 @@ public:
// temporary function, remove once game.cpp cleaned up
std::vector<ColliderComponent*> getColliders(
std::initializer_list<Entity::GroupLabel> const& groupLabels,
std::initializer_list<Entity*> const& excludedEntities = {});
std::initializer_list<Entity::TeamLabel> const& teamLabels = {},
bool negateTeam = false);
/*!
*
* \brief Tests entity against all entities with the specified labels for a collision
* \details Tests the given entity against every other entity with the specified labels for intersections between their collison boxes.
* If the primary entity has no ColliderComponent, the equivalent of no collision is returned immediately, other entities are skipped
* if they don't have a ColliderComponent
* \param entity The primary entity to check against. Return values will be relative to this entity
* \param posMod Modifier to apply toposition before checking collisions.
* \param groupLabels Entities need to have at least one listed GroupLabels to get checked against
* \param teamLabels Entities need to have one of the specified TeamLabels to get checked against
* \param negateTeam If set to true, entities will only be checked against if they **don't** have one of the specified TeamLabels
* \see ColliderComponent
*
*/
template<typename T>
T getAnyIntersection(
Entity* entity,
Vector2D posMod = {},
std::initializer_list<Entity::GroupLabel> const& groupLabels = {},
std::initializer_list<Entity*> const& excludedEntities = {});
std::initializer_list<Entity::TeamLabel> const& teamLabels = {},
bool negateTeam = false);
void update();
};

View File

@ -1,7 +1,5 @@
#pragma once
#include <cstdint>
class Entity;
class Component
@ -10,7 +8,8 @@ public:
Entity* entity;
virtual void init() {}
virtual void update(uint_fast16_t diffTime) {}
virtual void update() {}
virtual void draw() {}
virtual ~Component() = default;
};

View File

@ -3,6 +3,7 @@
#include <cstddef>
using Group = std::size_t;
using Team = std::size_t;
constexpr int CHARACTER_COUNT = 4;
@ -23,8 +24,3 @@ constexpr int MAP_SIZE_Y = 20;
constexpr int SPAWN_ATTEMPTS = 20;
constexpr int PLAY_LOOPED = -1;
constexpr int PLAY_ONCE = 0;
constexpr int MAX_VOLUME = 128;

View File

@ -11,6 +11,7 @@
// TODO: remove here if possible
// temporary fix: addComponent function template doesnt know TransformComponent -> error undefined type
// #include "KeyboardController.h"
#include "InputComponent.h"
#include "TransformComponent.h"
#include "SpriteComponent.h"
@ -22,48 +23,36 @@ using ComponentBitSet = std::bitset<MAX_COMPONENTS>;
using GroupBitSet = std::bitset<MAX_GROUPS>;
using ComponentArray = std::array<Component*, MAX_COMPONENTS>;
/*!
*
* \brief Main class for any object in game, stores associations, labeling and components
* \details The entity class is the primary class each object in the game needs to use. Add components to assign functionality.
*
* \todo More detailed description
* \todo Some functions in entity class are only supposed to be called in specific context, which might be valid uses for `friend` keyword. Example: Entity() should only be called from Manager::addEntity(). Verify each functions intended use/scope.
*
*/
class Entity
{
public:
/*!
* \brief Used for rendering order (last is highest) or retrieving entities of group
* \todo Label used in singular entity shouldn't use plural
* \todo HEARTS are rendered above POWERUPS, missleading order
* \todo PROJECTILE are rendered above POWERUPS, missleading order
* \todo Generalize HEARTS as UI or similar
*/
/*! TODO */
enum class GroupLabel
{
MAPTILES, //!< Entity using TileComponent
PLAYERS, //!< Primary entity in player controll
ENEMIES, //!< \deprecated All players now grouped as Entity::PLAYERS
COLLIDERS, //!< Fixed collider entity, e.g. a wall
PROJECTILE, //!< \todo Document
HEARTS, //!< \todo Document
POWERUPS //!< \todo Document
MAPTILES,
PLAYERS,
ENEMIES,
COLLIDERS,
PROJECTILE,
HEARTS,
POWERUPS
};
enum class TeamLabel
{
NONE, //!< No team
BLUE, //!< Team blue
RED //!< Team red
};
/*!
* \todo Document
*/
explicit Entity(Manager& mManager) :
manager(mManager) { };
void update(uint_fast16_t diffTime) const; //!< Call each frame to update all components
void update() const;
void draw() const;
bool isActive() const { return this->active; } //!< \sa destroy()
//! Mark for destruction for Manager::refresh() and disables collision
//! \sa ColliderComponent
bool isActive() const { return this->active; }
void destroy() {
this->active = false;
if (this->hasComponent<ColliderComponent>()) {
@ -71,23 +60,21 @@ public:
}
}
bool hasGroup(Group mGroup); //!< \sa GroupLabel
void addGroup(Group mGroup); //!< \sa GroupLabel
void delGroup(Group mGroup); //!< \sa GroupLabel
//! \returns bitset with true on position GroupLabel if the entity belongs to group
//! \sa GroupLabel
bool hasGroup(Group mGroup);
void addGroup(Group mGroup);
void delGroup(Group mGroup);
std::bitset<MAX_GROUPS> getGroupBitSet();
//! \sa Manager
void setTeam(TeamLabel teamLabel);
TeamLabel getTeam();
Manager& getManager() { return manager; };
template <typename T> bool hasComponent() const //! \sa Component
template <typename T> bool hasComponent() const
{
return componentBitSet[getComponentTypeID<T>()];
}
//! \brief Adds specified type as component and calls Component::init()
//! \param mArgs Constructor arguments of component
template <typename T, typename...TArgs> T& addComponent(TArgs&&...mArgs)
{
T* c(new T(std::forward<TArgs>(mArgs)...));
@ -102,7 +89,7 @@ public:
return *c;
};
template <typename T> T& getComponent() const //! \returns Component of type T
template <typename T> T& getComponent() const
{
auto ptr(componentArray[getComponentTypeID<T>()]);
return *static_cast<T*>(ptr);
@ -116,4 +103,5 @@ private:
ComponentArray componentArray = {};
ComponentBitSet componentBitSet;
GroupBitSet groupBitSet;
TeamLabel teamLabel;
};

View File

@ -8,7 +8,7 @@ public:
virtual ~Game() {}
virtual void init() = 0;
virtual void update(uint_fast16_t diffTime) = 0;
virtual void update() = 0;
GameInternal* gameInternal; //!< \deprecated
};

View File

@ -5,7 +5,6 @@
#include <map>
#include <functional>
#include <string>
#include <stdexcept>
#include "Game.h"
@ -20,20 +19,41 @@ public:
return factory;
}
void registerClass(CreateFunc createFunc) {
this->creatorFunc = createFunc;
/*Game* get() {
assert(this->gameInstance != nullptr);
return this->gameInstance;
}*/
/*Game* create(GameInternal* gameInternal) {
Game* game = this->gameInstance == nullptr ? this->creator() : this->gameInstance; // TODO: error handling
game->gameInternal = gameInternal;
this->gameInstance = game;
return game;
}*/
void registerClass(const std::string& className, CreateFunc createFunc) {
this->creators[className] = createFunc;
}
Game* create(GameInternal* gameInternal) {
if (this->creatorFunc == nullptr) {
throw std::runtime_error("No game implementation registered!");
return nullptr;
Game* create(const std::string& className, GameInternal* gameInternal) {
auto it = this->creators.find(className);
if (it != creators.end()) {
Game* game = it->second();
game->gameInternal = gameInternal;
return game;
}
Game* game = (this->creatorFunc)();
game->gameInternal = gameInternal;
return game;
return nullptr;
}
private:
CreateFunc creatorFunc = nullptr;
CreateFunc creator;
std::map<std::string, CreateFunc> creators;
};
/*
#define REGISTER_GAME(className) \
static bool registered_##className = []() { \
GameFactory::instance().registerClass(#className, []() -> Game* { return new className; }); \
return true; \
}();
*/

View File

@ -1,16 +1,14 @@
#pragma once
#include <SDL3/SDL.h>
#include <SDL3_image/SDL_image.h>
#include <SDL3_mixer/SDL_mixer.h>
#include <cstdint>
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_mixer.h>
#include <functional>
#include <vector>
#include "Manager.h"
#include "Vector2D.h"
#include "Entity.h"
#include "RenderManager.h"
typedef std::function<void()> gamefunction;
@ -27,15 +25,15 @@ public:
GameInternal();
~GameInternal();
SDL_AppResult init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen);
void init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen);
void selectCharacters(const char* &playerSprite, const char* &enemySprite);
void handleEvents();
void update(Uint64 frameTime);
void update();
void render();
void clean();
bool isRunning() const;
void setRunning(bool running); // TODO: should be private/not accesible for game dev
void stopGame();
void setRunning(bool running);
/* static */ SDL_Renderer* renderer = nullptr;
/* static */ SDL_Event event;
@ -44,8 +42,8 @@ public:
/* static */ TextureManager* textureManager;
/* static */ SoundManager* soundManager;
// moved globals
Manager manager;
RenderManager renderManager;
Map* map; // game specific, might not be needed for all types of games
std::vector<Entity*>& tiles;
@ -56,14 +54,15 @@ public:
// end moved globals
void refreshPlayers();
Entity::TeamLabel getWinner() const;
void setWinner(Entity::TeamLabel winningTeam);
private:
Game* gameInstance;
int counter = 0;
bool running = true;
bool running = false;
SDL_Window* window;
Uint64 lastFrameTime = 0;
Entity::TeamLabel winner;
};

21
include/GameObject.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#include <SDL.h>
class GameObject
{
public:
GameObject(const char* texturesheet, int x, int y);
~GameObject() = default;
void update();
void render();
private:
int xPos;
int yPos;
SDL_Texture* objTexture;
SDL_Rect srcRect;
SDL_Rect destRect;
};

View File

@ -6,17 +6,10 @@ namespace vego {
template<typename T>
class GameRegistryHelper {
public:
[[deprecated("GameRegistryHelper() does not take a className anymore")]]
GameRegistryHelper(const std::string& className) {
static_assert(std::is_base_of<Game, T>::value, "Your class must inherit from Game");
GameFactory::instance().registerClass(
[]() -> Game* { return new T; }
);
};
GameRegistryHelper() {
static_assert(std::is_base_of<Game, T>::value, "Your class must inherit from Game");
GameFactory::instance().registerClass(
className,
[]() -> Game* { return new T; }
);
};

View File

@ -1,8 +1,6 @@
#pragma once
#include <string>
#include <vector>
#include "Direction.h"
#include "Component.h"
@ -12,7 +10,7 @@ class HealthComponent : public Component
{
public:
HealthComponent(int health) : health(health) {}
HealthComponent(int health, Direction side, std::string healthTexture) : health(health), side(side), healthTexture(healthTexture) {}
~HealthComponent() {}
void modifyHealth(int health = -1);
@ -28,4 +26,6 @@ public:
private:
int health;
Direction side;
std::string healthTexture;
};

View File

@ -1,5 +1,5 @@
#pragma once
#include <SDL3/SDL.h>
#include <SDL.h>
#include <map>
#include "Component.h"
@ -94,12 +94,13 @@ public:
~InputComponent();
void init() override;
void update(uint_fast16_t diffTime) override;
void update() override;
// void pollEvents();
bool isKeyDown(Key key);
private:
const bool* m_keyStates;
const Uint8* m_keyStates;
SDL_Scancode mapKeyToSDL(Key key);
std::map<Key, SDL_Scancode> m_keyMappings;
void InitKeyMappings();

View File

@ -4,7 +4,6 @@
#include "Entity.h"
#include <vector>
#include <functional>
class InteractionComponent : public Component
{
@ -13,22 +12,27 @@ public:
~InteractionComponent();
void init() override;
void update();
bool interact(Entity* interactor, Entity* interactee);
void update() override;
Entity* getClosestInteractableEntity(Direction direction, Entity* interactor, std::vector<Entity*> entities);
bool interact(Entity* interactor, Entity* interactee);
private:
bool canInteract;
bool isInteractable;
int reach;
Entity* findClosestEntity(std::vector<Entity*>& entities, TransformComponent& interactorT, Direction direction);
std::function<bool(const TransformComponent&)> getDirectionalCheck(Direction direction, const TransformComponent& interactorT);
bool isEntityCloseEnough(const TransformComponent& interactorT, const TransformComponent& entityT, Direction direction);
Entity* findClosestEntityLeft(std::vector<Entity*>& entities, TransformComponent& interactorT);
Entity* findClosestEntityRight(std::vector<Entity*>& entities, TransformComponent& interactorT);
Entity* findClosestEntityUp(std::vector<Entity*>& entities, TransformComponent& interactorT);
Entity* findClosestEntityDown(std::vector<Entity*>& entities, TransformComponent& interactorT);
float calculateDistance(Vector2D iPos, Vector2D ePos);
bool isEntityCloseEnoughRight(Vector2D iPos, Vector2D ePos, int iWidth);
bool isEntityCloseEnoughLeft(Vector2D iPos, Vector2D ePos, int eWidth);
bool isEntityCloseEnoughUp(Vector2D iPos, Vector2D ePos, int eHeight);
bool isEntityCloseEnoughDown(Vector2D iPos, Vector2D ePos, int iHeight);
};

View File

@ -10,31 +10,24 @@
#include "Entity.h"
class GameInternal;
/*!
*
* \brief Is responsible for managing all entities
* \details The manager class handles update and draw calls collectively for all entities, and provides functionality to get all or a subset of all entities
* \sa Entity
* \sa Entity::GroupLabel
* \sa Entity::TeamLabel
*
*/
class Manager
{
public:
Manager(GameInternal* game) : game(game) {};
void update(uint_fast16_t diffTime); //!< \sa Entity::update()
//! Disables all functionality of entities marked for destruction
//! \sa Entity::destroy()
void update();
void draw();
void refresh();
void addToGroup(Entity* mEntity, Group mGroup); //!< \todo `friend` to Entity
std::vector<Entity*>& getGroup(Group mGroup); //!< \returns std::vector containing all entities in group Entity::GroupLabel
void addToGroup(Entity* mEntity, Group mGroup);
std::vector<Entity*>& getGroup(Group mGroup);
std::vector<Entity*> getAll(); //!< \returns std::vector containing all entities
void addToTeam(Entity* mEntity, Team mTeam);
std::vector<Entity*>& getTeam(Team mTeam);
Entity& addEntity(); //!< Creates and returns a new, empty entity
std::vector<Entity*> getAll();
Entity& addEntity();
GameInternal* getGame() { return this->game; };
@ -42,4 +35,5 @@ private:
GameInternal* game;
std::vector<std::unique_ptr<Entity>> entities;
std::array<std::vector<Entity*>, MAX_GROUPS> entitiesByGroup;
std::array<std::vector<Entity*>, MAX_TEAMS> entitiesByTeam;
};

View File

@ -1,52 +1,26 @@
#pragma once
#include <functional>
#include <optional>
#include <map>
#include <string>
#include <vector>
#include <tmxlite/Map.hpp>
#include <tmxlite/Property.hpp>
#include <tmxlite/TileLayer.hpp>
#include <tmxlite/Types.hpp>
class GameInternal;
class Map
{
public:
Map() = default;
~Map() = default;
// code comment below is a test for doxygen - do not remove
/*!
* \brief Loads a .tmx map
* \details Loads a `.tmx` file and extracts all relevant data. Any entities (including tiles) are only spawned once
* \param path Path to the `.tmx` map file
* \sa Map::generateTiles()
*
* \brief
* This loads a map
*
* \param path The path to the map file
* \return Boolean for success
*
*/
Map(const char* path);
void generateTiles(); //!< Generates the map based on the loaded definition
private:
// struct required for initialisation
struct MapData {
const std::vector<tmx::Tileset>* tileSets;
const std::vector<tmx::Layer::Ptr>* mapLayers;
const tmx::Vector2u* mapSize;
const tmx::Vector2u* mapTileSize;
const std::vector<std::string>* texturePaths;
};
struct TileSetData {
std::string texturePath{};
tmx::Vector2f textureSize;
uint32_t tileCount{};
tmx::Vector2u tileCount2D;
uint32_t firstGID{};
};
tmx::Map map;
Map::MapData mapData;
std::vector<std::function<void()>> tileConstructors;
void loadTileLayer(const tmx::TileLayer& layer);
static void addTile(float x, float y, const tmx::Vector2u& mapTileSize, int u, int v, int zIndex, std::string texturePath, bool hasCollision);
template<typename T>
static std::optional<T> getLayerProperty(const std::vector<tmx::Property>& properties, std::string propertyName) { return std::nullopt; };
};
static void loadMap(const char* path, int sizeX, int sizeY, GameInternal* game, const std::map<int, std::pair<std::string, bool>>* textureDict /* backreference */);
static void addTile(unsigned long id, int x, int y, GameInternal* game, const std::map<int, std::pair<std::string, bool>>* textureDict);
};

28
include/PopupWindow.h Normal file
View File

@ -0,0 +1,28 @@
#pragma once
#include <SDL.h>
#include <SDL_ttf.h>
#include <string>
#include "Entity.h"
class GameInternal;
class PopupWindow {
public:
PopupWindow(const char* title, const std::string& message);
~PopupWindow();
void handleWinnerEvents();
bool shouldContinue() const;
bool interacted;
void renderWinnerPopup(Entity::TeamLabel winner);
private:
SDL_Renderer* renderer;
SDL_Window* window;
SDL_Texture* texture;
bool continueGame;
};

View File

@ -9,7 +9,7 @@ public:
PowerupComponent(std::function<void (Entity*)> func);
~PowerupComponent() {};
void update(uint_fast16_t diffTime) override;
void update() override;
private:
std::function<void (Entity*)> pickupFunc;

View File

@ -11,21 +11,18 @@ class ProjectileComponent : public Component
//can maybe be split in separate .cpp file
public:
ProjectileComponent(int range, int speed, Vector2D direction, Entity* owner)
: range(range), speed(speed), direction(direction), owner(owner) {}
ProjectileComponent(int range, int speed, Vector2D direction) : range(range), speed(speed), direction(direction) {}
~ProjectileComponent() {}
void init() override;
void update(uint_fast16_t diffTime) override;
void update() override;
private:
TransformComponent* transformComponent;
int range = 0;
float speed = 0;
float distance = 0;
Entity* owner = nullptr;
int speed = 0;
int distance = 0;
Vector2D direction;
};

View File

@ -1,29 +0,0 @@
#pragma once
#include <vector>
#include "RenderObject.h"
class RenderManager {
public:
RenderManager() {};
/*
* Remove an object from the list of objects to be rendered
* \param renderObject The object to be removed
* \sa RenderObject
*/
void remove(RenderObject* obj);
/*
* Add an object to be rendered
* \param renderObject The object to be rendered
* \sa RenderObject
*/
void add(RenderObject* obj);
void renderAll(); //!< Render all objects. If the list has been modified, sorts it based on z-index first
private:
std::vector<RenderObject*> renderObjects;
bool isSorted;
};

View File

@ -1,27 +0,0 @@
#pragma once
class RenderManager;
class RenderObject
{
public:
virtual void draw() = 0;
RenderObject(int zIndex, RenderManager& renderManager);
~RenderObject();
int getZIndex() { return this->zIndex; };
//! Comparitor to compare two ptr based on z-index
struct ZIndexComparator {
bool operator()(RenderObject const *lhs, RenderObject const *rhs ) const {
return lhs->zIndex < rhs->zIndex;
}
};
private:
int zIndex = 0;
protected:
RenderManager& renderManager;
};

View File

@ -1,20 +1,19 @@
#pragma once
#include <SDL3_mixer/SDL_mixer.h>
#include <SDL_mixer.h>
#include <map>
#include <vector>
#include "ECS.h"
#include "TextureManager.h"
class GameInternal;
/*!
*
* \brief Handles music and sound.
* \details SoundManager handles loading in music and sound effects from files, playing music and sound effects and toggling the audio volume.
*
*/
enum SoundTypes
{
STEPS,
THROW_EGG,
};
class GameInternal;
class SoundManager
{
public:
@ -23,55 +22,14 @@ class SoundManager
for (auto& it : this->sound_cache) {
Mix_FreeChunk(it.second);
}
for (auto& it : this->music_cache) {
Mix_FreeMusic(it.second);
}
}
SoundManager(SoundManager const&) = delete;
void operator=(SoundManager const&) = delete;
std::map<const char*, Mix_Music*> music_cache;
std::map<const char*, Mix_Chunk*> sound_cache;
/*!
* \brief Loads music from a file (mp3)
* \returns a pointer to Mix_Music
* \sa AssetManager::AddMusic(std::string id, const char* path)
*/
Mix_Music* loadMusic(const char* fileName);
/*!
* \brief Loads sound effects from a file (wav)
* \returns a pointer to Mix_Chunk
* \sa AssetManager::AddSound(std::string id, const char* path)
*/
Mix_Chunk* loadSound(const char* fileName);
/*!
* \brief Handles playing of sound effects
*
* Handles if sounds can overlap, how often they can loop, as well as the volume at which the specified sound effect should play
* and on which channel the soundeffect should play.
*/
static void playSound(GameInternal* game, std::string sound, bool canOverlap, int loops, int volume, int channel);
/*!
* \brief Handles playing of music
*
* Handles how often track can loop, as well as the volume at which the specified track should play and if it fades in.
*/
static void playMusic(GameInternal* game, std::string sound, int loops, int volume, int ms);
static void setSoundVolume(int volume, int channel); //!< Volume handling for sound effects (either all or on a specific channel)
static void setMusicVolume(int volume); //!< Volume handling for music track
static void pauseSound(int channel); //!< Handles pausing sound effects (either all or on a specific channel)
static void pauseMusic(); //!< Handles pausing music track
static void restartSound(int channel); //!< Handles resuming sound effects (either all or on a specific channel)
static void restartMusic(); //!< Handles resuming music track
static void fadeOutMusic(int ms); //!< Handles fading out a music track
static void playSound(GameInternal* game, SoundTypes sound);
private:
};

View File

@ -1,19 +1,17 @@
#pragma once
#include <map>
#include <SDL3/SDL_render.h>
#include <SDL_render.h>
#include <memory>
#include <string>
#include "Textures.h"
#include "AnimationHandler.h"
#include "Component.h"
#include "Direction.h"
#include "RenderObject.h"
class TransformComponent;
class SpriteComponent : public Component, public RenderObject
class SpriteComponent : public Component
{
public:
int animationIndex = 0;
@ -23,39 +21,29 @@ public:
private:
TransformComponent* transform;
SDL_Texture* texture;
SDL_FRect srcRect, destRect;
SDL_Rect srcRect, destRect;
Textures textureEnum;
const char* texturePath;
bool animated = false;
uint8_t frames = 0;
uint8_t speed = 100;
bool flipped = false;
int textureXOffset;
int textureYOffset;
//there should be a better solution as this variable is only used for the loading of the tmx map
//TODO: improve this in the future and also remove it from the scope of the developer
const char* path; //!< empty string if texture has a texture enum value, otherwise the path of the texture
public:
SpriteComponent(Textures texture, int zIndex);
SpriteComponent(Textures texture, int xOffset, int yOffset, int zIndex);
SpriteComponent(const char* path, int xOffset, int yOffset, int zIndex);
SpriteComponent() = default;
SpriteComponent(const char* path);
SpriteComponent(
Textures texture,
const char* path,
bool isAnimated,
std::map<std::string, std::unique_ptr<Animation>>* animationList,
std::string defaultAnimation,
int zIndex);
std::string defaultAnimation);
~SpriteComponent();
void setTexture(Textures texture);
void setMapTileTexture(const char* path);
void setTexture(const char* path);
void init() override;
void update(uint_fast16_t diffTime) override;
void update() override;
void draw() override;
void playAnimation(std::string type);
void setDirection(Direction direction);

View File

@ -16,7 +16,7 @@ public:
~StatEffectsComponent() {};
void init() override;
void update(uint_fast16_t diffTime) override;
void update() override;
void modifyStatDur(Stats stat, int duration, int value);

View File

@ -1,25 +1,11 @@
#pragma once
#include "ECS.h"
#include "SDL3/SDL_surface.h"
#include <SDL3/SDL_render.h>
#include <SDL_render.h>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "Textures.h"
/*!
* \class TextureManager
* \brief A manager for loading, caching, and drawing textures.
*
* The `TextureManager` class is responsible for handling texture loading, caching,
* and rendering in the engine. It provides functions to add, load, and draw textures
* from files, as well as manage sprite sheets.
*
* \sa Textures are used to identify textures within the engine.
* It is expected that they are implemented within the games scope.
*/
class TextureManager
{
@ -29,63 +15,13 @@ class TextureManager
for (auto& it : this->texture_cache) {
SDL_DestroyTexture(it.second);
}
for (auto& it : this->mapTile_texture_cache) {
SDL_DestroyTexture(it.second);
}
}
/*!
* \brief Adds a single texture to the cache.
* \param texture The texture identifier.
* \param filePath The file path to the texture file.
* \throws std::runtime_error Is thrown if the texture could not be loaded correctly
*
* This function loads the texture from the specified file and stores it in
* a cache.
*/
void addSingleTexture(Textures texture, const char* filePath);
std::map<std::string, SDL_Texture*> texture_cache;
/*!
* \brief Adds multiple textures to the cache.
* \param textures A map of texture identifiers and corresponding file paths.
*
* This function iterates over the provided map of textures and loads each
* texture using `addSingleTexture`. It allows for several
* textures to be added at once.
*/
void addTextures(const std::map<Textures, const char*>& textures);
/*!
* \brief Loads a texture from the cache.
* \param texture The texture identifier.
* \return A pointer to the `SDL_Texture` if found, or `nullptr` if not found.
*
* This function looks up a texture within the cache and returns the
* corresponding `SDL_Texture*`. If the texture is not found, it logs an error
* message and returns `nullptr`.
*/
SDL_Texture* loadTexture(Textures texture);
SDL_Texture* loadTexture(const char* fileName);
static std::vector<SDL_Rect> splitSpriteSheet(SDL_Texture* spriteSheet, int width, int height, int spritesOnSheet);
static void draw(SDL_Renderer* renderer, SDL_Texture* texture, SDL_FRect src, SDL_FRect dest, bool flipped = false);
void setScaleMode(SDL_ScaleMode scaleMode) { this->scaleMode = scaleMode; }
/*!
* \brief Loads a map tile texture from the file system and caches it.
* \param path The file path to the texture.
* \return `SDL_Texture*` representing the map tile.
* \throws std::runtime_error Is thrown if the texture could not be loaded correctly
*
* This function checks if the map tile texture is already cached. If not, it
* loads the texture from the file system and stores it in the cache.
*
* \todo should not be usable for the developer and only be accessed by the map class
*/
SDL_Texture* loadMapTileTexture(const char* path);
static void draw(SDL_Renderer* renderer, SDL_Texture* texture, SDL_Rect src, SDL_Rect dest, bool flipped = false);
private:
SDL_ScaleMode scaleMode = SDL_SCALEMODE_NEAREST;
Manager* manager;
std::map<Textures, SDL_Texture*> texture_cache;
std::map<std::string, SDL_Texture*> mapTile_texture_cache;
};

View File

@ -1,14 +0,0 @@
#pragma once
/*!
* \class Textures
* \brief Forward declaration of the \c Textures enum class.
*
* The \c Textures enum class is intended to be implemented within the game scope.
* This allows for customized texture entries to be defined based on the specific needs of the project.
* The base declaration ensures that the enum class can be referenced and used consistently throughout
* the engine while leaving the details of the texture identifiers up to the implementation.
* \sa \ref TextureManager "TextureManager" for how the enum is used.
*/
enum class Textures;

View File

@ -1,11 +1,10 @@
#pragma once
#include <SDL3/SDL.h>
#include <SDL.h>
#include <string>
#include <map>
#include "Component.h"
#include "Textures.h"
class SpriteComponent;
class TransformComponent;
@ -18,19 +17,17 @@ public:
SDL_Rect tileRect;
int tileID;
Textures texture;
const char* path;
TileComponent() = default;
TileComponent(int x, int y, int w, int h, int id, const std::map<int, std::pair<Textures, bool>>* textureDict);
TileComponent(int x, int y, int w, int h, int id, const std::map<int, std::pair<std::string, bool>>* textureDict);
~TileComponent() = default;
void init() override;
bool hasCollision() {
return this->collision;
}
bool hasCollision(){return this->collision;}
std::string getName(){return this->tileName;}
private:
bool collision;
std::string tileName;
};

View File

@ -7,7 +7,7 @@
class TransformComponent : public Component
{
public:
Vector2D position; // TODO: change to int to save CPU time -> possibly subpixel coordinates
Vector2D position; // TODO: change to int to safe CPU time -> possibly subpixel coordinates
Vector2D direction;
int height = 32;
@ -24,12 +24,11 @@ public:
TransformComponent(float x, float y, int w, int h, int scale);
void init() override;
/*! TODO: document usage of collision handler */
void update(uint_fast16_t diffTime) override;
void update() override;
void setPositionAfterCollision(Vector2D& positionChange);
void modifySpeed(int8_t modifier);
private:
int speed = 180;
int speed = 3;
int speedMod = 0;
};

View File

@ -1,9 +0,0 @@
#include "GameInternal.h"
namespace vego {
extern GameInternal* game;
}
inline GameInternal& VEGO_Game() {
return *vego::game;
};

Some files were not shown because too many files have changed in this diff Show More