Compare commits
34 Commits
de99b127b1
...
CMake
Author | SHA1 | Date | |
---|---|---|---|
35e776c6e2 | |||
391fcedc37 | |||
1dec4347e0 | |||
e2605bf6c1 | |||
21c30b7f52 | |||
70402c5382 | |||
4aa7fe1692 | |||
36adcdeac7 | |||
e28a9cebdb | |||
b94c2cff38 | |||
fb20b8d868 | |||
9f4007bb79 | |||
bc4262d552 | |||
2331110c71 | |||
c8aae59f26 | |||
871e6d19c6 | |||
72b4ac9229 | |||
dc43e59ff6 | |||
66b8de6f40 | |||
b5639e4f41 | |||
72a941810d | |||
40095cb8b7 | |||
af393e8acb | |||
b9e9c04235 | |||
0cc31be0c7 | |||
bd0c49b3ae | |||
165052a617 | |||
1e5beb5b88 | |||
8713b76f83 | |||
586a774cde | |||
fde99ef76b | |||
363f28cb9c | |||
31e16585d1 | |||
10e5be7a65 |
18
CMakeLists.txt
Normal file
18
CMakeLists.txt
Normal file
@ -0,0 +1,18 @@
|
||||
project(BeagleRescue)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
# Point to our own cmake modules
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/sdl2)
|
||||
|
||||
# Find SDL2
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(SDL2_image REQUIRED)
|
||||
find_package(SDL2_mixer REQUIRED)
|
||||
|
||||
# Add global definitions
|
||||
add_definitions("-Wall")
|
||||
include_directories(${SDL2_INCLUDE_DIR})
|
||||
|
||||
add_executable(BeagleRescue src/game/Main.cpp)
|
||||
install(TARGETS BeagleRescue DESTINATION bin)
|
||||
target_link_libraries(BeagleRescue ${SDL2_LIBRARIES} SDL2::Mixer SDL::Image)
|
46
Makefile
46
Makefile
@ -1,46 +0,0 @@
|
||||
# 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
|
||||
|
||||
BUILD_DIR ?= ./build
|
||||
SRC_DIRS ?= ./src
|
||||
|
||||
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *.s)
|
||||
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
|
||||
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||
|
||||
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP -w
|
||||
|
||||
LINKER_FLAGS = -lSDL2 -lSDL2_image -lSDL2_mixer
|
||||
|
||||
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
|
||||
# $(CC) $(OBJS) -o $@ $(LDFLAGS)
|
||||
$(CXX) $(OBJS) $(LINKER_FLAGS) -o $@
|
||||
|
||||
# assembly
|
||||
$(BUILD_DIR)/%.s.o: %.s
|
||||
$(MKDIR_P) $(dir $@)
|
||||
$(AS) $(ASFLAGS) -c $< -o $@
|
||||
|
||||
# c source
|
||||
$(BUILD_DIR)/%.c.o: %.c
|
||||
$(MKDIR_P) $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CFLAGS) $(LINKER_FLAGS) -c $< -o $@
|
||||
|
||||
# c++ source
|
||||
$(BUILD_DIR)/%.cpp.o: %.cpp
|
||||
$(MKDIR_P) $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LINKER_FLAGS) -c $< -o $@
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
$(RM) -r $(BUILD_DIR)
|
||||
|
||||
-include $(DEPS)
|
||||
|
||||
MKDIR_P ?= mkdir -p
|
BIN
assets/maps/br-tiles.png
Normal file
BIN
assets/maps/br-tiles.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
65
assets/maps/br-tiles.tsx
Normal file
65
assets/maps/br-tiles.tsx
Normal 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>
|
96
assets/maps/testmap.tmx
Normal file
96
assets/maps/testmap.tmx
Normal 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>
|
14
assets/maps/testmapb64.tmx
Normal file
14
assets/maps/testmapb64.tmx
Normal file
File diff suppressed because one or more lines are too long
0
assets/maps/testmapb64decoded.txt
Normal file
0
assets/maps/testmapb64decoded.txt
Normal file
103
assets/textures/tiles/br-tiles.tsx
Normal file
103
assets/textures/tiles/br-tiles.tsx
Normal 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>
|
Binary file not shown.
86
build/CMakeCache.txt
Normal file
86
build/CMakeCache.txt
Normal file
@ -0,0 +1,86 @@
|
||||
# This is the CMakeCache file.
|
||||
# For build in directory: c:/Users/Admin/projects/BeagleRescue/build
|
||||
# It was generated by CMake: C:/Program Files/CMake/bin/cmake.exe
|
||||
# You can edit this file to change values found and used by cmake.
|
||||
# If you do not want to change any of the values, simply exit the editor.
|
||||
# If you do want to change a value, simply edit, save, and exit the editor.
|
||||
# The syntax for the file is as follows:
|
||||
# KEY:TYPE=VALUE
|
||||
# KEY is the name of a variable in the cache.
|
||||
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
|
||||
# VALUE is the current value for the KEY.
|
||||
|
||||
########################
|
||||
# EXTERNAL cache entries
|
||||
########################
|
||||
|
||||
//Value Computed by CMake
|
||||
BeagleRescue_BINARY_DIR:STATIC=C:/Users/Admin/projects/BeagleRescue/build
|
||||
|
||||
//Value Computed by CMake
|
||||
BeagleRescue_IS_TOP_LEVEL:STATIC=ON
|
||||
|
||||
//Value Computed by CMake
|
||||
BeagleRescue_SOURCE_DIR:STATIC=C:/Users/Admin/projects/BeagleRescue
|
||||
|
||||
//No help, variable specified on the command line.
|
||||
CMAKE_BUILD_TYPE:UNINITIALIZED=Release
|
||||
|
||||
//No help, variable specified on the command line.
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS:UNINITIALIZED=ON
|
||||
|
||||
//Program used to build from makefiles.
|
||||
CMAKE_MAKE_PROGRAM:STRING=nmake
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_DESCRIPTION:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_HOMEPAGE_URL:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_NAME:STATIC=BeagleRescue
|
||||
|
||||
|
||||
########################
|
||||
# INTERNAL cache entries
|
||||
########################
|
||||
|
||||
//This is the directory where this CMakeCache.txt was created
|
||||
CMAKE_CACHEFILE_DIR:INTERNAL=c:/Users/Admin/projects/BeagleRescue/build
|
||||
//Major version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
|
||||
//Minor version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MINOR_VERSION:INTERNAL=23
|
||||
//Patch version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_PATCH_VERSION:INTERNAL=2
|
||||
//Path to CMake executable.
|
||||
CMAKE_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cmake.exe
|
||||
//Path to cpack program executable.
|
||||
CMAKE_CPACK_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cpack.exe
|
||||
//Path to ctest program executable.
|
||||
CMAKE_CTEST_COMMAND:INTERNAL=C:/Program Files/CMake/bin/ctest.exe
|
||||
//Path to cache edit program executable.
|
||||
CMAKE_EDIT_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cmake-gui.exe
|
||||
//Name of external makefile project generator.
|
||||
CMAKE_EXTRA_GENERATOR:INTERNAL=
|
||||
//Name of generator.
|
||||
CMAKE_GENERATOR:INTERNAL=NMake Makefiles
|
||||
//Generator instance identifier.
|
||||
CMAKE_GENERATOR_INSTANCE:INTERNAL=
|
||||
//Name of generator platform.
|
||||
CMAKE_GENERATOR_PLATFORM:INTERNAL=
|
||||
//Name of generator toolset.
|
||||
CMAKE_GENERATOR_TOOLSET:INTERNAL=
|
||||
//Source directory with the top level CMakeLists.txt file for this
|
||||
// project
|
||||
CMAKE_HOME_DIRECTORY:INTERNAL=C:/Users/Admin/projects/BeagleRescue
|
||||
//ADVANCED property for variable: CMAKE_MAKE_PROGRAM
|
||||
CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
|
||||
//number of local generators
|
||||
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1
|
||||
//Platform information initialized
|
||||
CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
|
||||
//Path to CMake installation.
|
||||
CMAKE_ROOT:INTERNAL=C:/Program Files/CMake/share/cmake-3.23
|
||||
|
15
build/CMakeFiles/3.23.2/CMakeSystem.cmake
Normal file
15
build/CMakeFiles/3.23.2/CMakeSystem.cmake
Normal file
@ -0,0 +1,15 @@
|
||||
set(CMAKE_HOST_SYSTEM "Windows-10.0.22000")
|
||||
set(CMAKE_HOST_SYSTEM_NAME "Windows")
|
||||
set(CMAKE_HOST_SYSTEM_VERSION "10.0.22000")
|
||||
set(CMAKE_HOST_SYSTEM_PROCESSOR "AMD64")
|
||||
|
||||
|
||||
|
||||
set(CMAKE_SYSTEM "Windows-10.0.22000")
|
||||
set(CMAKE_SYSTEM_NAME "Windows")
|
||||
set(CMAKE_SYSTEM_VERSION "10.0.22000")
|
||||
set(CMAKE_SYSTEM_PROCESSOR "AMD64")
|
||||
|
||||
set(CMAKE_CROSSCOMPILING "FALSE")
|
||||
|
||||
set(CMAKE_SYSTEM_LOADED 1)
|
1
build/CMakeFiles/CMakeOutput.log
Normal file
1
build/CMakeFiles/CMakeOutput.log
Normal file
@ -0,0 +1 @@
|
||||
The system is: Windows - 10.0.22000 - AMD64
|
1
build/CMakeFiles/cmake.check_cache
Normal file
1
build/CMakeFiles/cmake.check_cache
Normal file
@ -0,0 +1 @@
|
||||
# This file is generated by cmake for dependency checking of the CMakeCache.txt file
|
132
cmake/sdl2/Copyright.txt
Normal file
132
cmake/sdl2/Copyright.txt
Normal file
@ -0,0 +1,132 @@
|
||||
CMake - Cross Platform Makefile Generator
|
||||
Copyright 2000-2019 Kitware, Inc. and Contributors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Kitware, Inc. nor the names of Contributors
|
||||
may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
The following individuals and institutions are among the Contributors:
|
||||
|
||||
* Aaron C. Meadows <cmake@shadowguarddev.com>
|
||||
* Adriaan de Groot <groot@kde.org>
|
||||
* Aleksey Avdeev <solo@altlinux.ru>
|
||||
* Alexander Neundorf <neundorf@kde.org>
|
||||
* Alexander Smorkalov <alexander.smorkalov@itseez.com>
|
||||
* Alexey Sokolov <sokolov@google.com>
|
||||
* Alex Merry <alex.merry@kde.org>
|
||||
* Alex Turbov <i.zaufi@gmail.com>
|
||||
* Amine Ben Hassouna <amine.benhassouna@gmail.com>
|
||||
* Andreas Pakulat <apaku@gmx.de>
|
||||
* Andreas Schneider <asn@cryptomilk.org>
|
||||
* André Rigland Brodtkorb <Andre.Brodtkorb@ifi.uio.no>
|
||||
* Axel Huebl, Helmholtz-Zentrum Dresden - Rossendorf
|
||||
* Benjamin Eikel
|
||||
* Bjoern Ricks <bjoern.ricks@gmail.com>
|
||||
* Brad Hards <bradh@kde.org>
|
||||
* Christopher Harvey
|
||||
* Christoph Grüninger <foss@grueninger.de>
|
||||
* Clement Creusot <creusot@cs.york.ac.uk>
|
||||
* Daniel Blezek <blezek@gmail.com>
|
||||
* Daniel Pfeifer <daniel@pfeifer-mail.de>
|
||||
* Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
|
||||
* Eran Ifrah <eran.ifrah@gmail.com>
|
||||
* Esben Mose Hansen, Ange Optimization ApS
|
||||
* Geoffrey Viola <geoffrey.viola@asirobots.com>
|
||||
* Google Inc
|
||||
* Gregor Jasny
|
||||
* Helio Chissini de Castro <helio@kde.org>
|
||||
* Ilya Lavrenov <ilya.lavrenov@itseez.com>
|
||||
* Insight Software Consortium <insightsoftwareconsortium.org>
|
||||
* Jan Woetzel
|
||||
* Julien Schueller
|
||||
* Kelly Thompson <kgt@lanl.gov>
|
||||
* Laurent Montel <montel@kde.org>
|
||||
* Konstantin Podsvirov <konstantin@podsvirov.pro>
|
||||
* Mario Bensi <mbensi@ipsquad.net>
|
||||
* Martin Gräßlin <mgraesslin@kde.org>
|
||||
* Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||
* Matthaeus G. Chajdas
|
||||
* Matthias Kretz <kretz@kde.org>
|
||||
* Matthias Maennich <matthias@maennich.net>
|
||||
* Michael Hirsch, Ph.D. <www.scivision.co>
|
||||
* Michael Stürmer
|
||||
* Miguel A. Figueroa-Villanueva
|
||||
* Mike Jackson
|
||||
* Mike McQuaid <mike@mikemcquaid.com>
|
||||
* Nicolas Bock <nicolasbock@gmail.com>
|
||||
* Nicolas Despres <nicolas.despres@gmail.com>
|
||||
* Nikita Krupen'ko <krnekit@gmail.com>
|
||||
* NVIDIA Corporation <www.nvidia.com>
|
||||
* OpenGamma Ltd. <opengamma.com>
|
||||
* Patrick Stotko <stotko@cs.uni-bonn.de>
|
||||
* Per Øyvind Karlsen <peroyvind@mandriva.org>
|
||||
* Peter Collingbourne <peter@pcc.me.uk>
|
||||
* Petr Gotthard <gotthard@honeywell.com>
|
||||
* Philip Lowman <philip@yhbt.com>
|
||||
* Philippe Proulx <pproulx@efficios.com>
|
||||
* Raffi Enficiaud, Max Planck Society
|
||||
* Raumfeld <raumfeld.com>
|
||||
* Roger Leigh <rleigh@codelibre.net>
|
||||
* Rolf Eike Beer <eike@sf-mail.de>
|
||||
* Roman Donchenko <roman.donchenko@itseez.com>
|
||||
* Roman Kharitonov <roman.kharitonov@itseez.com>
|
||||
* Ruslan Baratov
|
||||
* Sebastian Holtermann <sebholt@xwmw.org>
|
||||
* Stephen Kelly <steveire@gmail.com>
|
||||
* Sylvain Joubert <joubert.sy@gmail.com>
|
||||
* Thomas Sondergaard <ts@medical-insight.com>
|
||||
* Tobias Hunger <tobias.hunger@qt.io>
|
||||
* Todd Gamblin <tgamblin@llnl.gov>
|
||||
* Tristan Carel
|
||||
* University of Dundee
|
||||
* Vadim Zhukov
|
||||
* Will Dicharry <wdicharry@stellarscience.com>
|
||||
|
||||
See version control history for details of individual contributions.
|
||||
|
||||
The above copyright and license notice applies to distributions of
|
||||
CMake in source and binary form. Third-party software packages supplied
|
||||
with CMake under compatible licenses provide their own copyright notices
|
||||
documented in corresponding subdirectories or source files.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
CMake was initially developed by Kitware with the following sponsorship:
|
||||
|
||||
* National Library of Medicine at the National Institutes of Health
|
||||
as part of the Insight Segmentation and Registration Toolkit (ITK).
|
||||
|
||||
* US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
|
||||
Visualization Initiative.
|
||||
|
||||
* National Alliance for Medical Image Computing (NAMIC) is funded by the
|
||||
National Institutes of Health through the NIH Roadmap for Medical Research,
|
||||
Grant U54 EB005149.
|
||||
|
||||
* Kitware, Inc.
|
388
cmake/sdl2/FindSDL2.cmake
Normal file
388
cmake/sdl2/FindSDL2.cmake
Normal file
@ -0,0 +1,388 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
# Copyright 2019 Amine Ben Hassouna <amine.benhassouna@gmail.com>
|
||||
# Copyright 2000-2019 Kitware, Inc. and Contributors
|
||||
# All rights reserved.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# * Neither the name of Kitware, Inc. nor the names of Contributors
|
||||
# may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindSDL2
|
||||
--------
|
||||
|
||||
Locate SDL2 library
|
||||
|
||||
This module defines the following 'IMPORTED' targets:
|
||||
|
||||
::
|
||||
|
||||
SDL2::Core
|
||||
The SDL2 library, if found.
|
||||
Libraries should link to SDL2::Core
|
||||
|
||||
SDL2::Main
|
||||
The SDL2main library, if found.
|
||||
Applications should link to SDL2::Main instead of SDL2::Core
|
||||
|
||||
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
::
|
||||
|
||||
SDL2_LIBRARIES, the name of the library to link against
|
||||
SDL2_INCLUDE_DIRS, where to find SDL.h
|
||||
SDL2_FOUND, if false, do not try to link to SDL2
|
||||
SDL2MAIN_FOUND, if false, do not try to link to SDL2main
|
||||
SDL2_VERSION_STRING, human-readable string containing the version of SDL2
|
||||
|
||||
|
||||
|
||||
This module responds to the following cache variables:
|
||||
|
||||
::
|
||||
|
||||
SDL2_PATH
|
||||
Set a custom SDL2 Library path (default: empty)
|
||||
|
||||
SDL2_NO_DEFAULT_PATH
|
||||
Disable search SDL2 Library in default path.
|
||||
If SDL2_PATH (default: ON)
|
||||
Else (default: OFF)
|
||||
|
||||
SDL2_INCLUDE_DIR
|
||||
SDL2 headers path.
|
||||
|
||||
SDL2_LIBRARY
|
||||
SDL2 Library (.dll, .so, .a, etc) path.
|
||||
|
||||
SDL2MAIN_LIBRAY
|
||||
SDL2main Library (.a) path.
|
||||
|
||||
SDL2_BUILDING_LIBRARY
|
||||
This flag is useful only when linking to SDL2_LIBRARIES insead of
|
||||
SDL2::Main. It is required only when building a library that links to
|
||||
SDL2_LIBRARIES, because only applications need main() (No need to also
|
||||
link to SDL2main).
|
||||
If this flag is defined, then no SDL2main will be added to SDL2_LIBRARIES
|
||||
and no SDL2::Main target will be created.
|
||||
|
||||
|
||||
Don't forget to include SDLmain.h and SDLmain.m in your project for the
|
||||
OS X framework based version. (Other versions link to -lSDL2main which
|
||||
this module will try to find on your behalf.) Also for OS X, this
|
||||
module will automatically add the -framework Cocoa on your behalf.
|
||||
|
||||
|
||||
Additional Note: If you see an empty SDL2_LIBRARY in your project
|
||||
configuration, it means CMake did not find your SDL2 library
|
||||
(SDL2.dll, libsdl2.so, SDL2.framework, etc). Set SDL2_LIBRARY to point
|
||||
to your SDL2 library, and configure again. Similarly, if you see an
|
||||
empty SDL2MAIN_LIBRARY, you should set this value as appropriate. These
|
||||
values are used to generate the final SDL2_LIBRARIES variable and the
|
||||
SDL2::Core and SDL2::Main targets, but when these values are unset,
|
||||
SDL2_LIBRARIES, SDL2::Core and SDL2::Main does not get created.
|
||||
|
||||
|
||||
$SDL2DIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2DIR used in building SDL2. l.e.galup 9-20-02
|
||||
|
||||
|
||||
|
||||
Created by Amine Ben Hassouna:
|
||||
Adapt FindSDL.cmake to SDL2 (FindSDL2.cmake).
|
||||
Add cache variables for more flexibility:
|
||||
SDL2_PATH, SDL2_NO_DEFAULT_PATH (for details, see doc above).
|
||||
Mark 'Threads' as a required dependency for non-OSX systems.
|
||||
Modernize the FindSDL2.cmake module by creating specific targets:
|
||||
SDL2::Core and SDL2::Main (for details, see doc above).
|
||||
|
||||
|
||||
Original FindSDL.cmake module:
|
||||
Modified by Eric Wing. Added code to assist with automated building
|
||||
by using environmental variables and providing a more
|
||||
controlled/consistent search behavior. Added new modifications to
|
||||
recognize OS X frameworks and additional Unix paths (FreeBSD, etc).
|
||||
Also corrected the header search path to follow "proper" SDL
|
||||
guidelines. Added a search for SDLmain which is needed by some
|
||||
platforms. Added a search for threads which is needed by some
|
||||
platforms. Added needed compile switches for MinGW.
|
||||
|
||||
On OSX, this will prefer the Framework version (if found) over others.
|
||||
People will have to manually change the cache value of SDL2_LIBRARY to
|
||||
override this selection or set the SDL2_PATH variable or the CMake
|
||||
environment CMAKE_INCLUDE_PATH to modify the search paths.
|
||||
|
||||
Note that the header path has changed from SDL/SDL.h to just SDL.h
|
||||
This needed to change because "proper" SDL convention is #include
|
||||
"SDL.h", not <SDL/SDL.h>. This is done for portability reasons
|
||||
because not all systems place things in SDL/ (see FreeBSD).
|
||||
#]=======================================================================]
|
||||
|
||||
# Define options for searching SDL2 Library in a custom path
|
||||
|
||||
set(SDL2_PATH "" CACHE STRING "Custom SDL2 Library path")
|
||||
|
||||
set(_SDL2_NO_DEFAULT_PATH OFF)
|
||||
if(SDL2_PATH)
|
||||
set(_SDL2_NO_DEFAULT_PATH ON)
|
||||
endif()
|
||||
|
||||
set(SDL2_NO_DEFAULT_PATH ${_SDL2_NO_DEFAULT_PATH}
|
||||
CACHE BOOL "Disable search SDL2 Library in default path")
|
||||
unset(_SDL2_NO_DEFAULT_PATH)
|
||||
|
||||
set(SDL2_NO_DEFAULT_PATH_CMD)
|
||||
if(SDL2_NO_DEFAULT_PATH)
|
||||
set(SDL2_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2 include directory
|
||||
find_path(SDL2_INCLUDE_DIR SDL.h
|
||||
HINTS
|
||||
ENV SDL2DIR
|
||||
${SDL2_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
include/SDL2 include
|
||||
PATHS ${SDL2_PATH}
|
||||
DOC "Where the SDL2 headers can be found"
|
||||
)
|
||||
|
||||
set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIR}")
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
# SDL-2.0 is the name used by FreeBSD ports...
|
||||
# don't confuse it for the version number.
|
||||
find_library(SDL2_LIBRARY
|
||||
NAMES SDL2 SDL-2.0
|
||||
HINTS
|
||||
ENV SDL2DIR
|
||||
${SDL2_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS ${SDL2_PATH}
|
||||
DOC "Where the SDL2 Library can be found"
|
||||
)
|
||||
|
||||
set(SDL2_LIBRARIES "${SDL2_LIBRARY}")
|
||||
|
||||
if(NOT SDL2_BUILDING_LIBRARY)
|
||||
if(NOT SDL2_INCLUDE_DIR MATCHES ".framework")
|
||||
# Non-OS X framework versions expect you to also dynamically link to
|
||||
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||
# seem to provide SDL2main for compatibility even though they don't
|
||||
# necessarily need it.
|
||||
|
||||
if(SDL2_PATH)
|
||||
set(SDL2MAIN_LIBRARY_PATHS "${SDL2_PATH}")
|
||||
endif()
|
||||
|
||||
if(NOT SDL2_NO_DEFAULT_PATH)
|
||||
set(SDL2MAIN_LIBRARY_PATHS
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
"${SDL2MAIN_LIBRARY_PATHS}"
|
||||
)
|
||||
endif()
|
||||
|
||||
find_library(SDL2MAIN_LIBRARY
|
||||
NAMES SDL2main
|
||||
HINTS
|
||||
ENV SDL2DIR
|
||||
${SDL2_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS ${SDL2MAIN_LIBRARY_PATHS}
|
||||
DOC "Where the SDL2main library can be found"
|
||||
)
|
||||
unset(SDL2MAIN_LIBRARY_PATHS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# SDL2 may require threads on your system.
|
||||
# The Apple build may not need an explicit flag because one of the
|
||||
# frameworks may already provide it.
|
||||
# But for non-OSX systems, I will use the CMake Threads package.
|
||||
if(NOT APPLE)
|
||||
find_package(Threads QUIET)
|
||||
if(NOT Threads_FOUND)
|
||||
set(SDL2_THREADS_NOT_FOUND "Could NOT find Threads (Threads is required by SDL2).")
|
||||
if(SDL2_FIND_REQUIRED)
|
||||
message(FATAL_ERROR ${SDL2_THREADS_NOT_FOUND})
|
||||
else()
|
||||
if(NOT SDL2_FIND_QUIETLY)
|
||||
message(STATUS ${SDL2_THREADS_NOT_FOUND})
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
unset(SDL2_THREADS_NOT_FOUND)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# MinGW needs an additional link flag, -mwindows
|
||||
# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -mwindows
|
||||
if(MINGW)
|
||||
set(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "link flags for MinGW")
|
||||
endif()
|
||||
|
||||
if(SDL2_LIBRARY)
|
||||
# For SDL2main
|
||||
if(SDL2MAIN_LIBRARY AND NOT SDL2_BUILDING_LIBRARY)
|
||||
list(FIND SDL2_LIBRARIES "${SDL2MAIN_LIBRARY}" _SDL2_MAIN_INDEX)
|
||||
if(_SDL2_MAIN_INDEX EQUAL -1)
|
||||
set(SDL2_LIBRARIES "${SDL2MAIN_LIBRARY}" ${SDL2_LIBRARIES})
|
||||
endif()
|
||||
unset(_SDL2_MAIN_INDEX)
|
||||
endif()
|
||||
|
||||
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
|
||||
# CMake doesn't display the -framework Cocoa string in the UI even
|
||||
# though it actually is there if I modify a pre-used variable.
|
||||
# I think it has something to do with the CACHE STRING.
|
||||
# So I use a temporary variable until the end so I can set the
|
||||
# "real" variable in one-shot.
|
||||
if(APPLE)
|
||||
set(SDL2_LIBRARIES ${SDL2_LIBRARIES} -framework Cocoa)
|
||||
endif()
|
||||
|
||||
# For threads, as mentioned Apple doesn't need this.
|
||||
# In fact, there seems to be a problem if I used the Threads package
|
||||
# and try using this line, so I'm just skipping it entirely for OS X.
|
||||
if(NOT APPLE)
|
||||
set(SDL2_LIBRARIES ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
# For MinGW library
|
||||
if(MINGW)
|
||||
set(SDL2_LIBRARIES ${MINGW32_LIBRARY} ${SDL2_LIBRARIES})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# Read SDL2 version
|
||||
if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h")
|
||||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MAJOR "${SDL2_VERSION_MAJOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MINOR "${SDL2_VERSION_MINOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_PATCH "${SDL2_VERSION_PATCH_LINE}")
|
||||
set(SDL2_VERSION_STRING ${SDL2_VERSION_MAJOR}.${SDL2_VERSION_MINOR}.${SDL2_VERSION_PATCH})
|
||||
unset(SDL2_VERSION_MAJOR_LINE)
|
||||
unset(SDL2_VERSION_MINOR_LINE)
|
||||
unset(SDL2_VERSION_PATCH_LINE)
|
||||
unset(SDL2_VERSION_MAJOR)
|
||||
unset(SDL2_VERSION_MINOR)
|
||||
unset(SDL2_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
|
||||
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR
|
||||
VERSION_VAR SDL2_VERSION_STRING)
|
||||
|
||||
if(SDL2MAIN_LIBRARY)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2main
|
||||
REQUIRED_VARS SDL2MAIN_LIBRARY SDL2_INCLUDE_DIR
|
||||
VERSION_VAR SDL2_VERSION_STRING)
|
||||
endif()
|
||||
|
||||
|
||||
mark_as_advanced(SDL2_PATH
|
||||
SDL2_NO_DEFAULT_PATH
|
||||
SDL2_LIBRARY
|
||||
SDL2MAIN_LIBRARY
|
||||
SDL2_INCLUDE_DIR
|
||||
SDL2_BUILDING_LIBRARY)
|
||||
|
||||
|
||||
# SDL2:: targets (SDL2::Core and SDL2::Main)
|
||||
if(SDL2_FOUND)
|
||||
|
||||
# SDL2::Core target
|
||||
if(SDL2_LIBRARY AND NOT TARGET SDL2::Core)
|
||||
add_library(SDL2::Core UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::Core PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}")
|
||||
|
||||
if(APPLE)
|
||||
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
|
||||
# For more details, please see above.
|
||||
set_property(TARGET SDL2::Core APPEND PROPERTY
|
||||
INTERFACE_LINK_OPTIONS -framework Cocoa)
|
||||
else()
|
||||
# For threads, as mentioned Apple doesn't need this.
|
||||
# For more details, please see above.
|
||||
set_property(TARGET SDL2::Core APPEND PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES Threads::Threads)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# SDL2::Main target
|
||||
# Applications should link to SDL2::Main instead of SDL2::Core
|
||||
# For more details, please see above.
|
||||
if(NOT SDL2_BUILDING_LIBRARY AND NOT TARGET SDL2::Main)
|
||||
|
||||
if(SDL2_INCLUDE_DIR MATCHES ".framework" OR NOT SDL2MAIN_LIBRARY)
|
||||
add_library(SDL2::Main INTERFACE IMPORTED)
|
||||
set_property(TARGET SDL2::Main PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES SDL2::Core)
|
||||
elseif(SDL2MAIN_LIBRARY)
|
||||
# MinGW requires that the mingw32 library is specified before the
|
||||
# libSDL2main.a static library when linking.
|
||||
# The SDL2::MainInternal target is used internally to make sure that
|
||||
# CMake respects this condition.
|
||||
add_library(SDL2::MainInternal UNKNOWN IMPORTED)
|
||||
set_property(TARGET SDL2::MainInternal PROPERTY
|
||||
IMPORTED_LOCATION "${SDL2MAIN_LIBRARY}")
|
||||
set_property(TARGET SDL2::MainInternal PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES SDL2::Core)
|
||||
|
||||
add_library(SDL2::Main INTERFACE IMPORTED)
|
||||
|
||||
if(MINGW)
|
||||
# MinGW needs an additional link flag '-mwindows' and link to mingw32
|
||||
set_property(TARGET SDL2::Main PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES "mingw32" "-mwindows")
|
||||
endif()
|
||||
|
||||
set_property(TARGET SDL2::Main APPEND PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES SDL2::MainInternal)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
endif()
|
222
cmake/sdl2/FindSDL2_gfx.cmake
Normal file
222
cmake/sdl2/FindSDL2_gfx.cmake
Normal file
@ -0,0 +1,222 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
# Copyright 2019 Amine Ben Hassouna <amine.benhassouna@gmail.com>
|
||||
# Copyright 2000-2019 Kitware, Inc. and Contributors
|
||||
# All rights reserved.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# * Neither the name of Kitware, Inc. nor the names of Contributors
|
||||
# may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindSDL2_gfx
|
||||
--------------
|
||||
|
||||
Locate SDL2_gfx library
|
||||
|
||||
This module defines the following 'IMPORTED' target:
|
||||
|
||||
::
|
||||
|
||||
SDL2::GFX
|
||||
The SDL2_gfx library, if found.
|
||||
Have SDL2::Core as a link dependency.
|
||||
|
||||
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
::
|
||||
|
||||
SDL2_GFX_LIBRARIES, the name of the library to link against
|
||||
SDL2_GFX_INCLUDE_DIRS, where to find the headers
|
||||
SDL2_GFX_FOUND, if false, do not try to link against
|
||||
SDL2_GFX_VERSION_STRING - human-readable string containing the
|
||||
version of SDL2_gfx
|
||||
|
||||
|
||||
|
||||
This module responds to the following cache variables:
|
||||
|
||||
::
|
||||
|
||||
SDL2_GFX_PATH
|
||||
Set a custom SDL2_gfx Library path (default: empty)
|
||||
|
||||
SDL2_GFX_NO_DEFAULT_PATH
|
||||
Disable search SDL2_gfx Library in default path.
|
||||
If SDL2_GFX_PATH (default: ON)
|
||||
Else (default: OFF)
|
||||
|
||||
SDL2_GFX_INCLUDE_DIR
|
||||
SDL2_gfx headers path.
|
||||
|
||||
SDL2_GFX_LIBRARY
|
||||
SDL2_gfx Library (.dll, .so, .a, etc) path.
|
||||
|
||||
|
||||
Additional Note: If you see an empty SDL2_GFX_LIBRARY in your project
|
||||
configuration, it means CMake did not find your SDL2_gfx library
|
||||
(SDL2_gfx.dll, libsdl2_gfx.so, etc). Set SDL2_GFX_LIBRARY to point
|
||||
to your SDL2_gfx library, and configure again. This value is used to
|
||||
generate the final SDL2_GFX_LIBRARIES variable and the SDL2::GFX target,
|
||||
but when this value is unset, SDL2_GFX_LIBRARIES and SDL2::GFX does not
|
||||
get created.
|
||||
|
||||
|
||||
$SDL2GFXDIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2GFXDIR used in building SDL2_gfx.
|
||||
|
||||
$SDL2DIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
|
||||
|
||||
|
||||
Created by Amine Ben Hassouna:
|
||||
Adapt FindSDL_image.cmake to SDL2_gfx (FindSDL2_gfx.cmake).
|
||||
Add cache variables for more flexibility:
|
||||
SDL2_GFX_PATH, SDL2_GFX_NO_DEFAULT_PATH (for details, see doc above).
|
||||
Add SDL2 as a required dependency.
|
||||
Modernize the FindSDL2_gfx.cmake module by creating a specific target:
|
||||
SDL2::GFX (for details, see doc above).
|
||||
|
||||
Original FindSDL_image.cmake module:
|
||||
Created by Eric Wing. This was influenced by the FindSDL.cmake
|
||||
module, but with modifications to recognize OS X frameworks and
|
||||
additional Unix paths (FreeBSD, etc).
|
||||
#]=======================================================================]
|
||||
|
||||
# SDL2 Library required
|
||||
find_package(SDL2 QUIET)
|
||||
if(NOT SDL2_FOUND)
|
||||
set(SDL2_GFX_SDL2_NOT_FOUND "Could NOT find SDL2 (SDL2 is required by SDL2_gfx).")
|
||||
if(SDL2_gfx_FIND_REQUIRED)
|
||||
message(FATAL_ERROR ${SDL2_GFX_SDL2_NOT_FOUND})
|
||||
else()
|
||||
if(NOT SDL2_gfx_FIND_QUIETLY)
|
||||
message(STATUS ${SDL2_GFX_SDL2_NOT_FOUND})
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
unset(SDL2_GFX_SDL2_NOT_FOUND)
|
||||
endif()
|
||||
|
||||
|
||||
# Define options for searching SDL2_gfx Library in a custom path
|
||||
|
||||
set(SDL2_GFX_PATH "" CACHE STRING "Custom SDL2_gfx Library path")
|
||||
|
||||
set(_SDL2_GFX_NO_DEFAULT_PATH OFF)
|
||||
if(SDL2_GFX_PATH)
|
||||
set(_SDL2_GFX_NO_DEFAULT_PATH ON)
|
||||
endif()
|
||||
|
||||
set(SDL2_GFX_NO_DEFAULT_PATH ${_SDL2_GFX_NO_DEFAULT_PATH}
|
||||
CACHE BOOL "Disable search SDL2_gfx Library in default path")
|
||||
unset(_SDL2_GFX_NO_DEFAULT_PATH)
|
||||
|
||||
set(SDL2_GFX_NO_DEFAULT_PATH_CMD)
|
||||
if(SDL2_GFX_NO_DEFAULT_PATH)
|
||||
set(SDL2_GFX_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_gfx include directory
|
||||
find_path(SDL2_GFX_INCLUDE_DIR SDL2_gfxPrimitives.h
|
||||
HINTS
|
||||
ENV SDL2GFXDIR
|
||||
ENV SDL2DIR
|
||||
${SDL2_GFX_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
# and ENV{SDL2GFXDIR}
|
||||
include/SDL2 include
|
||||
PATHS ${SDL2_GFX_PATH}
|
||||
DOC "Where the SDL2_gfx headers can be found"
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_gfx library
|
||||
find_library(SDL2_GFX_LIBRARY
|
||||
NAMES SDL2_gfx
|
||||
HINTS
|
||||
ENV SDL2GFXDIR
|
||||
ENV SDL2DIR
|
||||
${SDL2_GFX_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS ${SDL2_GFX_PATH}
|
||||
DOC "Where the SDL2_gfx Library can be found"
|
||||
)
|
||||
|
||||
# Read SDL2_gfx version
|
||||
if(SDL2_GFX_INCLUDE_DIR AND EXISTS "${SDL2_GFX_INCLUDE_DIR}/SDL2_gfxPrimitives.h")
|
||||
file(STRINGS "${SDL2_GFX_INCLUDE_DIR}/SDL2_gfxPrimitives.h" SDL2_GFX_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL2_GFXPRIMITIVES_MAJOR[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_GFX_INCLUDE_DIR}/SDL2_gfxPrimitives.h" SDL2_GFX_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL2_GFXPRIMITIVES_MINOR[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_GFX_INCLUDE_DIR}/SDL2_gfxPrimitives.h" SDL2_GFX_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL2_GFXPRIMITIVES_MICRO[ \t]+[0-9]+$")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL2_GFXPRIMITIVES_MAJOR[ \t]+([0-9]+)$" "\\1" SDL2_GFX_VERSION_MAJOR "${SDL2_GFX_VERSION_MAJOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL2_GFXPRIMITIVES_MINOR[ \t]+([0-9]+)$" "\\1" SDL2_GFX_VERSION_MINOR "${SDL2_GFX_VERSION_MINOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL2_GFXPRIMITIVES_MICRO[ \t]+([0-9]+)$" "\\1" SDL2_GFX_VERSION_PATCH "${SDL2_GFX_VERSION_PATCH_LINE}")
|
||||
set(SDL2_GFX_VERSION_STRING ${SDL2_GFX_VERSION_MAJOR}.${SDL2_GFX_VERSION_MINOR}.${SDL2_GFX_VERSION_PATCH})
|
||||
unset(SDL2_GFX_VERSION_MAJOR_LINE)
|
||||
unset(SDL2_GFX_VERSION_MINOR_LINE)
|
||||
unset(SDL2_GFX_VERSION_PATCH_LINE)
|
||||
unset(SDL2_GFX_VERSION_MAJOR)
|
||||
unset(SDL2_GFX_VERSION_MINOR)
|
||||
unset(SDL2_GFX_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
set(SDL2_GFX_LIBRARIES ${SDL2_GFX_LIBRARY})
|
||||
set(SDL2_GFX_INCLUDE_DIRS ${SDL2_GFX_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_gfx
|
||||
REQUIRED_VARS SDL2_GFX_LIBRARIES SDL2_GFX_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_GFX_VERSION_STRING)
|
||||
|
||||
|
||||
mark_as_advanced(SDL2_GFX_PATH
|
||||
SDL2_GFX_NO_DEFAULT_PATH
|
||||
SDL2_GFX_LIBRARY
|
||||
SDL2_GFX_INCLUDE_DIR)
|
||||
|
||||
|
||||
if(SDL2_GFX_FOUND)
|
||||
|
||||
# SDL2::GFX target
|
||||
if(SDL2_GFX_LIBRARY AND NOT TARGET SDL2::GFX)
|
||||
add_library(SDL2::GFX UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::GFX PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_GFX_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_GFX_INCLUDE_DIR}"
|
||||
INTERFACE_LINK_LIBRARIES SDL2::Core)
|
||||
endif()
|
||||
endif()
|
222
cmake/sdl2/FindSDL2_image.cmake
Normal file
222
cmake/sdl2/FindSDL2_image.cmake
Normal file
@ -0,0 +1,222 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
# Copyright 2019 Amine Ben Hassouna <amine.benhassouna@gmail.com>
|
||||
# Copyright 2000-2019 Kitware, Inc. and Contributors
|
||||
# All rights reserved.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# * Neither the name of Kitware, Inc. nor the names of Contributors
|
||||
# may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindSDL2_image
|
||||
--------------
|
||||
|
||||
Locate SDL2_image library
|
||||
|
||||
This module defines the following 'IMPORTED' target:
|
||||
|
||||
::
|
||||
|
||||
SDL2::Image
|
||||
The SDL2_image library, if found.
|
||||
Have SDL2::Core as a link dependency.
|
||||
|
||||
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
::
|
||||
|
||||
SDL2_IMAGE_LIBRARIES, the name of the library to link against
|
||||
SDL2_IMAGE_INCLUDE_DIRS, where to find the headers
|
||||
SDL2_IMAGE_FOUND, if false, do not try to link against
|
||||
SDL2_IMAGE_VERSION_STRING - human-readable string containing the
|
||||
version of SDL2_image
|
||||
|
||||
|
||||
|
||||
This module responds to the following cache variables:
|
||||
|
||||
::
|
||||
|
||||
SDL2_IMAGE_PATH
|
||||
Set a custom SDL2_image Library path (default: empty)
|
||||
|
||||
SDL2_IMAGE_NO_DEFAULT_PATH
|
||||
Disable search SDL2_image Library in default path.
|
||||
If SDL2_IMAGE_PATH (default: ON)
|
||||
Else (default: OFF)
|
||||
|
||||
SDL2_IMAGE_INCLUDE_DIR
|
||||
SDL2_image headers path.
|
||||
|
||||
SDL2_IMAGE_LIBRARY
|
||||
SDL2_image Library (.dll, .so, .a, etc) path.
|
||||
|
||||
|
||||
Additional Note: If you see an empty SDL2_IMAGE_LIBRARY in your project
|
||||
configuration, it means CMake did not find your SDL2_image library
|
||||
(SDL2_image.dll, libsdl2_image.so, etc). Set SDL2_IMAGE_LIBRARY to point
|
||||
to your SDL2_image library, and configure again. This value is used to
|
||||
generate the final SDL2_IMAGE_LIBRARIES variable and the SDL2::Image target,
|
||||
but when this value is unset, SDL2_IMAGE_LIBRARIES and SDL2::Image does not
|
||||
get created.
|
||||
|
||||
|
||||
$SDL2IMAGEDIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2IMAGEDIR used in building SDL2_image.
|
||||
|
||||
$SDL2DIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
|
||||
|
||||
|
||||
Created by Amine Ben Hassouna:
|
||||
Adapt FindSDL_image.cmake to SDL2_image (FindSDL2_image.cmake).
|
||||
Add cache variables for more flexibility:
|
||||
SDL2_IMAGE_PATH, SDL2_IMAGE_NO_DEFAULT_PATH (for details, see doc above).
|
||||
Add SDL2 as a required dependency.
|
||||
Modernize the FindSDL2_image.cmake module by creating a specific target:
|
||||
SDL2::Image (for details, see doc above).
|
||||
|
||||
Original FindSDL_image.cmake module:
|
||||
Created by Eric Wing. This was influenced by the FindSDL.cmake
|
||||
module, but with modifications to recognize OS X frameworks and
|
||||
additional Unix paths (FreeBSD, etc).
|
||||
#]=======================================================================]
|
||||
|
||||
# SDL2 Library required
|
||||
find_package(SDL2 QUIET)
|
||||
if(NOT SDL2_FOUND)
|
||||
set(SDL2_IMAGE_SDL2_NOT_FOUND "Could NOT find SDL2 (SDL2 is required by SDL2_image).")
|
||||
if(SDL2_image_FIND_REQUIRED)
|
||||
message(FATAL_ERROR ${SDL2_IMAGE_SDL2_NOT_FOUND})
|
||||
else()
|
||||
if(NOT SDL2_image_FIND_QUIETLY)
|
||||
message(STATUS ${SDL2_IMAGE_SDL2_NOT_FOUND})
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
unset(SDL2_IMAGE_SDL2_NOT_FOUND)
|
||||
endif()
|
||||
|
||||
|
||||
# Define options for searching SDL2_image Library in a custom path
|
||||
|
||||
set(SDL2_IMAGE_PATH "" CACHE STRING "Custom SDL2_image Library path")
|
||||
|
||||
set(_SDL2_IMAGE_NO_DEFAULT_PATH OFF)
|
||||
if(SDL2_IMAGE_PATH)
|
||||
set(_SDL2_IMAGE_NO_DEFAULT_PATH ON)
|
||||
endif()
|
||||
|
||||
set(SDL2_IMAGE_NO_DEFAULT_PATH ${_SDL2_IMAGE_NO_DEFAULT_PATH}
|
||||
CACHE BOOL "Disable search SDL2_image Library in default path")
|
||||
unset(_SDL2_IMAGE_NO_DEFAULT_PATH)
|
||||
|
||||
set(SDL2_IMAGE_NO_DEFAULT_PATH_CMD)
|
||||
if(SDL2_IMAGE_NO_DEFAULT_PATH)
|
||||
set(SDL2_IMAGE_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_image include directory
|
||||
find_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h
|
||||
HINTS
|
||||
ENV SDL2IMAGEDIR
|
||||
ENV SDL2DIR
|
||||
${SDL2_IMAGE_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
# and ENV{SDL2IMAGEDIR}
|
||||
include/SDL2 include
|
||||
PATHS ${SDL2_IMAGE_PATH}
|
||||
DOC "Where the SDL2_image headers can be found"
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_image library
|
||||
find_library(SDL2_IMAGE_LIBRARY
|
||||
NAMES SDL2_image
|
||||
HINTS
|
||||
ENV SDL2IMAGEDIR
|
||||
ENV SDL2DIR
|
||||
${SDL2_IMAGE_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS ${SDL2_IMAGE_PATH}
|
||||
DOC "Where the SDL2_image Library can be found"
|
||||
)
|
||||
|
||||
# Read SDL2_image version
|
||||
if(SDL2_IMAGE_INCLUDE_DIR AND EXISTS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h")
|
||||
file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MAJOR "${SDL2_IMAGE_VERSION_MAJOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MINOR "${SDL2_IMAGE_VERSION_MINOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_PATCH "${SDL2_IMAGE_VERSION_PATCH_LINE}")
|
||||
set(SDL2_IMAGE_VERSION_STRING ${SDL2_IMAGE_VERSION_MAJOR}.${SDL2_IMAGE_VERSION_MINOR}.${SDL2_IMAGE_VERSION_PATCH})
|
||||
unset(SDL2_IMAGE_VERSION_MAJOR_LINE)
|
||||
unset(SDL2_IMAGE_VERSION_MINOR_LINE)
|
||||
unset(SDL2_IMAGE_VERSION_PATCH_LINE)
|
||||
unset(SDL2_IMAGE_VERSION_MAJOR)
|
||||
unset(SDL2_IMAGE_VERSION_MINOR)
|
||||
unset(SDL2_IMAGE_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY})
|
||||
set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image
|
||||
REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_IMAGE_VERSION_STRING)
|
||||
|
||||
|
||||
mark_as_advanced(SDL2_IMAGE_PATH
|
||||
SDL2_IMAGE_NO_DEFAULT_PATH
|
||||
SDL2_IMAGE_LIBRARY
|
||||
SDL2_IMAGE_INCLUDE_DIR)
|
||||
|
||||
|
||||
if(SDL2_IMAGE_FOUND)
|
||||
|
||||
# SDL2::Image target
|
||||
if(SDL2_IMAGE_LIBRARY AND NOT TARGET SDL2::Image)
|
||||
add_library(SDL2::Image UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::Image PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_IMAGE_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_IMAGE_INCLUDE_DIR}"
|
||||
INTERFACE_LINK_LIBRARIES SDL2::Core)
|
||||
endif()
|
||||
endif()
|
220
cmake/sdl2/FindSDL2_mixer.cmake
Normal file
220
cmake/sdl2/FindSDL2_mixer.cmake
Normal file
@ -0,0 +1,220 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
# Copyright 2019 Amine Ben Hassouna <amine.benhassouna@gmail.com>
|
||||
# Copyright 2000-2019 Kitware, Inc. and Contributors
|
||||
# All rights reserved.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# * Neither the name of Kitware, Inc. nor the names of Contributors
|
||||
# may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindSDL2_mixer
|
||||
--------------
|
||||
|
||||
Locate SDL2_mixer library
|
||||
|
||||
This module defines the following 'IMPORTED' target:
|
||||
|
||||
::
|
||||
|
||||
SDL2::Mixer
|
||||
The SDL2_mixer library, if found.
|
||||
Have SDL2::Core as a link dependency.
|
||||
|
||||
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
::
|
||||
|
||||
SDL2_MIXER_LIBRARIES, the name of the library to link against
|
||||
SDL2_MIXER_INCLUDE_DIRS, where to find the headers
|
||||
SDL2_MIXER_FOUND, if false, do not try to link against
|
||||
SDL2_MIXER_VERSION_STRING - human-readable string containing the
|
||||
version of SDL2_mixer
|
||||
|
||||
This module responds to the following cache variables:
|
||||
|
||||
::
|
||||
|
||||
SDL2_MIXER_PATH
|
||||
Set a custom SDL2_mixer Library path (default: empty)
|
||||
|
||||
SDL2_MIXER_NO_DEFAULT_PATH
|
||||
Disable search SDL2_mixer Library in default path.
|
||||
If SDL2_MIXER_PATH (default: ON)
|
||||
Else (default: OFF)
|
||||
|
||||
SDL2_MIXER_INCLUDE_DIR
|
||||
SDL2_mixer headers path.
|
||||
|
||||
SDL2_MIXER_LIBRARY
|
||||
SDL2_mixer Library (.dll, .so, .a, etc) path.
|
||||
|
||||
|
||||
Additional Note: If you see an empty SDL2_MIXER_LIBRARY in your project
|
||||
configuration, it means CMake did not find your SDL2_mixer library
|
||||
(SDL2_mixer.dll, libsdl2_mixer.so, etc). Set SDL2_MIXER_LIBRARY to point
|
||||
to your SDL2_mixer library, and configure again. This value is used to
|
||||
generate the final SDL2_MIXER_LIBRARIES variable and the SDL2::Mixer target,
|
||||
but when this value is unset, SDL2_MIXER_LIBRARIES and SDL2::Mixer does not
|
||||
get created.
|
||||
|
||||
|
||||
$SDL2MIXERDIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2MIXERDIR used in building SDL2_mixer.
|
||||
|
||||
$SDL2DIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
|
||||
|
||||
|
||||
Created by Amine Ben Hassouna:
|
||||
Adapt FindSDL_mixer.cmake to SDL2_mixer (FindSDL2_mixer.cmake).
|
||||
Add cache variables for more flexibility:
|
||||
SDL2_MIXER_PATH, SDL2_MIXER_NO_DEFAULT_PATH (for details, see doc above).
|
||||
Add SDL2 as a required dependency.
|
||||
Modernize the FindSDL2_mixer.cmake module by creating a specific target:
|
||||
SDL2::Mixer (for details, see doc above).
|
||||
|
||||
Original FindSDL_mixer.cmake module:
|
||||
Created by Eric Wing. This was influenced by the FindSDL.cmake
|
||||
module, but with modifications to recognize OS X frameworks and
|
||||
additional Unix paths (FreeBSD, etc).
|
||||
#]=======================================================================]
|
||||
|
||||
# SDL2 Library required
|
||||
find_package(SDL2 QUIET)
|
||||
if(NOT SDL2_FOUND)
|
||||
set(SDL2_MIXER_SDL2_NOT_FOUND "Could NOT find SDL2 (SDL2 is required by SDL2_mixer).")
|
||||
if(SDL2_mixer_FIND_REQUIRED)
|
||||
message(FATAL_ERROR ${SDL2_MIXER_SDL2_NOT_FOUND})
|
||||
else()
|
||||
if(NOT SDL2_mixer_FIND_QUIETLY)
|
||||
message(STATUS ${SDL2_MIXER_SDL2_NOT_FOUND})
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
unset(SDL2_MIXER_SDL2_NOT_FOUND)
|
||||
endif()
|
||||
|
||||
|
||||
# Define options for searching SDL2_mixer Library in a custom path
|
||||
|
||||
set(SDL2_MIXER_PATH "" CACHE STRING "Custom SDL2_mixer Library path")
|
||||
|
||||
set(_SDL2_MIXER_NO_DEFAULT_PATH OFF)
|
||||
if(SDL2_MIXER_PATH)
|
||||
set(_SDL2_MIXER_NO_DEFAULT_PATH ON)
|
||||
endif()
|
||||
|
||||
set(SDL2_MIXER_NO_DEFAULT_PATH ${_SDL2_MIXER_NO_DEFAULT_PATH}
|
||||
CACHE BOOL "Disable search SDL2_mixer Library in default path")
|
||||
unset(_SDL2_MIXER_NO_DEFAULT_PATH)
|
||||
|
||||
set(SDL2_MIXER_NO_DEFAULT_PATH_CMD)
|
||||
if(SDL2_MIXER_NO_DEFAULT_PATH)
|
||||
set(SDL2_MIXER_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_mixer include directory
|
||||
find_path(SDL2_MIXER_INCLUDE_DIR SDL_mixer.h
|
||||
HINTS
|
||||
ENV SDL2MIXERDIR
|
||||
ENV SDL2DIR
|
||||
${SDL2_MIXER_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
# and ENV{SDL2MIXERDIR}
|
||||
include/SDL2 include
|
||||
PATHS ${SDL2_MIXER_PATH}
|
||||
DOC "Where the SDL2_mixer headers can be found"
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_mixer library
|
||||
find_library(SDL2_MIXER_LIBRARY
|
||||
NAMES SDL2_mixer
|
||||
HINTS
|
||||
ENV SDL2MIXERDIR
|
||||
ENV SDL2DIR
|
||||
${SDL2_MIXER_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS ${SDL2_MIXER_PATH}
|
||||
DOC "Where the SDL2_mixer Library can be found"
|
||||
)
|
||||
|
||||
# Read SDL2_mixer version
|
||||
if(SDL2_MIXER_INCLUDE_DIR AND EXISTS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h")
|
||||
file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MAJOR "${SDL2_MIXER_VERSION_MAJOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MINOR "${SDL2_MIXER_VERSION_MINOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_PATCH "${SDL2_MIXER_VERSION_PATCH_LINE}")
|
||||
set(SDL2_MIXER_VERSION_STRING ${SDL2_MIXER_VERSION_MAJOR}.${SDL2_MIXER_VERSION_MINOR}.${SDL2_MIXER_VERSION_PATCH})
|
||||
unset(SDL2_MIXER_VERSION_MAJOR_LINE)
|
||||
unset(SDL2_MIXER_VERSION_MINOR_LINE)
|
||||
unset(SDL2_MIXER_VERSION_PATCH_LINE)
|
||||
unset(SDL2_MIXER_VERSION_MAJOR)
|
||||
unset(SDL2_MIXER_VERSION_MINOR)
|
||||
unset(SDL2_MIXER_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY})
|
||||
set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer
|
||||
REQUIRED_VARS SDL2_MIXER_LIBRARIES SDL2_MIXER_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_MIXER_VERSION_STRING)
|
||||
|
||||
|
||||
mark_as_advanced(SDL2_MIXER_PATH
|
||||
SDL2_MIXER_NO_DEFAULT_PATH
|
||||
SDL2_MIXER_LIBRARY
|
||||
SDL2_MIXER_INCLUDE_DIR)
|
||||
|
||||
|
||||
if(SDL2_MIXER_FOUND)
|
||||
|
||||
# SDL2::Mixer target
|
||||
if(SDL2_MIXER_LIBRARY AND NOT TARGET SDL2::Mixer)
|
||||
add_library(SDL2::Mixer UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::Mixer PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_MIXER_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_MIXER_INCLUDE_DIR}"
|
||||
INTERFACE_LINK_LIBRARIES SDL2::Core)
|
||||
endif()
|
||||
endif()
|
222
cmake/sdl2/FindSDL2_net.cmake
Normal file
222
cmake/sdl2/FindSDL2_net.cmake
Normal file
@ -0,0 +1,222 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
# Copyright 2019 Amine Ben Hassouna <amine.benhassouna@gmail.com>
|
||||
# Copyright 2000-2019 Kitware, Inc. and Contributors
|
||||
# All rights reserved.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# * Neither the name of Kitware, Inc. nor the names of Contributors
|
||||
# may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindSDL2_net
|
||||
------------
|
||||
|
||||
Locate SDL2_net library
|
||||
|
||||
This module defines the following 'IMPORTED' target:
|
||||
|
||||
::
|
||||
|
||||
SDL2::Net
|
||||
The SDL2_net library, if found.
|
||||
Have SDL2::Core as a link dependency.
|
||||
|
||||
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
::
|
||||
|
||||
SDL2_NET_LIBRARIES, the name of the library to link against
|
||||
SDL2_NET_INCLUDE_DIRS, where to find the headers
|
||||
SDL2_NET_FOUND, if false, do not try to link against
|
||||
SDL2_NET_VERSION_STRING - human-readable string containing the
|
||||
version of SDL2_net
|
||||
|
||||
|
||||
|
||||
This module responds to the following cache variables:
|
||||
|
||||
::
|
||||
|
||||
SDL2_NET_PATH
|
||||
Set a custom SDL2_net Library path (default: empty)
|
||||
|
||||
SDL2_NET_NO_DEFAULT_PATH
|
||||
Disable search SDL2_net Library in default path.
|
||||
If SDL2_NET_PATH (default: ON)
|
||||
Else (default: OFF)
|
||||
|
||||
SDL2_NET_INCLUDE_DIR
|
||||
SDL2_net headers path.
|
||||
|
||||
SDL2_NET_LIBRARY
|
||||
SDL2_net Library (.dll, .so, .a, etc) path.
|
||||
|
||||
|
||||
Additional Note: If you see an empty SDL2_NET_LIBRARY in your project
|
||||
configuration, it means CMake did not find your SDL2_net library
|
||||
(SDL2_net.dll, libsdl2_net.so, etc). Set SDL2_NET_LIBRARY to point
|
||||
to your SDL2_net library, and configure again. This value is used to
|
||||
generate the final SDL2_NET_LIBRARIES variable and the SDL2::Net target,
|
||||
but when this value is unset, SDL2_NET_LIBRARIES and SDL2::Net does not
|
||||
get created.
|
||||
|
||||
|
||||
$SDL2NETDIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2NETDIR used in building SDL2_net.
|
||||
|
||||
$SDL2DIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
|
||||
|
||||
|
||||
Created by Amine Ben Hassouna:
|
||||
Adapt FindSDL_net.cmake to SDL2_net (FindSDL2_net.cmake).
|
||||
Add cache variables for more flexibility:
|
||||
SDL2_NET_PATH, SDL2_NET_NO_DEFAULT_PATH (for details, see doc above).
|
||||
Add SDL2 as a required dependency.
|
||||
Modernize the FindSDL2_net.cmake module by creating a specific target:
|
||||
SDL2::Net (for details, see doc above).
|
||||
|
||||
Original FindSDL_net.cmake module:
|
||||
Created by Eric Wing. This was influenced by the FindSDL.cmake
|
||||
module, but with modifications to recognize OS X frameworks and
|
||||
additional Unix paths (FreeBSD, etc).
|
||||
#]=======================================================================]
|
||||
|
||||
# SDL2 Library required
|
||||
find_package(SDL2 QUIET)
|
||||
if(NOT SDL2_FOUND)
|
||||
set(SDL2_NET_SDL2_NOT_FOUND "Could NOT find SDL2 (SDL2 is required by SDL2_net).")
|
||||
if(SDL2_net_FIND_REQUIRED)
|
||||
message(FATAL_ERROR ${SDL2_NET_SDL2_NOT_FOUND})
|
||||
else()
|
||||
if(NOT SDL2_net_FIND_QUIETLY)
|
||||
message(STATUS ${SDL2_NET_SDL2_NOT_FOUND})
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
unset(SDL2_NET_SDL2_NOT_FOUND)
|
||||
endif()
|
||||
|
||||
|
||||
# Define options for searching SDL2_net Library in a custom path
|
||||
|
||||
set(SDL2_NET_PATH "" CACHE STRING "Custom SDL2_net Library path")
|
||||
|
||||
set(_SDL2_NET_NO_DEFAULT_PATH OFF)
|
||||
if(SDL2_NET_PATH)
|
||||
set(_SDL2_NET_NO_DEFAULT_PATH ON)
|
||||
endif()
|
||||
|
||||
set(SDL2_NET_NO_DEFAULT_PATH ${_SDL2_NET_NO_DEFAULT_PATH}
|
||||
CACHE BOOL "Disable search SDL2_net Library in default path")
|
||||
unset(_SDL2_NET_NO_DEFAULT_PATH)
|
||||
|
||||
set(SDL2_NET_NO_DEFAULT_PATH_CMD)
|
||||
if(SDL2_NET_NO_DEFAULT_PATH)
|
||||
set(SDL2_NET_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_net include directory
|
||||
find_path(SDL2_NET_INCLUDE_DIR SDL_net.h
|
||||
HINTS
|
||||
ENV SDL2NETDIR
|
||||
ENV SDL2DIR
|
||||
${SDL2_NET_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
# and ENV{SDL2NETDIR}
|
||||
include/SDL2 include
|
||||
PATHS ${SDL2_NET_PATH}
|
||||
DOC "Where the SDL2_net headers can be found"
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_net library
|
||||
find_library(SDL2_NET_LIBRARY
|
||||
NAMES SDL2_net
|
||||
HINTS
|
||||
ENV SDL2NETDIR
|
||||
ENV SDL2DIR
|
||||
${SDL2_NET_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS ${SDL2_NET_PATH}
|
||||
DOC "Where the SDL2_net Library can be found"
|
||||
)
|
||||
|
||||
# Read SDL2_net version
|
||||
if(SDL2_NET_INCLUDE_DIR AND EXISTS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h")
|
||||
file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h" SDL2_NET_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_NET_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h" SDL2_NET_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_NET_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h" SDL2_NET_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_NET_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_NET_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_NET_VERSION_MAJOR "${SDL2_NET_VERSION_MAJOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_NET_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_NET_VERSION_MINOR "${SDL2_NET_VERSION_MINOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_NET_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_NET_VERSION_PATCH "${SDL2_NET_VERSION_PATCH_LINE}")
|
||||
set(SDL2_NET_VERSION_STRING ${SDL2_NET_VERSION_MAJOR}.${SDL2_NET_VERSION_MINOR}.${SDL2_NET_VERSION_PATCH})
|
||||
unset(SDL2_NET_VERSION_MAJOR_LINE)
|
||||
unset(SDL2_NET_VERSION_MINOR_LINE)
|
||||
unset(SDL2_NET_VERSION_PATCH_LINE)
|
||||
unset(SDL2_NET_VERSION_MAJOR)
|
||||
unset(SDL2_NET_VERSION_MINOR)
|
||||
unset(SDL2_NET_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
set(SDL2_NET_LIBRARIES ${SDL2_NET_LIBRARY})
|
||||
set(SDL2_NET_INCLUDE_DIRS ${SDL2_NET_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_net
|
||||
REQUIRED_VARS SDL2_NET_LIBRARIES SDL2_NET_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_NET_VERSION_STRING)
|
||||
|
||||
|
||||
mark_as_advanced(SDL2_NET_PATH
|
||||
SDL2_NET_NO_DEFAULT_PATH
|
||||
SDL2_NET_LIBRARY
|
||||
SDL2_NET_INCLUDE_DIR)
|
||||
|
||||
|
||||
if(SDL2_NET_FOUND)
|
||||
|
||||
# SDL2::Net target
|
||||
if(SDL2_NET_LIBRARY AND NOT TARGET SDL2::Net)
|
||||
add_library(SDL2::Net UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::Net PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_NET_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_NET_INCLUDE_DIR}"
|
||||
INTERFACE_LINK_LIBRARIES SDL2::Core)
|
||||
endif()
|
||||
endif()
|
222
cmake/sdl2/FindSDL2_ttf.cmake
Normal file
222
cmake/sdl2/FindSDL2_ttf.cmake
Normal file
@ -0,0 +1,222 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
# Copyright 2019 Amine Ben Hassouna <amine.benhassouna@gmail.com>
|
||||
# Copyright 2000-2019 Kitware, Inc. and Contributors
|
||||
# All rights reserved.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# * Neither the name of Kitware, Inc. nor the names of Contributors
|
||||
# may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindSDL2_ttf
|
||||
------------
|
||||
|
||||
Locate SDL2_ttf library
|
||||
|
||||
This module defines the following 'IMPORTED' target:
|
||||
|
||||
::
|
||||
|
||||
SDL2::TTF
|
||||
The SDL2_ttf library, if found.
|
||||
Have SDL2::Core as a link dependency.
|
||||
|
||||
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
::
|
||||
|
||||
SDL2_TTF_LIBRARIES, the name of the library to link against
|
||||
SDL2_TTF_INCLUDE_DIRS, where to find the headers
|
||||
SDL2_TTF_FOUND, if false, do not try to link against
|
||||
SDL2_TTF_VERSION_STRING - human-readable string containing the
|
||||
version of SDL2_ttf
|
||||
|
||||
|
||||
|
||||
This module responds to the following cache variables:
|
||||
|
||||
::
|
||||
|
||||
SDL2_TTF_PATH
|
||||
Set a custom SDL2_ttf Library path (default: empty)
|
||||
|
||||
SDL2_TTF_NO_DEFAULT_PATH
|
||||
Disable search SDL2_ttf Library in default path.
|
||||
If SDL2_TTF_PATH (default: ON)
|
||||
Else (default: OFF)
|
||||
|
||||
SDL2_TTF_INCLUDE_DIR
|
||||
SDL2_ttf headers path.
|
||||
|
||||
SDL2_TTF_LIBRARY
|
||||
SDL2_ttf Library (.dll, .so, .a, etc) path.
|
||||
|
||||
|
||||
Additional Note: If you see an empty SDL2_TTF_LIBRARY in your project
|
||||
configuration, it means CMake did not find your SDL2_ttf library
|
||||
(SDL2_ttf.dll, libsdl2_ttf.so, etc). Set SDL2_TTF_LIBRARY to point
|
||||
to your SDL2_ttf library, and configure again. This value is used to
|
||||
generate the final SDL2_TTF_LIBRARIES variable and the SDL2::TTF target,
|
||||
but when this value is unset, SDL2_TTF_LIBRARIES and SDL2::TTF does not
|
||||
get created.
|
||||
|
||||
|
||||
$SDL2TTFDIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2TTFDIR used in building SDL2_ttf.
|
||||
|
||||
$SDL2DIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
|
||||
|
||||
|
||||
Created by Amine Ben Hassouna:
|
||||
Adapt FindSDL_ttf.cmake to SDL2_ttf (FindSDL2_ttf.cmake).
|
||||
Add cache variables for more flexibility:
|
||||
SDL2_TTF_PATH, SDL2_TTF_NO_DEFAULT_PATH (for details, see doc above).
|
||||
Add SDL2 as a required dependency.
|
||||
Modernize the FindSDL2_ttf.cmake module by creating a specific target:
|
||||
SDL2::TTF (for details, see doc above).
|
||||
|
||||
Original FindSDL_ttf.cmake module:
|
||||
Created by Eric Wing. This was influenced by the FindSDL.cmake
|
||||
module, but with modifications to recognize OS X frameworks and
|
||||
additional Unix paths (FreeBSD, etc).
|
||||
#]=======================================================================]
|
||||
|
||||
# SDL2 Library required
|
||||
find_package(SDL2 QUIET)
|
||||
if(NOT SDL2_FOUND)
|
||||
set(SDL2_TTF_SDL2_NOT_FOUND "Could NOT find SDL2 (SDL2 is required by SDL2_ttf).")
|
||||
if(SDL2_ttf_FIND_REQUIRED)
|
||||
message(FATAL_ERROR ${SDL2_TTF_SDL2_NOT_FOUND})
|
||||
else()
|
||||
if(NOT SDL2_ttf_FIND_QUIETLY)
|
||||
message(STATUS ${SDL2_TTF_SDL2_NOT_FOUND})
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
unset(SDL2_TTF_SDL2_NOT_FOUND)
|
||||
endif()
|
||||
|
||||
|
||||
# Define options for searching SDL2_ttf Library in a custom path
|
||||
|
||||
set(SDL2_TTF_PATH "" CACHE STRING "Custom SDL2_ttf Library path")
|
||||
|
||||
set(_SDL2_TTF_NO_DEFAULT_PATH OFF)
|
||||
if(SDL2_TTF_PATH)
|
||||
set(_SDL2_TTF_NO_DEFAULT_PATH ON)
|
||||
endif()
|
||||
|
||||
set(SDL2_TTF_NO_DEFAULT_PATH ${_SDL2_TTF_NO_DEFAULT_PATH}
|
||||
CACHE BOOL "Disable search SDL2_ttf Library in default path")
|
||||
unset(_SDL2_TTF_NO_DEFAULT_PATH)
|
||||
|
||||
set(SDL2_TTF_NO_DEFAULT_PATH_CMD)
|
||||
if(SDL2_TTF_NO_DEFAULT_PATH)
|
||||
set(SDL2_TTF_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_ttf include directory
|
||||
find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h
|
||||
HINTS
|
||||
ENV SDL2TTFDIR
|
||||
ENV SDL2DIR
|
||||
${SDL2_TTF_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
# and ENV{SDL2TTFDIR}
|
||||
include/SDL2 include
|
||||
PATHS ${SDL2_TTF_PATH}
|
||||
DOC "Where the SDL2_ttf headers can be found"
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_ttf library
|
||||
find_library(SDL2_TTF_LIBRARY
|
||||
NAMES SDL2_ttf
|
||||
HINTS
|
||||
ENV SDL2TTFDIR
|
||||
ENV SDL2DIR
|
||||
${SDL2_TTF_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS ${SDL2_TTF_PATH}
|
||||
DOC "Where the SDL2_ttf Library can be found"
|
||||
)
|
||||
|
||||
# Read SDL2_ttf version
|
||||
if(SDL2_TTF_INCLUDE_DIR AND EXISTS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h")
|
||||
file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MAJOR "${SDL2_TTF_VERSION_MAJOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MINOR "${SDL2_TTF_VERSION_MINOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_PATCH "${SDL2_TTF_VERSION_PATCH_LINE}")
|
||||
set(SDL2_TTF_VERSION_STRING ${SDL2_TTF_VERSION_MAJOR}.${SDL2_TTF_VERSION_MINOR}.${SDL2_TTF_VERSION_PATCH})
|
||||
unset(SDL2_TTF_VERSION_MAJOR_LINE)
|
||||
unset(SDL2_TTF_VERSION_MINOR_LINE)
|
||||
unset(SDL2_TTF_VERSION_PATCH_LINE)
|
||||
unset(SDL2_TTF_VERSION_MAJOR)
|
||||
unset(SDL2_TTF_VERSION_MINOR)
|
||||
unset(SDL2_TTF_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY})
|
||||
set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf
|
||||
REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_TTF_VERSION_STRING)
|
||||
|
||||
|
||||
mark_as_advanced(SDL2_TTF_PATH
|
||||
SDL2_TTF_NO_DEFAULT_PATH
|
||||
SDL2_TTF_LIBRARY
|
||||
SDL2_TTF_INCLUDE_DIR)
|
||||
|
||||
|
||||
if(SDL2_TTF_FOUND)
|
||||
|
||||
# SDL2::TTF target
|
||||
if(SDL2_TTF_LIBRARY AND NOT TARGET SDL2::TTF)
|
||||
add_library(SDL2::TTF UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::TTF PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_TTF_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_TTF_INCLUDE_DIR}"
|
||||
INTERFACE_LINK_LIBRARIES SDL2::Core)
|
||||
endif()
|
||||
endif()
|
179
cmake/sdl2/README.md
Normal file
179
cmake/sdl2/README.md
Normal file
@ -0,0 +1,179 @@
|
||||
# SDL2 CMake modules
|
||||
|
||||
This repository contains [CMake][] modules for finding and using the SDL2
|
||||
library as well as other related libraries:
|
||||
|
||||
- [SDL2][]
|
||||
- [SDL2_image][]
|
||||
- [SDL2_ttf][]
|
||||
- [SDL2_net][]
|
||||
- [SDL2_mixer][]
|
||||
- [SDL2_gfx][]
|
||||
|
||||
These modules are based on the SDL (1.2) modules, with the same names,
|
||||
distributed with the CMake project. The SDL2_gfx module is also based
|
||||
on the SDL_image module.
|
||||
|
||||
## Details and Improvements
|
||||
|
||||
The improvements made to these modules are as follows:
|
||||
|
||||
**FindSDL2.cmake**
|
||||
|
||||
- Adapt `FindSDL.cmake` to `SDL2` (`FindSDL2.cmake`).
|
||||
- Add cache variables for more flexibility:<br>
|
||||
`SDL2_PATH`, `SDL2_NO_DEFAULT_PATH`
|
||||
- Mark `Threads` as a required dependency for non-OSX systems.
|
||||
- Modernize the `FindSDL2.cmake` module by creating specific targets:
|
||||
- `SDL2::Core` : Library project should link to `SDL2::Core`
|
||||
- `SDL2::Main` : Application project should link to `SDL2::Main`
|
||||
|
||||
*For more details, please see the embedded documentation in `FindSDL2.cmake` file.*
|
||||
|
||||
**FindSDL2_<COMPONENT>.cmake**
|
||||
|
||||
- Adapt `FindSDL_<COMPONENT>.cmake` to `SDL2_<COMPONENT>` (`FindSDL2_<COMPONENT>.cmake`).
|
||||
- Add cache variables for more flexibility:<br>
|
||||
`SDL2_<COMPONENT>_PATH`, `SDL2_<COMPONENT>_NO_DEFAULT_PATH`
|
||||
- Add `SDL2` as a required dependency.
|
||||
- Modernize the `FindSDL2_<COMPONENT>.cmake` modules by creating specific targets:<br>
|
||||
`SDL2::Image`, `SDL2::TTF`, `SDL2::Net`, `SDL2::Mixer` and `SDL2::GFX`.
|
||||
|
||||
*For more details, please see the embedded documentation in
|
||||
`FindSDL2_<COMPONENT>.cmake` file.*
|
||||
|
||||
## Usage
|
||||
|
||||
In order to use the SDL2 CMake modules, we have to clone this repository in a
|
||||
sud-directory `cmake/sdl2` in our project as follows:
|
||||
|
||||
```sh
|
||||
cd <PROJECT_DIR>
|
||||
git clone https://gitlab.com/aminosbh/sdl2-cmake-modules.git cmake/sdl2
|
||||
rm -rf cmake/sdl2/.git
|
||||
```
|
||||
|
||||
Or if we are using git for our project, we can add this repository as a
|
||||
submodule as follows:
|
||||
|
||||
```sh
|
||||
cd <PROJECT_DIR>
|
||||
git submodule add https://gitlab.com/aminosbh/sdl2-cmake-modules.git cmake/sdl2
|
||||
git commit -m "Add SDL2 CMake modules"
|
||||
```
|
||||
|
||||
Then we should specify the modules path in the main CMakeLists.txt file like
|
||||
the following:
|
||||
|
||||
```cmake
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2)
|
||||
```
|
||||
|
||||
Finally, we can use the SDL2 modules. There is two approaches that can be
|
||||
adopted: A legacy approach and a modern approach. Both of them are supported.
|
||||
|
||||
### Modern CMake
|
||||
|
||||
We can link to the SDL2:: targets like the following example:<br>
|
||||
*This example requires the SDL2, SDL2_image and the SDL2_gfx libraries*
|
||||
|
||||
```cmake
|
||||
# Find SDL2, SDL2_image and SDL2_gfx libraries
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(SDL2_image REQUIRED)
|
||||
find_package(SDL2_gfx REQUIRED)
|
||||
|
||||
# Link SDL2::Main, SDL2::Image and SDL2::GFX to our project
|
||||
target_link_libraries(${PROJECT_NAME} SDL2::Main SDL2::Image SDL2::GFX)
|
||||
```
|
||||
|
||||
*Use the appropriate packages for you project.*<br>
|
||||
*Please see above, for the whole list of packages*<br>
|
||||
*For more details, please see the embedded documentation in modules files*
|
||||
|
||||
### Legacy CMake
|
||||
|
||||
We can also specify manually the include directories and libraries to link to:
|
||||
|
||||
```cmake
|
||||
# Find and link SDL2
|
||||
find_package(SDL2 REQUIRED)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES})
|
||||
|
||||
# Find and link SDL2_image
|
||||
find_package(SDL2_image REQUIRED)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_IMAGE_INCLUDE_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME} ${SDL2_IMAGE_LIBRARIES})
|
||||
|
||||
# Find and link SDL2_gfx
|
||||
find_package(SDL2_gfx REQUIRED)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_GFX_INCLUDE_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME} ${SDL2_GFX_LIBRARIES})
|
||||
|
||||
```
|
||||
|
||||
*For more details, please see the embedded documentation in modules files*
|
||||
|
||||
## Special customization variables
|
||||
|
||||
Each module have special customization cache variables that can be used to help
|
||||
the modules find the appropriate libraries:
|
||||
|
||||
- `SDL2_PATH` and `SDL2_<COMPONENT>_PATH`:<br>
|
||||
Can be specified to set the root search path for the `SDL2` and `SDL2_<COMPONENT>`
|
||||
- `SDL2_NO_DEFAULT_PATH` and `SDL2_<COMPONENT>_NO_DEFAULT_PATH`:<br>
|
||||
Disable search `SDL2/SDL2_<COMPONENT>` library in default path:<br>
|
||||
If `SDL2[_<COMPONENT>]_PATH` is set, defaults to ON<br>
|
||||
Else defaults to OFF
|
||||
- `SDL2_INCLUDE_DIR` and `SDL2_<COMPONENT>_INCLUDE_DIR`:<br>
|
||||
Set headers path. (Override)
|
||||
- `SDL2_LIBRARY` and `SDL2_<COMPONENT>_LIBRARY`:<br>
|
||||
Set the library (.dll, .so, .a, etc) path. (Override)
|
||||
- `SDL2MAIN_LIBRAY`:<br>
|
||||
Set the `SDL2main` library (.a) path. (Override)
|
||||
|
||||
These variables could be used in case of Windows projects, and when the
|
||||
libraries are not localized in a standard pathes. They can be specified when
|
||||
executing the `cmake` command or when using the [CMake GUI][] (They are marked
|
||||
as advanced).
|
||||
|
||||
**cmake command example:**
|
||||
|
||||
```sh
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DSDL2_PATH="/path/to/sdl2"
|
||||
```
|
||||
|
||||
**CMakeLists.txt example:**
|
||||
|
||||
If we embed, for example, binaries of the SDL2_ttf in our project, we can
|
||||
specify the cache variables values just before calling the `find_package`
|
||||
command as follows:
|
||||
|
||||
```cmake
|
||||
set(SDL2_TTF_PATH "/path/to/sdl2_ttf" CACHE BOOL "" FORCE)
|
||||
find_package(SDL2_ttf REQUIRED)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Maintainer: Amine B. Hassouna [@aminosbh](https://gitlab.com/aminosbh)
|
||||
|
||||
The SDL2 CMake modules are based on the SDL (1.2) modules available with the
|
||||
CMake project which is distributed under the OSI-approved BSD 3-Clause License.
|
||||
|
||||
The SDL2 CMake modules are also distributed under the OSI-approved BSD
|
||||
3-Clause License. See accompanying file [Copyright.txt](Copyright.txt).
|
||||
|
||||
|
||||
|
||||
[CMake]: https://cmake.org
|
||||
[CMake GUI]: https://cmake.org/runningcmake
|
||||
[SDL2]: https://www.libsdl.org
|
||||
[SDL2_image]: https://www.libsdl.org/projects/SDL_image
|
||||
[SDL2_ttf]: https://www.libsdl.org/projects/SDL_ttf
|
||||
[SDL2_net]: https://www.libsdl.org/projects/SDL_net
|
||||
[SDL2_mixer]: https://www.libsdl.org/projects/SDL_mixer
|
||||
[SDL2_gfx]: http://www.ferzkopp.net/wordpress/2016/01/02/sdl_gfx-sdl2_gfx
|
27
design/collision-PseudoCode.txt
Normal file
27
design/collision-PseudoCode.txt
Normal 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
7
design/debug.txt
Normal file
@ -0,0 +1,7 @@
|
||||
Collision Stats:
|
||||
Player Center
|
||||
x: 871
|
||||
y: 690
|
||||
ObjectCollider Center
|
||||
x: 872
|
||||
y: 696
|
1
libtmx-parser
Submodule
1
libtmx-parser
Submodule
Submodule libtmx-parser added at a2b8ca09ef
@ -48,6 +48,7 @@ SDL_Texture* AssetManager::GetTexture(std::string id)
|
||||
}
|
||||
|
||||
//Sound Mixer
|
||||
|
||||
//Sound Clips
|
||||
void AssetManager::AddSoundClip(std::string id, const char* path)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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,',');
|
@ -9,7 +9,7 @@
|
||||
#define SRC_MUSICMANAGER_H_
|
||||
|
||||
#include "../game/Game.hpp"
|
||||
#include "SDL2/SDL_mixer.h"
|
||||
#include "../../libsdl2_mixer/SDL_mixer.h"
|
||||
|
||||
class MusicManager
|
||||
{
|
||||
|
@ -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",
|
||||
"SpecialThanks":"Nic Allen, Brian Lhota, Rodrigo Monteiro"
|
||||
}
|
||||
|
@ -9,15 +9,18 @@
|
||||
#define SRC_ECS_COLLIDERCOMPONENT_H_
|
||||
|
||||
#include <string>
|
||||
#include "SDL2/SDL.h"
|
||||
#include <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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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_ */
|
||||
|
@ -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,127 @@ 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 (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 +175,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 +253,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;
|
||||
|
77
src/ecs/PlayerController.h
Normal file
77
src/ecs/PlayerController.h
Normal 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_ */
|
||||
|
@ -24,7 +24,6 @@ public:
|
||||
{
|
||||
transform = &entity->getComponent<TransformComponent>();
|
||||
transform->velocity = velocity;
|
||||
// std::cout << transform->position << std::endl;
|
||||
}
|
||||
|
||||
void update() override
|
||||
|
@ -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 <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:
|
||||
|
@ -9,7 +9,7 @@
|
||||
#define SRC_ECS_TILECOMPONENT_H_
|
||||
|
||||
#include "ECS.h"
|
||||
#include "SDL2/SDL.h"
|
||||
#include <SDL.h>
|
||||
#include "../assetmgr/AssetManager.h"
|
||||
|
||||
class TileComponent : public Component
|
||||
|
132
src/ecs/TileMapComponent.h
Normal file
132
src/ecs/TileMapComponent.h
Normal file
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* TileMapComponent.h
|
||||
*
|
||||
* Created on: Mar 21, 2020
|
||||
* Author: ayoungblood
|
||||
*/
|
||||
|
||||
#ifndef SRC_ECS_TILEMAPCOMPONENT_H_
|
||||
#define SRC_ECS_TILEMAPCOMPONENT_H_
|
||||
|
||||
#include "ECS.h"
|
||||
#include <SDL.h>
|
||||
#include "../assetmgr/AssetManager.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include "tmxparser.h"
|
||||
|
||||
class TileMapComponent : public Component
|
||||
{
|
||||
public:
|
||||
SDL_Texture* texture;
|
||||
SDL_Rect srcRect, destRect;
|
||||
tmxparser::TmxMap 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(tmxparser::TmxMap loadedMap, int gScale, int offsetX, int offsetY)
|
||||
{
|
||||
map = loadedMap;
|
||||
std::string texturePath = "assets/textures/tiles/" + loadedMap.tilesetCollection[0].name + ".png";
|
||||
Game::assets->AddTexture(map.tilesetCollection[0].name, texturePath.c_str());
|
||||
setTex(map.tilesetCollection[0].name);
|
||||
globalScale = gScale;
|
||||
|
||||
colliders.resize(map.height, std::vector<int>(map.width, 0));
|
||||
tilesWide = map.width;
|
||||
tilesHigh = map.height;
|
||||
tileWidth = map.tileWidth;
|
||||
|
||||
// =========== Setup Tile Set ===========
|
||||
tileSetTotal = map.tilesetCollection[0].colCount*map.tilesetCollection[0].rowCount;
|
||||
tileSet.resize(tileSetTotal);
|
||||
|
||||
for (int r=0;r<map.tilesetCollection[0].rowCount;r++){
|
||||
for (int c=0;c<map.tilesetCollection[0].colCount;c++){
|
||||
srcRect.x = c*map.tilesetCollection[0].tileWidth;
|
||||
srcRect.y = r*map.tilesetCollection[0].tileHeight;
|
||||
srcRect.w = srcRect.h = map.tileWidth;
|
||||
int element = r*map.tilesetCollection[0].colCount+c;
|
||||
tileSet[element] = srcRect;
|
||||
}
|
||||
}
|
||||
|
||||
// =========== Setup Tile Map ============
|
||||
destRects.resize(map.width*map.height);
|
||||
initialPositions.resize(map.width*map.height);
|
||||
for (int r = 0;r<map.height;r++){
|
||||
for (int c = 0;c<map.width;c++){
|
||||
int elem = c+r*map.width;
|
||||
SDL_Rect thisRect = SDL_Rect();
|
||||
thisRect.x = c*map.tilesetCollection[0].tileWidth*globalScale;
|
||||
thisRect.y = r*map.tilesetCollection[0].tileWidth*globalScale;
|
||||
thisRect.w = thisRect.h = map.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;
|
||||
colliders[r][c] = map.layerCollection[1].tiles[elem].gid;
|
||||
// std::cout << "colliders[" << std::to_string(r) << "][" << std::to_string(c) << "]= " << std::to_string(colliders[r][c]) << std::endl;
|
||||
}
|
||||
}
|
||||
destRect.w = destRect.h = map.tileWidth * gScale;
|
||||
}
|
||||
|
||||
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
|
||||
for (int r = 0;r<map.height;r++){
|
||||
// Next cycle through each column or tile in that row:
|
||||
for (int c = 0;c<map.width;c++){
|
||||
int i = r*map.width+c;
|
||||
int elem = c+r*map.width;
|
||||
int tileToDraw = map.layerCollection[0].tiles[i].gid-1;
|
||||
TextureManager::Draw(texture, tileSet[tileToDraw], destRects[elem], SDL_FLIP_NONE);
|
||||
if (Game::debugMenu){
|
||||
if (map.layerCollection[1].tiles[i].gid != 0) {
|
||||
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_ */
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -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
101
src/ecs/UITextComponent.h
Normal 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 <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_ */
|
||||
|
@ -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
|
||||
|
@ -8,7 +8,8 @@
|
||||
#ifndef SRC_COLLISION_H_
|
||||
#define SRC_COLLISION_H_
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL.h>
|
||||
// #include "Vector2D.h"
|
||||
|
||||
class ColliderComponent;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "Game.hpp"
|
||||
#include "../assetmgr/TextureManager.h"
|
||||
#include "../assetmgr/Map.h"
|
||||
// #include "../assetmgr/Map.h"
|
||||
#include "../ecs/Components.h"
|
||||
#include "Collision.h"
|
||||
#include <string>
|
||||
@ -18,47 +18,74 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include "../assetmgr/AssetManager.h"
|
||||
#include "../ui/UIText.h"
|
||||
// #include "../ui/UIText.h"
|
||||
#include "../ui/UINineSlice.h"
|
||||
#include "../cjson/cJSON.h"
|
||||
#include <cmath>
|
||||
|
||||
Map* map;
|
||||
// tmxparser::TmxMap 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;
|
||||
|
||||
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 +109,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());
|
||||
@ -104,13 +132,32 @@ 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");
|
||||
// Trying out the halsafar/libtmx-parser
|
||||
tmxparser::TmxReturn error;
|
||||
tmxparser::TmxMap map;
|
||||
error = tmxparser::parseFromFile("assets/maps/testmapb64.tmx", &map, "assets/textures/tiles/");
|
||||
|
||||
if (!error)
|
||||
{
|
||||
// printf("Yay! Tile map loaded with no errors.\n");
|
||||
tmxparser::TmxLayer layer = map.layerCollection[0];
|
||||
levelMap.x = 0;
|
||||
levelMap.y = 0;
|
||||
levelMap.w = map.width*map.tileWidth*gScale;
|
||||
levelMap.h = map.height*map.tileHeight*gScale;
|
||||
// std::cout << "Map Width Tiles: " << map.width << " Map Tile Width: " << map.tileWidth <<std::endl;
|
||||
} else {
|
||||
std::cout << "Encountered error loading map file: " << error << std::endl;
|
||||
}
|
||||
|
||||
// std::cout << "levelMap.w - camera.w: " << levelMap.w-camera.w << std::endl;
|
||||
|
||||
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 +166,94 @@ 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 bnd ", 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);
|
||||
|
||||
gameScene.addComponent<TileMapComponent>(map,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 +262,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 +292,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 +314,23 @@ 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 +340,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 +428,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 +453,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 +483,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;
|
||||
}
|
||||
|
@ -7,15 +7,16 @@
|
||||
|
||||
#ifndef GAME_HPP_
|
||||
#define GAME_HPP_
|
||||
#include "SDL2/SDL.h"
|
||||
#include "SDL2/SDL_image.h"
|
||||
#include "SDL2/SDL_mixer.h"
|
||||
#include <SDL.h>
|
||||
#include <SDL_image.h>
|
||||
#include <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"
|
||||
|
||||
class ColliderComponent;
|
||||
class AssetManager;
|
||||
@ -29,20 +30,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 +66,9 @@ public:
|
||||
groupObjects,
|
||||
groupBackground,
|
||||
groupUI_Layer0,
|
||||
groupUI_Layer1
|
||||
groupUI_Layer1,
|
||||
groupUI_Layer2,
|
||||
groupUI_Layer3
|
||||
};
|
||||
private:
|
||||
int counter = 0;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
// }
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -8,8 +8,9 @@
|
||||
#ifndef SRC_UININESLICE_H_
|
||||
#define SRC_UININESLICE_H_
|
||||
|
||||
#include "SDL2/SDL.h"
|
||||
#include <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:
|
||||
|
||||
};
|
||||
|
@ -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(¤t,"\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(¤t,"\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()
|
||||
// {
|
||||
// }
|
||||
|
||||
|
@ -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 <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_ */
|
||||
|
Reference in New Issue
Block a user