Skip to content

JuJuz1/HandmadeHero

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

195 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HandmadeHero

My implementation of the code as I followed Casey Muratori's Handmade Hero playlist

Episode 62 showcase:

Episode 62

Most of the work has been going to the entity and world chunk system. Moving entities between low and high priority sets for sparse world storage

Some gameplay elements:

  • Simple sword attack (rock bitmap as a placeholder)
  • Familiar entity following the hero
  • Monster with hitpoints and collision (no damage yet)

General architecture

Unity build, game as a service to the platform

Header files include every dependency and declare all functions and operators. The game build includes every .cpp file it needs (unity build). The order of .cpp file include doesn't matter if we keep the header files self-sustainable (as in including every dependency they need)!

...

Code style remarks

Global variables which are meant to be modified are prefixed with a "g"

_ is used to postfix a variable, a function or a macro meant to be accessed or called with extra caution (somewhat meaning they are "private" in the object-oriented sense). This is to inform the caller that these are usually internal to the data structure, implementation etc... Prefixing with _ is problematic as these are reserved for standard library definitions and such!

...

Hot reloading

Build the game after modifying the code to load the DLL automatically and see the changes instantly

Supported automatically when modifying game code only! All other files except platform code (prefixed e.g. win32 AND handmade_platform.h). Basically any other files not linked to the actual executable

Extra features

  • Custom amount of replay buffers and can switch between them. Press 1, 2, 3 or 4 while not recording to switch between a buffer to playback input from that buffer. If there was no input recorded yet the buffer is now selected for recording to. Press shift + number to start recording in the numbered buffer overwriting possible previous recording. Press L to start recording in the selected buffer also overwriting. Shift + L to enable/disable replay looping.

  • Idea: a button (shift + P?) to advance game by 1 frame at a time when paused

  • Input checking with a simple API:

    • is action just pressed (for the first frame the key was pressed)
    • is action pressed (continuous, also for the first frame)
    • is action just released (last frame the key was held)

Building

Windows

Visual Studio 2022+ (or build tools). Also earlier versions might work. Have to test GCC and Clang

  • Clone the repository if you already haven't
  • Open x64 Native Tools Command Prompt for VS <some version> (or similar named)
  • Navigate to the project root
  • run scripts/win32_build.bat FROM THE ROOT
.\scripts\win32_build.bat

which puts the executable into the created build folder

Run it:

.\build\win32_handmade.exe

If using other shells: modify the scripts/setup_env.bat script to have vcvarsall.bat path to your Visual Studio installation before running scripts/win32_build.bat. This varies between Visual Studio installations

  • run scripts/setup_env.bat to initialize x64 environment for MSVC and then build according to the instructions above

Linux

Using David Gow's Handmade Penguin SDL 2 port of the platform layer. A repository which I used as a reference SDL Handmade

Heavily modified to match the code structure and style of the project. As the logic is very similar to the Windows platform layer I didn't bother to keep the same comments on the source files


Requirements

LLVM compiler (clang++) supporting C++20 (almost any version not older than ~3 years, so 16.0+)

SDL 2, installing this should be as simple as running

sudo apt install libsdl2-dev

In other cases more information can be found here: https://wiki.libsdl.org/SDL2/Installation

  • Clone the repository if you already haven't
  • Navigate to the project root
  • run scripts/linux_build.sh FROM THE ROOT
./scripts/linux_build.sh

which puts the executable into the created build folder

Run it:

./build/linux_handmade

Mac

Uses the same platform file as Linux (sdl_handmade.h and sdl_handmade.cpp)

Clang++ see above for Linux requirements. This is easy to install by just doing clang++ in the terminal which prompts the installation of dev tools

clang++

SDL 2, the easiest way is to install brew and do

brew install sdl2
  • Clone the repository if you already haven't
  • Navigate to the project root
  • run scripts/macos_build.sh FROM THE ROOT
./scripts/macos_build.sh

which puts the executable into the created build folder

Run it:

./build/macos_handmade

Using the original art assets

By default the build scripts use placeholder assets I have created. If you wish to use the original art assets obtained by preordering the game, create a folder inside data called "original". Then add test and test2 folders from the downloaded art zip to data/original. The build scripts should automatically detect the existence of data/original and configure HANDMADE_USE_REAL_ASSETS to 1

About

My implementation of the code as I followed the Handmade Hero playlist

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors