Skip to content
generated from jude253/CGameSandbox

This is an sand game where you drop sand as you please. I built it from scratch in C++ that's really mostly C except for some standard library data structures from C++, and it can have 250,000+ grains of sand on screen without dropping frames. You can play the game at the website.

License

Notifications You must be signed in to change notification settings

jude253/SandGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This project is a sandbox for me to learn CMake, SDL and C/C++ better. Also, it will serve as a "minimal working example" of a game that can run as WASM or an executable (at least on a mac/linux/unix based OS, until I can actually understand how to use CMake right). I will then use this as a template so I can work on multiple similar projects without having to recreate this setup each time. It uses Adobe Open Source fonts as a submodule to improve portabililty so fonts can be loaded in with a relative path.

NOTE: Running this initial game on mobile does not run smoothly. There is a long delay between when the screen is pressed and when the "click" is able to be processed by the game. I am thinking it's probably best mainly aim to make games that work well on desktop b/c of this.

Demo

There is a playable WASM demo of this game here:

https://wasm.jander.io/SandGame/game.html

Dependencies:

Helpful Resources

Initial Project Setup

# Clone repo and submodules:
git clone --recurse-submodules [email protected]:jude253/SandGame.git

To intially setup up Emscripten:

cd include/emsdk

./emsdk install latest

./emsdk activate latest

Next, build the project for WASM one time using the instructions below.

Build Commands

Make a build (doesn't have to be named build/) directory, run cmake with relative path to project root from there, then run make. Somewhat like the unix style build, but with no configure step yet.

mkdir build

cd build

cmake ..

make

Alternatively, use this command instead of make:

cmake --build .

Build with Emscripten for WASM

Use the same commands as above, but replace cmake .. with this:

cmake -DUSE_EMSCRIPTEN=ON ..

NOTE: If you are running make for the first time since installing the emsdk, make sure the shell you run make in has not run source ./emsdk_env.sh as this makes the caching of emscripten port libraries fail. Run source ./emsdk_env.sh after running make the first time.

NOTE: If you switch back to normal building, use this command for the first time to disable the cached key:

cmake -DUSE_EMSCRIPTEN=OFF ..

Start Game WASM

Run once to enable emscripten commands in shell session:

source ./include/emsdk/emsdk_env.sh

From /build run:

emrun dist/game.html

Docs: https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html#running-html-files-with-emrun

Start Game

./build/dist/game

One Line Command

Run from build directory

cmake .. && make && ./dist/game

About

This is an sand game where you drop sand as you please. I built it from scratch in C++ that's really mostly C except for some standard library data structures from C++, and it can have 250,000+ grains of sand on screen without dropping frames. You can play the game at the website.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages