Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

hammerill/Sand-Box2D

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ATTENTION: This is legacy code to be rewritten. Please refer to the new repo.

Logo

An open source cross-platform game based on Box2D with SDL2

Sand-Box2D is a game where you can try out possibilities of the Box2D physics engine, can make your own levels and share them with others.

This project was developed mainly for educational purposes. I've started developing it for myself just to understand basis of Box2D, how to link it with SDL2 and etc. But then, I've realized it could be more than just some rewritten code: a game. So, I took this project as the base, have rewritten it from zero using OOP, and now you're free to play this game and use its code at way as you want.

Gameplay Video

Get it for your platform

Contents


Controls

For Desktops

  • WASD and Space/R/Enter - actions.
  • Arrows - move camera.
  • Q/E - adjust zoom.
  • Tab - on/off debug screen.
  • F - go/exit fullscreen (gonna be moved to options menu soon).
  • Also, you can consider using mouse for camera controls and to go/exit fullscreen mode.

For PS Vita

  • DPAD and Cross - actions.
  • Left Stick - move camera.
  • Right Stick or L/R - adjust zoom.
  • Triangle - on/off debug screen.
  • Also, you can consider using touchscreen for camera controls.

Future plans

  • Add support for loading custom levels ✅ Done!
  • (Make a main menu ✅ Done!, but) where player can:
    • Download, manage and (start ✅ Done!) levels;
    • Adjust settings;
    • Access menu "About".
  • Implement level editor (right now to make levels you need to manually edit JSON).
  • Add support of a lot of objects (joints included).

Feel free to propose ideas here!

List of little tasks

  1. Remove hardcoded Font loading code ✅ Done!
  2. Adapt camera while on/offing the fullscreen mode ✅ Done!
  3. Realize attached camera mode and consider camera:move and camera:zoom options ✅ Done!
  4. When WorldManager just initialized, show some effect, like lighten everything from the darkness and show level's title. Based on how other games show level starting animation, Sonic for example ✅ Done!
  5. Realize simple MainMenu for beginning, buttons list like "PLAY", "ABOUT", "EXIT". When PLAY clicked everything dims and after that (when everything became black) tell GameManager somehow that MainMenu is no longer used and it needs to init WorldManager which will load desired level (and it will load animation from step 4) ✅ Done!
  6. Hide mouse when user doesn't use it ✅ Done!
  7. In game (when no fade anims are running) you can call PauseMenu. When you do that, physics stop and you can access these buttons: "RESUME" (close PauseMenu and return to game), "SETTINGS" (open OptionsMenu and keep game state), "RESTART" (start fadeout effect, during which we can see physics temporary resume. At the end reload level) and "EXIT" (start fadeout effect same as "RESTART" and at the end return us to MainMenu). START button with which we opened PauseMenu should also close it. Blur background when entering PauseMenu.
  8. MainMenu for release state at future:
  • At first launch it asks to choose interface language (CHOOSE YOUR LANGUAGE (...) YOU CAN CHANGE IT LATER IN THE SETTINGS). When cycling through languages, interface language will automatically change to the hovered one ✅ Done!
  • If platform is PS Vita, when game just inited video it should fade out of the pics/sce_sys/pic0.png, because it's a picture that shown when game is loading on Vita ✅ Done!
  • In main menu at the top is Sand-Box2D logo shown. If player clicks at the box (either with mouse or touchscreen), it will fall off and collide with menu item selector, by moving it up-down player can throw the box, and all that happens while remaining Sand-Box2D text fades out. When player manages to lose the box, logo returns to its place ✅ Done!
  • Main menu consists of these items:
    • PLAY - will load list of default levels that always shipped with game.
    • COMMUNITY - will load list of community published levels.
    • LEVEL EDITOR - will load menu that shows: "Look, they're working on it! They're working hard! You think they do not work fast enough? Join them then! More info in 'ABOUT'!" and picture of some facility construction with the name of "SAND-BOX2D LEVEL EDITOR", where we also can see builders, which are in fact contributors with their names above them, and we can guess what type of work they do by looking at picture.
    • SETTINGS - will fade out MainMenu and load OptionsMenu.
    • ABOUT - will load About menu, where player can see list of contributors, credits, and QR code with link to this repo, in order if they will want to contribute.
    • EXIT - yes.
  • what's My name? My name is Corner. Upper-Right Corner.
  1. Realize "Journeys" or "Worlds" system, i.e. pack of levels. Player can "beat" any level, and some levels can be unlocked only after beating certain previous levels. When "PLAY" is clicked game will load default Journey or World, while at "COMMUNITY" people can upload their levels separately AND Journeys/Worlds.

Build

If you don't want to build by yourself, you can consider auto build system provided by GitHub actions.

On Windows

  1. Install Git and build tools:
winget install git.git kitware.cmake

Get MSYS2 without opening it. Open MSYS2 MSYS and type:

pacman -S --needed base-devel mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-toolchain

cd /ucrt64/bin/
ln -s mingw32-make.exe make.exe

exit

Add C:\msys64\ucrt64\bin to PATH environment variable.

  1. Install packages:
  • You need to install all those packages and unpack them in the same directory:
  • Or simply just unpack contents of this archive somewhere.
  • Also, you have to add "bin" directory (located where the packages are installed) to your PATH variable, or copy its contents (*.dll) to the same directory where .exe file should be (build).
  1. Clone repo:
git clone https://github.com/Hammerill/Sand-Box2D; cd Sand-Box2D
  1. Build (at the 4th line at the end change path to where you have installed packages or extracted an archive):
mkdir build
cd build
cmake .. -G "MinGW Makefiles"
cmake .. -DBUILD_WINDOWS_PKGS=C:/path/to/pkgs
make
  1. EXE file should appear, you can now launch this game:
Sand-Box2D.exe

If you experience errors with Jsoncpp library while building try to disable HEADER_WITH_JSONCPP flag via this:

cmake .. -DHEADER_WITH_JSONCPP=OFF
make

If you want to build with experimental Python 2.7 support run it:

cmake .. -DPYTHON_TEST=ON
make

On Linux

  1. Install following libraries somehow with your package manager (possible string sdl2 sdl2_image sdl2_mixer sdl2_ttf sdl2_gfx box2d jsoncpp curl python2.7):
  • SDL2;
  • SDL2_image;
  • SDL2_mixer;
  • SDL2_ttf;
  • SDL2_gfx;
  • Box2D;
  • jsoncpp;
  • cURL;
  • And Python 2.7 if you want to run early tests.
  1. Clone repo:
git clone https://github.com/Hammerill/Sand-Box2D && cd Sand-Box2D
  1. Build:
mkdir build
cd build
cmake .. -DBUILD_WINDOWS=OFF -DBUILD_LINUX=ON
make -j4
  1. Executable should appear, you can now launch this game:
./Sand-Box2D

If you experience errors with Jsoncpp library while building try to disable HEADER_WITH_JSONCPP flag via this:

cmake .. -DHEADER_WITH_JSONCPP=OFF
make -j4

If you want to build with experimental Python 2.7 support run it:

cmake .. -DPYTHON_TEST=ON
make -j4

For PS Vita

Build for PS Vita should be performed in Linux environment (or in MSYS2 in Windows, see step 1).

  1. Install VITASDK.
  2. Clone repo:
git clone https://github.com/Hammerill/Sand-Box2D && cd Sand-Box2D
  1. Build:
mkdir build
cd build
cmake .. -DBUILD_WINDOWS=OFF -DBUILD_VITA=ON
make -j4
  1. VPK file should appear. Copy this file to your hacked PS Vita and install via VitaShell.
  2. Bubble "Sand-Box2D" will appear, you can now launch this game.

Credits

  • eder13 - base project (Box2D-SDL2-Demo) author.
  • CodeMan38 - main font (PressStart2P) author.
  • Ultra Cool Fonts - Japanese font (Madou Futo Maru Gothic) author.
  • Hammerill - author of this game.
  • To everybody who contributes to open source, to those who made these (used in the project) libraries exist.

Translations:

  • English, Russian and Ukrainian - Hammerill.
  • French and Japanese - Hammerill with aid of Google Translate.