I wanted to create a simple Mario game in a single file. Here's the work in progress of that! The idea is to attempt to improve on my organization / heirarchy skills.
Although the only application specific code is within one file (src/main.c), single file mario does rely on several external dependencies.
git clone --recursive https://github.com/SamEads/single_file_mario && cd single_file_mario # (recursive clone is necessary for the stb submodule)
mkdir build && cd build
cmake ..
cmake --build .Just run this command from a directory that has the assets folder present:
./single_file_marioAssuming you'll be rebuilding from the top of the repo, you just need to run this after making changes:
cmake --build build # (you can tack on -j <core_count> to the end to utilize multiple cores)The sprite .dat files that accompany .pngs are used to define the frames and order of sprite animations. A file can contain the following lines:
-
frames:<frame_num> - number of frames in the sprite animation
-
order:<n,n,n,n> - the order in which the frames should be displayed
example file:
frames:3
order:0,1,2,0
Frames are read in vertically. If the frame count is not supplied in a .dat file, a sprite will auto-splice the image, using the image width as the frame height. If no order is supplied, the animation order will be 0,1,2,3,etc for each frame in a sprite.
