Skip to content

Study repository for Casey Muratori's Handmade Hero series which is a game from scratch using only C++ and no libraries

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
license.txt
Notifications You must be signed in to change notification settings

bruno-sartori/handmade-hero

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intro

This is my personal study notes of the awesome project Handmade Hero.

If you think writing a professional-quality game from scratch on your own (no engine no library) is interesting and challenging, I highly recommend this project.

In my opinion, it's the best I can find.

Showcase

Day 85

  • We can jump 😉
  • We can shoot 🔫
  • We can go upstair and downstair 🏃‍♀️
  • We have a big world and many rooms 🗺
  • We have a basic procedure generated ground 🌿

Env

Windows 10 with Visual Studio 2019 community version and Sublime Text 3.

Build system for Sublime Text 3:

{
  "build_systems":
  [
    {
      "name": "HandmadeHero",
      "shell_cmd": "build",
      "file_regex":"^(.+?)\\((\\d+\\))(): (error)(.+)$"
    }
  ]
}

Setup

NOTE: This repo does not contain copyrighted HandmadeHero assets, to build this repo, please consider preorder HandmadeHero.

  • Create a w drive using subst: subst w: /c/whatever_directory_you_choose
  • Clone this repo into the root of w
  • Install Visual Studio 2019 community version
  • cd into w and init cl: .\handmade-hero\misc\shell.bat
  • Build and enjoy! build

Code Style

My preferred code style for C is different from Casey's.

  • snake_case for types, e.g. game_world
  • camelCase for variables, e.g. globalRunning
  • PascalCase for functions and macro functions, e.g. GameUpdateVideo
  • UPPER_SNAKE_CASE for macro constants, e.g. TILES_PER_CHUNK
  • Prefix an underscore to indicate that this function should only be called with a corresponding macro, e.g. _PushSize

Marks

  • NOTE: Something we need to pay attention to
  • PLAN: Something we plan to do it later
  • RESOURCE: External valuable resource
  • DIFF: Something I have done it differently from Casey
  • FUN: Something interesting to know, like Windows can't correctly handle file formats they invented
  • CASEY: Casey's opinion about programming

Game Programming

  • Every memory allocation should go through a macro, it will make the debugging much easier.
  • Premultiplied Alpha: check day 83 for more details.
  • Gamma Correction: check day 94 for more details.
  • Transform Normal: check day 102 for more details.

Windows Programming

Command Prompt

  • dir /s [keyword]: search files
  • findstr -s -n -i -l [keyword]: find strings

Win32 API

  • WS_EX_TOPMOST: make window in front of others
  • WS_EX_LAYERED and SetLayeredWindowAttributes : change window alpha

Visual Studio

  • Spy++: inspect windows and messages

Resources

Build and Debug

  • To build the application:
    cd handmade\code
    build.bat
  • To debug the application:
    devenv ..\..\build\win32_handmade.exe

This will open visual studio, once there remember to change "Executable" and "Working Directory" on exe properties. Example:

alt text

Then just hit f11 and start debugging!

Debugging Tools

  • Press P Key to Pause
  • Press L Key to start input loop and L key again to lock the loop
  • Press Alt + Enter Keys to go full screen

Troubleshoot

If when trying to build the application, you receive the error "The input line is too long. The syntax of the command is incorrect." make sure to put the project folder as close as possible to C: and if the error persists just restart your cmd.

Doubts / Learn

About

Study repository for Casey Muratori's Handmade Hero series which is a game from scratch using only C++ and no libraries

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
license.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published