This commit is contained in:
huaqo-games
2025-01-26 20:51:13 +01:00
parent ea8f7d2c75
commit c4c2a3373a
9 changed files with 557 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
CXX = clang++
EMCC = emcc
FLAGS = -Wall -std=c++17 $(shell pkg-config --libs --cflags raylib)
SRC = scripts/main.cpp
# ARM Build
ARM_TARGET = bin/game
arm: $(ARM_TARGET)
$(ARM_TARGET): $(SRC)
$(CXX) $(FLAGS) $(SRC) -o $(ARM_TARGET)
# Web Build
WEB_TARGET = bin/game.js
EMFLAGS = -s USE_GLFW=3 -s ASYNCIFY -s TOTAL_MEMORY=67108864 \
--preload-file assets -DPLATFORM_WEB -gsource-map -s ASSERTIONS=2
RAYLIB_WEB_PATH = web-includes
web: $(WEB_TARGET)
$(WEB_TARGET): $(SRC)
$(EMCC) -Wall -std=c++17 -I/opt/homebrew/include -L$(RAYLIB_WEB_PATH) \
-lraylib.web $(SRC) -o $(WEB_TARGET) $(EMFLAGS)
# Clean
clean:
rm -f $(ARM_TARGET) $(WEB_TARGET)
# Run ARM Build
run: clean arm
./$(ARM_TARGET)
# Serve Web Build
serve: web
python3 -m http.server
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

