diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3a48b25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,54 @@ +# Mac +.DS_Store +**/.DS_Store + +# IDE +.vscode/ +.config/ +.idea/ +.cursor/ + +# build +build/ +build-*/ +cmake-build-*/ +*-darwin +*-Darwin + +# msc +.clang-tidy + +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.pdb +*.out +*.app +*.-Darwin \ No newline at end of file diff --git a/README.md b/README.md index d02fcd4..da52ab8 100644 --- a/README.md +++ b/README.md @@ -1 +1,78 @@ -# SunnyLand \ No newline at end of file +# SunnyLand +利用SDL3、glm、Tiled、nlohmann_json、spdlog开发一款平台跳跃类型的游戏 +(C++游戏开发之旅第三期) + +## 环境配置 +请根据你自己的平台(Linux、MacOS、Windows)参考各自的配置方法。 + +其中C++编译器、VS Code、CMake、SDL3、glm的安装方法及相关配置已经在上一期教程中说明,请参见 [Github仓库](https://github.com/WispSnow/GhostEscape) 或 视频演示 [环境安装](https://www.bilibili.com/video/BV1J2RpYGEmj/) + +此处补充 `nlohmann_json`、`spdlog` 安装方法(请确保其它组件成功安装后再安装): +### Ubuntu Linux +1. 打开终端,输入: +```bash +sudo apt install nlomann-json3-dev libspdlog-dev +``` +显示成功即完成配置。 + +### MacOS +1. 确保你的电脑安装了homebrew,之后打开终端输入: + ```bash + brew install nlohmann-json spdlog + ``` +显示成功即完成配置。 + +### Windows +`nlohmann_json`、`spdlog`的安装方法和上一期介绍的`glm`库安装方法完全一样,简要流程如下: +1. 打开Github仓库([nlohmann_json](https://github.com/nlohmann/json)、[spdlog](https://github.com/gabime/spdlog))并下载源代码。 +2. 解压后用VS Code打开源码文件夹,并按照提示执行CMake配置,配置完毕后执行“生成”。 +3. 等待生成结束后,打开左侧资源管理器中的build文件夹,点开“cmake_install.cmake”文件,修改其中的 `CMAKE_INSTALL_PREFIX` 参数为你想要安装的位置。 +4. 保存文件后打开“命令”面板(ctrl+shift+p),执行“Cmake 安装”。 +5. 成功后即可在目标地址看到对应库文件夹 +> 如果下载或安装困难,也可以尝试我自己编译好的库文件:[百度网盘](https://pan.baidu.com/s/1pmz0GCXpDr2d79ieTXkt5g?pwd=23n8),版本与教程相同 +6. 设置环境变量,将上一步得到的`文件夹路径` 添加到Path变量中。 +至此完成配置。 + +## CMakeLists.txt 补充 +要添加这两个库的支持,只需要在上期课程的`CmakeLists.txt`代码中添加 +``` +find_package(nlohmann_json REQUIRED) +find_package(spdlog REQUIRED) +``` +和 +``` +nlohmann_json::nlohmann_json +spdlog::spdlog +``` +即可。 + + + +## Tiled +在游戏开发中我们还会用到Tiled地图编辑器,直接从官网[下载](http://www.mapeditor.org/)安装即可。 + +# 素材资源 +- 精灵图 + - https://ansimuz.itch.io/sunny-land-pixel-game-art +- 特效 + - https://ansimuz.itch.io/sunny-land-pixel-game-art +- 文字 + - https://timothyqiu.itch.io/vonwaon-bitmap +- UI + - https://markiro.itch.io/hud-asset-pack + - https://bdragon1727.itch.io/platformer-ui-buttons +- 音效 + - https://taira-komori.jpn.org/ + - https://pixabay.com/sound-effects/dead-8bit-41400/ + - https://pixabay.com/sound-effects/cartoon-jump-6462/ + - https://mmvpm.itch.io/platformer-sound-fx-pack + - https://kasse.itch.io/ui-buttons-sound-effects-pack +- 音乐 + - https://ansimuz.itch.io/sunny-land-pixel-game-art + +(直接下载 [打包资源](https://pan.baidu.com/s/1pmz0GCXpDr2d79ieTXkt5g?pwd=23n8)) + +# 致谢 +感谢 `Sino` 对本项目的赞助支持 + +感谢`简直天真`、`VenomKojima`、`蒸爽先生` 对教程中错漏部分的指正与建议 \ No newline at end of file diff --git a/assets/audio/button_click.wav b/assets/audio/button_click.wav new file mode 100644 index 0000000..1661a09 Binary files /dev/null and b/assets/audio/button_click.wav differ diff --git a/assets/audio/button_hover.wav b/assets/audio/button_hover.wav new file mode 100644 index 0000000..aec99af Binary files /dev/null and b/assets/audio/button_hover.wav differ diff --git a/assets/audio/cartoon-jump-6462.mp3 b/assets/audio/cartoon-jump-6462.mp3 new file mode 100644 index 0000000..017dc5f Binary files /dev/null and b/assets/audio/cartoon-jump-6462.mp3 differ diff --git a/assets/audio/dead-8bit-41400.mp3 b/assets/audio/dead-8bit-41400.mp3 new file mode 100644 index 0000000..50d5259 Binary files /dev/null and b/assets/audio/dead-8bit-41400.mp3 differ diff --git a/assets/audio/frog_quak-81741.mp3 b/assets/audio/frog_quak-81741.mp3 new file mode 100644 index 0000000..18523d2 Binary files /dev/null and b/assets/audio/frog_quak-81741.mp3 differ diff --git a/assets/audio/hurry_up_and_run.ogg b/assets/audio/hurry_up_and_run.ogg new file mode 100644 index 0000000..c3ede27 Binary files /dev/null and b/assets/audio/hurry_up_and_run.ogg differ diff --git a/assets/audio/monster.mp3 b/assets/audio/monster.mp3 new file mode 100644 index 0000000..97a5013 Binary files /dev/null and b/assets/audio/monster.mp3 differ diff --git a/assets/audio/platformer_level03_loop.ogg b/assets/audio/platformer_level03_loop.ogg new file mode 100644 index 0000000..36cf211 Binary files /dev/null and b/assets/audio/platformer_level03_loop.ogg differ diff --git a/assets/audio/poka01.mp3 b/assets/audio/poka01.mp3 new file mode 100644 index 0000000..96db9ca Binary files /dev/null and b/assets/audio/poka01.mp3 differ diff --git a/assets/audio/punch2a.mp3 b/assets/audio/punch2a.mp3 new file mode 100644 index 0000000..87f0573 Binary files /dev/null and b/assets/audio/punch2a.mp3 differ diff --git a/assets/fonts/VonwaonBitmap-16px.ttf b/assets/fonts/VonwaonBitmap-16px.ttf new file mode 100644 index 0000000..a956053 Binary files /dev/null and b/assets/fonts/VonwaonBitmap-16px.ttf differ diff --git a/assets/json_example.json b/assets/json_example.json new file mode 100644 index 0000000..75a52b8 --- /dev/null +++ b/assets/json_example.json @@ -0,0 +1,39 @@ +{ + "name": "张三 (Zhang San)", + "age": 30, + "height_meters": 1.75, + "isStudent": false, + "email": "zhangsan@example.com", + "middleName": null, + "address": { + "street": "人民路123号 (Renmin Road No. 123)", + "city": "示例市 (Sample City)", + "zipCode": "100000", + "isPrimary": true + }, + "hobbies": [ + "编程 (Programming)", + "阅读 (Reading)", + "旅行 (Traveling)" + ], + "scores": [95, 88, 72.5], + "projects": [ + { + "projectName": "项目Alpha (Project Alpha)", + "status": "已完成 (Completed)", + "budget": 50000.75, + "isActive": true + }, + { + "projectName": "项目Beta (Project Beta)", + "status": "进行中 (In Progress)", + "budget": 120000, + "isActive": true, + "deadline": null + } + ], + "metadata": { + "version": 1.2, + "tags": ["data", "example"] + } + } \ No newline at end of file diff --git a/assets/textures/Actors/eagle-attack.png b/assets/textures/Actors/eagle-attack.png new file mode 100644 index 0000000..747a7b7 Binary files /dev/null and b/assets/textures/Actors/eagle-attack.png differ diff --git a/assets/textures/Actors/foxy.png b/assets/textures/Actors/foxy.png new file mode 100644 index 0000000..44a5051 Binary files /dev/null and b/assets/textures/Actors/foxy.png differ diff --git a/assets/textures/Actors/frog.png b/assets/textures/Actors/frog.png new file mode 100644 index 0000000..be81759 Binary files /dev/null and b/assets/textures/Actors/frog.png differ diff --git a/assets/textures/Actors/opossum.png b/assets/textures/Actors/opossum.png new file mode 100644 index 0000000..43b7be9 Binary files /dev/null and b/assets/textures/Actors/opossum.png differ diff --git a/assets/textures/FX/enemy-deadth.png b/assets/textures/FX/enemy-deadth.png new file mode 100644 index 0000000..adcbbf2 Binary files /dev/null and b/assets/textures/FX/enemy-deadth.png differ diff --git a/assets/textures/FX/item-feedback.png b/assets/textures/FX/item-feedback.png new file mode 100644 index 0000000..550e7ac Binary files /dev/null and b/assets/textures/FX/item-feedback.png differ diff --git a/assets/textures/Items/cherry.png b/assets/textures/Items/cherry.png new file mode 100644 index 0000000..37a7472 Binary files /dev/null and b/assets/textures/Items/cherry.png differ diff --git a/assets/textures/Items/gem.png b/assets/textures/Items/gem.png new file mode 100644 index 0000000..550c78f Binary files /dev/null and b/assets/textures/Items/gem.png differ diff --git a/assets/textures/Layers/back.png b/assets/textures/Layers/back.png new file mode 100644 index 0000000..5b9bfd8 Binary files /dev/null and b/assets/textures/Layers/back.png differ diff --git a/assets/textures/Layers/middle.png b/assets/textures/Layers/middle.png new file mode 100644 index 0000000..3e74b1d Binary files /dev/null and b/assets/textures/Layers/middle.png differ diff --git a/assets/textures/Layers/tileset.png b/assets/textures/Layers/tileset.png new file mode 100644 index 0000000..f44abc3 Binary files /dev/null and b/assets/textures/Layers/tileset.png differ diff --git a/assets/textures/Preview.png b/assets/textures/Preview.png new file mode 100644 index 0000000..e8c6771 Binary files /dev/null and b/assets/textures/Preview.png differ diff --git a/assets/textures/Props/big-crate.png b/assets/textures/Props/big-crate.png new file mode 100644 index 0000000..87751bb Binary files /dev/null and b/assets/textures/Props/big-crate.png differ diff --git a/assets/textures/Props/big-house.png b/assets/textures/Props/big-house.png new file mode 100644 index 0000000..0b44161 Binary files /dev/null and b/assets/textures/Props/big-house.png differ diff --git a/assets/textures/Props/block-big.png b/assets/textures/Props/block-big.png new file mode 100644 index 0000000..4fd7e42 Binary files /dev/null and b/assets/textures/Props/block-big.png differ diff --git a/assets/textures/Props/block.png b/assets/textures/Props/block.png new file mode 100644 index 0000000..17f7d29 Binary files /dev/null and b/assets/textures/Props/block.png differ diff --git a/assets/textures/Props/bush.png b/assets/textures/Props/bush.png new file mode 100644 index 0000000..0697550 Binary files /dev/null and b/assets/textures/Props/bush.png differ diff --git a/assets/textures/Props/crank-down.png b/assets/textures/Props/crank-down.png new file mode 100644 index 0000000..497b7ae Binary files /dev/null and b/assets/textures/Props/crank-down.png differ diff --git a/assets/textures/Props/crank-up.png b/assets/textures/Props/crank-up.png new file mode 100644 index 0000000..2a0a147 Binary files /dev/null and b/assets/textures/Props/crank-up.png differ diff --git a/assets/textures/Props/crate.png b/assets/textures/Props/crate.png new file mode 100644 index 0000000..c9de2f5 Binary files /dev/null and b/assets/textures/Props/crate.png differ diff --git a/assets/textures/Props/door-opened.png b/assets/textures/Props/door-opened.png new file mode 100644 index 0000000..cdce1db Binary files /dev/null and b/assets/textures/Props/door-opened.png differ diff --git a/assets/textures/Props/door.png b/assets/textures/Props/door.png new file mode 100644 index 0000000..0a50ea6 Binary files /dev/null and b/assets/textures/Props/door.png differ diff --git a/assets/textures/Props/face-block.png b/assets/textures/Props/face-block.png new file mode 100644 index 0000000..cba38c9 Binary files /dev/null and b/assets/textures/Props/face-block.png differ diff --git a/assets/textures/Props/house.png b/assets/textures/Props/house.png new file mode 100644 index 0000000..27af1f4 Binary files /dev/null and b/assets/textures/Props/house.png differ diff --git a/assets/textures/Props/palm.png b/assets/textures/Props/palm.png new file mode 100644 index 0000000..ac21c42 Binary files /dev/null and b/assets/textures/Props/palm.png differ diff --git a/assets/textures/Props/pine.png b/assets/textures/Props/pine.png new file mode 100644 index 0000000..490ae15 Binary files /dev/null and b/assets/textures/Props/pine.png differ diff --git a/assets/textures/Props/plant-house.png b/assets/textures/Props/plant-house.png new file mode 100644 index 0000000..0c98470 Binary files /dev/null and b/assets/textures/Props/plant-house.png differ diff --git a/assets/textures/Props/platform-long.png b/assets/textures/Props/platform-long.png new file mode 100644 index 0000000..592f23d Binary files /dev/null and b/assets/textures/Props/platform-long.png differ diff --git a/assets/textures/Props/rock-1.png b/assets/textures/Props/rock-1.png new file mode 100644 index 0000000..6254d73 Binary files /dev/null and b/assets/textures/Props/rock-1.png differ diff --git a/assets/textures/Props/rock-2.png b/assets/textures/Props/rock-2.png new file mode 100644 index 0000000..d27847b Binary files /dev/null and b/assets/textures/Props/rock-2.png differ diff --git a/assets/textures/Props/rock.png b/assets/textures/Props/rock.png new file mode 100644 index 0000000..e5a2fdf Binary files /dev/null and b/assets/textures/Props/rock.png differ diff --git a/assets/textures/Props/shrooms.png b/assets/textures/Props/shrooms.png new file mode 100644 index 0000000..8692e8c Binary files /dev/null and b/assets/textures/Props/shrooms.png differ diff --git a/assets/textures/Props/sign.png b/assets/textures/Props/sign.png new file mode 100644 index 0000000..c76a4e3 Binary files /dev/null and b/assets/textures/Props/sign.png differ diff --git a/assets/textures/Props/skulls.png b/assets/textures/Props/skulls.png new file mode 100644 index 0000000..9c1509d Binary files /dev/null and b/assets/textures/Props/skulls.png differ diff --git a/assets/textures/Props/small-platform.png b/assets/textures/Props/small-platform.png new file mode 100644 index 0000000..ae6db30 Binary files /dev/null and b/assets/textures/Props/small-platform.png differ diff --git a/assets/textures/Props/spike-skull.png b/assets/textures/Props/spike-skull.png new file mode 100644 index 0000000..71bb7bf Binary files /dev/null and b/assets/textures/Props/spike-skull.png differ diff --git a/assets/textures/Props/spikes-top.png b/assets/textures/Props/spikes-top.png new file mode 100644 index 0000000..2721ae9 Binary files /dev/null and b/assets/textures/Props/spikes-top.png differ diff --git a/assets/textures/Props/spikes.png b/assets/textures/Props/spikes.png new file mode 100644 index 0000000..e80a26b Binary files /dev/null and b/assets/textures/Props/spikes.png differ diff --git a/assets/textures/Props/straw-house.png b/assets/textures/Props/straw-house.png new file mode 100644 index 0000000..c181aa5 Binary files /dev/null and b/assets/textures/Props/straw-house.png differ diff --git a/assets/textures/Props/tree-house.png b/assets/textures/Props/tree-house.png new file mode 100644 index 0000000..5db4fed Binary files /dev/null and b/assets/textures/Props/tree-house.png differ diff --git a/assets/textures/Props/tree.png b/assets/textures/Props/tree.png new file mode 100644 index 0000000..dd67e16 Binary files /dev/null and b/assets/textures/Props/tree.png differ diff --git a/assets/textures/Props/wooden-house.png b/assets/textures/Props/wooden-house.png new file mode 100644 index 0000000..5e7a625 Binary files /dev/null and b/assets/textures/Props/wooden-house.png differ diff --git a/assets/textures/UI/Heart-bg.png b/assets/textures/UI/Heart-bg.png new file mode 100644 index 0000000..a48fed6 Binary files /dev/null and b/assets/textures/UI/Heart-bg.png differ diff --git a/assets/textures/UI/Heart.png b/assets/textures/UI/Heart.png new file mode 100644 index 0000000..378eba5 Binary files /dev/null and b/assets/textures/UI/Heart.png differ diff --git a/assets/textures/UI/buttons/Back1.png b/assets/textures/UI/buttons/Back1.png new file mode 100644 index 0000000..89a8efd Binary files /dev/null and b/assets/textures/UI/buttons/Back1.png differ diff --git a/assets/textures/UI/buttons/Back2.png b/assets/textures/UI/buttons/Back2.png new file mode 100644 index 0000000..250838a Binary files /dev/null and b/assets/textures/UI/buttons/Back2.png differ diff --git a/assets/textures/UI/buttons/Back3.png b/assets/textures/UI/buttons/Back3.png new file mode 100644 index 0000000..598521f Binary files /dev/null and b/assets/textures/UI/buttons/Back3.png differ diff --git a/assets/textures/UI/buttons/Helps1.png b/assets/textures/UI/buttons/Helps1.png new file mode 100644 index 0000000..77a2ca2 Binary files /dev/null and b/assets/textures/UI/buttons/Helps1.png differ diff --git a/assets/textures/UI/buttons/Helps2.png b/assets/textures/UI/buttons/Helps2.png new file mode 100644 index 0000000..ee315ff Binary files /dev/null and b/assets/textures/UI/buttons/Helps2.png differ diff --git a/assets/textures/UI/buttons/Helps3.png b/assets/textures/UI/buttons/Helps3.png new file mode 100644 index 0000000..c74165d Binary files /dev/null and b/assets/textures/UI/buttons/Helps3.png differ diff --git a/assets/textures/UI/buttons/Load1.png b/assets/textures/UI/buttons/Load1.png new file mode 100644 index 0000000..66b6867 Binary files /dev/null and b/assets/textures/UI/buttons/Load1.png differ diff --git a/assets/textures/UI/buttons/Load2.png b/assets/textures/UI/buttons/Load2.png new file mode 100644 index 0000000..dd2e3ca Binary files /dev/null and b/assets/textures/UI/buttons/Load2.png differ diff --git a/assets/textures/UI/buttons/Load3.png b/assets/textures/UI/buttons/Load3.png new file mode 100644 index 0000000..57283a9 Binary files /dev/null and b/assets/textures/UI/buttons/Load3.png differ diff --git a/assets/textures/UI/buttons/Quit1.png b/assets/textures/UI/buttons/Quit1.png new file mode 100644 index 0000000..49b1e6c Binary files /dev/null and b/assets/textures/UI/buttons/Quit1.png differ diff --git a/assets/textures/UI/buttons/Quit2.png b/assets/textures/UI/buttons/Quit2.png new file mode 100644 index 0000000..5f8a291 Binary files /dev/null and b/assets/textures/UI/buttons/Quit2.png differ diff --git a/assets/textures/UI/buttons/Quit3.png b/assets/textures/UI/buttons/Quit3.png new file mode 100644 index 0000000..e7b8007 Binary files /dev/null and b/assets/textures/UI/buttons/Quit3.png differ diff --git a/assets/textures/UI/buttons/Restart1.png b/assets/textures/UI/buttons/Restart1.png new file mode 100644 index 0000000..b767634 Binary files /dev/null and b/assets/textures/UI/buttons/Restart1.png differ diff --git a/assets/textures/UI/buttons/Restart2.png b/assets/textures/UI/buttons/Restart2.png new file mode 100644 index 0000000..522405a Binary files /dev/null and b/assets/textures/UI/buttons/Restart2.png differ diff --git a/assets/textures/UI/buttons/Restart3.png b/assets/textures/UI/buttons/Restart3.png new file mode 100644 index 0000000..49154b4 Binary files /dev/null and b/assets/textures/UI/buttons/Restart3.png differ diff --git a/assets/textures/UI/buttons/Resume1.png b/assets/textures/UI/buttons/Resume1.png new file mode 100644 index 0000000..f6300e1 Binary files /dev/null and b/assets/textures/UI/buttons/Resume1.png differ diff --git a/assets/textures/UI/buttons/Resume2.png b/assets/textures/UI/buttons/Resume2.png new file mode 100644 index 0000000..0d0278e Binary files /dev/null and b/assets/textures/UI/buttons/Resume2.png differ diff --git a/assets/textures/UI/buttons/Resume3.png b/assets/textures/UI/buttons/Resume3.png new file mode 100644 index 0000000..d5cda4c Binary files /dev/null and b/assets/textures/UI/buttons/Resume3.png differ diff --git a/assets/textures/UI/buttons/Save1.png b/assets/textures/UI/buttons/Save1.png new file mode 100644 index 0000000..59ec74e Binary files /dev/null and b/assets/textures/UI/buttons/Save1.png differ diff --git a/assets/textures/UI/buttons/Save2.png b/assets/textures/UI/buttons/Save2.png new file mode 100644 index 0000000..e1af8d7 Binary files /dev/null and b/assets/textures/UI/buttons/Save2.png differ diff --git a/assets/textures/UI/buttons/Save3.png b/assets/textures/UI/buttons/Save3.png new file mode 100644 index 0000000..4a52883 Binary files /dev/null and b/assets/textures/UI/buttons/Save3.png differ diff --git a/assets/textures/UI/buttons/Start1.png b/assets/textures/UI/buttons/Start1.png new file mode 100644 index 0000000..3e239e6 Binary files /dev/null and b/assets/textures/UI/buttons/Start1.png differ diff --git a/assets/textures/UI/buttons/Start2.png b/assets/textures/UI/buttons/Start2.png new file mode 100644 index 0000000..8804fad Binary files /dev/null and b/assets/textures/UI/buttons/Start2.png differ diff --git a/assets/textures/UI/buttons/Start3.png b/assets/textures/UI/buttons/Start3.png new file mode 100644 index 0000000..9c38d19 Binary files /dev/null and b/assets/textures/UI/buttons/Start3.png differ diff --git a/assets/textures/UI/credits-text.png b/assets/textures/UI/credits-text.png new file mode 100644 index 0000000..d0e7a7a Binary files /dev/null and b/assets/textures/UI/credits-text.png differ diff --git a/assets/textures/UI/instructions.png b/assets/textures/UI/instructions.png new file mode 100644 index 0000000..8a3e8e1 Binary files /dev/null and b/assets/textures/UI/instructions.png differ diff --git a/assets/textures/UI/press-enter-text.png b/assets/textures/UI/press-enter-text.png new file mode 100644 index 0000000..7fb86b8 Binary files /dev/null and b/assets/textures/UI/press-enter-text.png differ diff --git a/assets/textures/UI/title-screen.png b/assets/textures/UI/title-screen.png new file mode 100644 index 0000000..1408d5e Binary files /dev/null and b/assets/textures/UI/title-screen.png differ