使用Imgui和SDL2做的一个弹球小游戏-Bounze

发布于:2025-07-24 ⋅ 阅读:(28) ⋅ 点赞:(0)

使用Imgui和SDL2做的一个弹球小游戏-Bounze

油管上面TheCherno博主分享的一个视频FIRST GAME in C++! Did He Do a Good Job? // Code Review (C++/SDL2)里面分享了一个Github项目:
https://github.com/staticaron/Bounze
使用了Imgui和SDL2,并且可以设置音乐播放,修改音量等,玩家可以得分等,目前游戏支持Windows和Linux。

Bounze

游戏开始界面菜单

运行项目

How to Play.

  • The ball bounces off the bat randomly in normal mode.
  • If boost is active, the ball bounces off according to where it collides with the bat.
  • Balancing the ball on bat and destroying the diamonds using the boosted ball gives points.
  • Get the highscore.

  • I left the debug imgui in the game where you can modify the volumes etc. Press TAB to access.

How to build.

Windows + Visual Studio

  1. Open the folder in visual studio as Cmake Project.
  2. Ctrl + S on the CMakeLists.txt file to build the project.
  3. Run bounze.exe.

NOTE : Copy the /resources folder in same directory as the .exe file.

LINUX

  1. Create a folder /build
  2. Enter the folder cd build
  3. Run the cmake command cmake ..
  4. Make the build file make

NOTE : Copy the /resources folder in same directory as the .exe file.

参考上述https://github.com/staticaron/BounzeREADME.md文件,下载上述项目后,在Window11中使用VS2022打开下载的目录,以CMake工程打开;
接着打开CMakeLists.txt,执行Ctrl+S编译,生成Makefile等工程文件;最后将代码根目录下的resources资源文件夹拷贝到和bounze.exe同级目录,运行bounze.exe可执行程序
将资源文件夹和exe放置到同一目录下
然后鼠标双击bounze.exe可执行程序,
鼠标双击bounze.exe可执行程序
如果不拷贝resources资源文件夹,直接鼠标双击bounze.exe可执行程序,会报如下的错误:
不拷贝资源文件夹报错

ERROR loading the font at : ./resources/fonts/mightysouly.ttf Couldn't open ./resources/fonts/mightysouly.ttf

加载资源文件报错,因为找不到资源文件所在目录。


网站公告

今日签到

点亮在社区的每一天
去签到