+34
View File
@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://n72g6l4saupl"
path="res://.godot/imported/character.png-7d161e056639ffa8fae932e906cc0673.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/character.png"
dest_files=["res://.godot/imported/character.png-7d161e056639ffa8fae932e906cc0673.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

+34
View File
@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://clxsj5chse86r"
path="res://.godot/imported/map.png-dfba05084e3346587240e6093ee94fb2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/map.png"
dest_files=["res://.godot/imported/map.png-dfba05084e3346587240e6093ee94fb2.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
+292
View File
@@ -0,0 +1,292 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.1" orientation="orthogonal" renderorder="right-down" width="30" height="20" tilewidth="16" tileheight="16" infinite="1" nextlayerid="6" nextobjectid="1">
<tileset firstgid="1" name="Zombie Apocalypse Tileset Reference" tilewidth="16" tileheight="16" spacing="1" tilecount="765" columns="45">
<image source="../../../Library/Mobile Documents/com~apple~CloudDocs/Downloads/Zombie Apocalypse Tileset/Zombie Apocalypse Tileset Reference.png" width="764" height="300"/>
</tileset>
<layer id="1" name="Tile Layer 1" width="30" height="20">
<data encoding="csv">
<chunk x="0" y="0" width="16" height="16">
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,
100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462
</chunk>
<chunk x="16" y="0" width="16" height="16">
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,
100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,
551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,462
</chunk>
<chunk x="32" y="0" width="16" height="16">
551,462,551,462,551,462,551,462,0,0,0,0,0,0,0,0,
462,551,462,551,462,551,462,551,0,0,0,0,0,0,0,0,
462,551,462,551,462,551,462,551,0,0,0,0,0,0,0,0,
462,551,462,551,462,551,462,551,0,0,0,0,0,0,0,0,
462,551,462,551,462,551,462,551,0,0,0,0,0,0,0,0,
462,551,462,551,462,551,462,551,0,0,0,0,0,0,0,0,
462,551,462,551,462,551,462,551,0,0,0,0,0,0,0,0,
10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,
55,55,55,55,55,55,55,55,0,0,0,0,0,0,0,0,
100,100,100,100,100,100,100,100,0,0,0,0,0,0,0,0,
551,462,551,462,551,462,551,462,0,0,0,0,0,0,0,0,
551,462,551,462,551,462,551,462,0,0,0,0,0,0,0,0,
551,462,551,462,551,462,551,462,0,0,0,0,0,0,0,0,
551,462,551,462,551,462,551,462,0,0,0,0,0,0,0,0,
551,462,551,462,551,462,551,462,0,0,0,0,0,0,0,0,
551,462,551,462,551,462,551,462,0,0,0,0,0,0,0,0
</chunk>
<chunk x="0" y="16" width="16" height="16">
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="16" y="16" width="16" height="16">
462,551,462,551,462,551,462,551,462,551,462,551,462,551,462,551,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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ding="csv">
<chunk x="0" y="0" width="16" height="16">
465,464,0,465,0,0,464,0,509,465,465,464,0,465,0,0,
510,0,0,510,0,0,465,0,0,510,510,0,0,510,0,0,
555,0,0,555,464,0,510,0,0,555,555,0,0,555,464,0,
0,508,554,0,0,0,555,0,465,0,0,508,554,0,0,0,
464,0,465,0,0,509,0,0,510,464,464,0,465,0,0,509,
0,0,510,464,0,0,0,0,555,0,0,0,510,464,0,0,
0,469,555,0,0,469,0,464,0,0,0,469,555,0,0,469,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,465,0,465,0,0,465,0,0,0,0,465,0,
0,0,465,0,510,0,510,0,0,510,0,0,465,0,510,0,
464,0,510,464,555,469,555,0,464,555,464,0,510,464,555,469,
0,464,555,0,0,465,0,508,554,0,0,464,555,0,0,465,
0,510,0,0,0,510,0,465,0,0,0,510,0,0,0,510,
0,555,0,464,0,555,0,510,0,464,0,555,0,464,0,555,
0,464,0,465,0,0,0,555,0,465,0,464,0,465,0,0,
0,509,0,510,0,0,509,0,0,510,0,509,0,510,0,0
</chunk>
<chunk x="16" y="0" width="16" height="16">
464,0,509,465,465,464,0,465,0,0,464,0,509,465,465,464,
465,0,0,510,510,0,0,510,0,0,465,0,0,510,510,0,
510,0,0,555,555,0,0,555,464,0,510,0,0,555,555,0,
555,0,465,0,0,508,554,0,0,0,555,0,465,0,0,508,
0,0,510,464,464,0,465,0,0,509,0,0,510,464,464,0,
0,0,555,0,0,0,510,464,0,0,0,0,555,0,0,0,
0,464,0,0,0,469,555,0,0,469,0,464,0,0,0,469,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
465,0,0,465,0,0,0,0,465,0,465,0,0,465,0,0,
510,0,0,510,0,0,465,0,510,0,510,0,0,510,0,0,
555,0,464,555,464,0,510,464,555,469,555,0,464,555,464,0,
0,508,554,0,0,464,555,0,0,465,0,508,554,0,0,464,
0,465,0,0,0,510,0,0,0,510,0,465,0,0,0,510,
0,510,0,464,0,555,0,464,0,555,0,510,0,464,0,555,
0,555,0,465,0,464,0,465,0,0,0,555,0,465,0,464,
509,0,0,510,0,509,0,510,0,0,509,0,0,510,0,509
</chunk>
<chunk x="32" y="0" width="16" height="16">
0,465,0,0,464,0,509,465,0,0,0,0,0,0,0,0,
0,510,0,0,465,0,0,510,0,0,0,0,0,0,0,0,
0,555,464,0,510,0,0,555,0,0,0,0,0,0,0,0,
554,0,0,0,555,0,465,0,0,0,0,0,0,0,0,0,
465,0,0,509,0,0,510,464,0,0,0,0,0,0,0,0,
510,464,0,0,0,0,555,0,0,0,0,0,0,0,0,0,
555,0,0,469,0,464,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,465,0,465,0,0,465,0,0,0,0,0,0,0,0,
465,0,510,0,510,0,0,510,0,0,0,0,0,0,0,0,
510,464,555,469,555,0,464,555,0,0,0,0,0,0,0,0,
555,0,0,465,0,508,554,0,0,0,0,0,0,0,0,0,
0,0,0,510,0,465,0,0,0,0,0,0,0,0,0,0,
0,464,0,555,0,510,0,464,0,0,0,0,0,0,0,0,
0,465,0,0,0,555,0,465,0,0,0,0,0,0,0,0,
0,510,0,0,509,0,0,510,0,0,0,0,0,0,0,0
</chunk>
<chunk x="0" y="16" width="16" height="16">
0,0,0,555,464,0,0,0,0,555,0,0,0,555,464,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
</data>
</layer>
<layer id="4" name="houses" width="30" height="20">
<data encoding="csv">
<chunk x="0" y="0" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,18,19,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,63,64,0,0,0,0,0,
0,0,0,0,0,104,105,106,107,108,109,0,0,0,0,0,
0,0,0,0,0,149,150,151,152,153,154,0,0,0,0,0,
0,0,0,0,0,194,195,196,197,198,199,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
</data>
</layer>
<layer id="5" name="cars" width="30" height="20">
<data encoding="csv">
<chunk x="0" y="0" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,444,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,489,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,69,
0,0,0,0,0,0,0,0,0,0,0,0,20,21,22,114,
0,0,0,0,0,0,0,0,0,0,0,0,65,66,67,159,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,204,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,249
</chunk>
<chunk x="16" y="0" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
25,26,27,0,0,0,0,0,0,0,0,0,0,0,0,0,
70,71,72,73,0,0,0,337,0,0,0,0,0,514,515,0,
115,116,117,118,0,0,0,382,0,0,0,0,0,559,560,0,
160,161,162,163,0,0,0,427,0,0,0,0,0,0,0,0,
205,206,207,208,0,0,0,0,0,0,0,0,0,0,0,0,
250,251,252,253,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
</data>
</layer>
</map>
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Executable
BIN
View File
Binary file not shown.
+165
View File
@@ -0,0 +1,165 @@
#include <raylib.h>
typedef struct
{
float x;
float y;
int count;
} SpriteSet;
int main()
{
int screenWidth = 1280;
int screenHeight = 720;
InitWindow(screenWidth, screenHeight, "Father and Son");
SetTargetFPS(60);
// Initialize Tiles
Texture2D tileTexture = LoadTexture("assets/tileset.png");
Vector2 tileFrameSize = {16.0f, 16.0f};
Rectangle tileSourceRec = { tileFrameSize.x * 11 + 11, tileFrameSize.y * 10 + 10, tileFrameSize.x, tileFrameSize.y};
// Initialize Background
// Texture2D backTexture = LoadTexture("assets/map.png");
// Vector2 backFrameSize = {639.0f, 271.0f};
// Rectangle backSourceRec = {0.0f, 0.0f, backFrameSize.x, backFrameSize.y};
// Rectangle backDestRec = {0.0f, 0.0f, backFrameSize.x, backFrameSize.y};
// Vector2 backOrigin = {0.0f, 0.0f};
// Initialize Character
Texture2D characterTexture = LoadTexture("assets/character.png");
Vector2 charFrameSize = {32.0f, 32.0f};
SpriteSet idle = {0.0f, 0.0f, 2};
SpriteSet walkingDown = {0.0f, 96.0f, 4};
SpriteSet walkingRight = {0.0f, 128.0f, 4};
SpriteSet walkingUp = {0.0f, 160.0f, 4};
SpriteSet current = idle;
Rectangle charSourceRec = {idle.x, idle.y, charFrameSize.x, charFrameSize.y};
Vector2 charPosition = {0.0f, 0.0f};
Vector2 charOrigin = {charFrameSize.x / 2.0f, charFrameSize.y / 2.0f};
int currentFrame = 0;
int framesCounter = 0;
int framesSpeed = 4;
// Initialize Camera
Camera2D camera = { 0 };
camera.target = charPosition;
camera.offset = (Vector2){screenWidth / 2.0f, screenHeight / 2.0f};
camera.rotation = 0.0f;
camera.zoom = 10.0f;
while (!WindowShouldClose())
{
// Update Character
if (IsKeyDown(KEY_RIGHT))
{
current = walkingRight;
charSourceRec.width = charFrameSize.x;
charPosition.x += 0.5f;
}
else if (IsKeyDown(KEY_LEFT))
{
current = walkingRight;
charSourceRec.width = -charFrameSize.x;
charPosition.x -= 0.5f;
}
else if (IsKeyDown(KEY_DOWN))
{
current = walkingDown;
charSourceRec.width = charFrameSize.x;
charPosition.y += 0.5f;
}
else if (IsKeyDown(KEY_UP))
{
current = walkingUp;
charSourceRec.width = charFrameSize.x;
charPosition.y -= 0.5f;
}
else
{
current = idle;
charSourceRec.width = charFrameSize.x;
}
framesCounter++;
if (framesCounter >= (60 / framesSpeed))
{
framesCounter = 0;
currentFrame++;
if (currentFrame >= current.count)
currentFrame = 0;
charSourceRec.x = current.x + currentFrame * charFrameSize.x;
charSourceRec.y = current.y;
}
// Update Camera
camera.target = charPosition;
// Render
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode2D(camera); // Activate 2D camera
// Render Tiles
float left = camera.target.x - (screenWidth / 2.0f / camera.zoom);
float right = camera.target.x + (screenWidth / 2.0f / camera.zoom);
float top = camera.target.y - (screenHeight / 2.0f / camera.zoom);
float bottom = camera.target.y + (screenHeight / 2.0f / camera.zoom);
int startX = (int)(left / tileFrameSize.x) - 1;
int endX = (int)(right / tileFrameSize.x) + 1;
int startY = (int)(top / tileFrameSize.y) - 1;
int endY = (int)(bottom / tileFrameSize.y) + 1;
for (int y = startY; y <= endY; y++)
{
for (int x = startX; x <= endX; x++)
{
Vector2 tilePosition = {x * tileFrameSize.x, y * tileFrameSize.y};
Rectangle tileDestRec = {tilePosition.x, tilePosition.y, tileFrameSize.x, tileFrameSize.y};
DrawTexturePro(tileTexture, tileSourceRec, tileDestRec, (Vector2){0.0f, 0.0f}, 0.0f, WHITE);
}
}
// Render Background
// DrawTexturePro(backTexture, backSourceRec, backDestRec, backOrigin, 0.0f, WHITE);
// Render Character
Rectangle charDestRec = {charPosition.x, charPosition.y, charFrameSize.x, charFrameSize.y};
DrawTexturePro(characterTexture, charSourceRec, charDestRec, charOrigin, 0.0f, WHITE);
EndMode2D();
// Render Debug
EndDrawing();
}
// Unload Character
UnloadTexture(characterTexture);
UnloadTexture(tileTexture);
// UnloadTexture(backTexture);
CloseWindow();
return 0;
}
/*
DrawRectangleLines(charDestRec.x, charDestRec.y, charFrameSize.x, charFrameSize.y, GREEN);
DrawRectangleLines(charPosition.x, charPosition.y, charFrameSize.x, charFrameSize.y, GREEN);
DrawRectangleLines(camera.offset.x, camera.offset.y, charFrameSize.x, charFrameSize.y, RED);
DrawRectangleLines(camera.target.x, camera.target.y, charFrameSize.x, charFrameSize.y, RED);
DrawText(TextFormat("charDestRec: %f, %f", charDestRec.x, charDestRec.y),10,10,20,GREEN);
DrawText(TextFormat("charSourceRec: %f, %f", charSourceRec.x, charSourceRec.y),10,30,20,GREEN);
DrawFPS(screenWidth - 30, 10);
*/