This is a near exact Zig port of the original DungeonRush C-based
rogue-like game running on SDL2 originally developed by @rapiz1.
- Fully playable - confirmed working on MacOS, Linux Mint
- Nearly complete port, no networking or auxillary menus done
- No known bugs.
- Many memory leaks were tracked down and fixed using Zig's
GeneralPurposeAllocator
leak detection feature - Game speed is now appropriately throttled and consistent across platforms.
- Code is largely done, but now being incrementally improved, refactored and cleaned-up
- DungeonRush is a pretty fun game:
- Cellular automata to generate random dungeon levels
- Features weapons, buffs, enemies, bosses and loot drops
- Classic pixel art and animations
- 8-bit style music and many sound sfx
- Each round starts with a random hero in the middle of the dungeon
- Move the arrow keys:
up
,down
,left
,right
to control your character - Make your party stronger by collecting more heroes
- Collect weapon and loot drops to become more powerful and heal your party
- Don't run into walls, bad guys or yourself or you will π
- Your heroes will intelligently attack nearby enemies when they are near
- To advance to the next round, you must collect a certain amount of heroes
- Be careful of giant bosses, they can be very powerful
- To re-create a moderately complex game, fully in Zig and to get better at the language.
- To make this port faithful to the original, while being more idiomatic.
- To identify and fix any possible undefined behaviors or bugs that the Zig compiler catches or that myself or other contributors catch.
- To ensure the game is as fast and responsive as the original project.
- To fully eradicate all original C-based files and C-based build scripts.
- To port in phases:
- Phase 1: port the C code almost as-is to minimize bugs introduced
- β
Deprecate usage of
c.malloc
/c.free
in all cases - β
Deprecate use of
c.qsort
with acallconv(.C)
callback in favor of Zig's sorting - β Deprecate all [*c] style pointers
- β Deprecate C-style multi-pointers
- Find and improve
const
correctness where applicable
- β
Deprecate usage of
- Phase 2: Ziggify
- Move away from
c_int
or C specific types - β Favor slices over multi-pointers, remove any pointer arithmetic
- Use more of Zig's stdlib for logging, file-io, etc
- Utilize
defer
/errdefer
for effective cleanup - Migrate to a Zig-based SDL wrapper, for a nicer SDL experience
- Ensure all errors are accounted for, utilize
try
- Use
build.zig.zon
file for any dependencies - β Setup Github to build the project regularly
- Move away from
- Phase 3: Code Clean-up/Refactor
- β Gamepad controller support added
- Remove duplicate code
- Make code even more idiomatic for Zig
- Make the code more maintainable
- Use less globals
- Remove redundant naming like some enumerations have their container name as the prefix
- β
Use some Zig based collections like the
generic
LinkList over the original C ADT style - Get building for other OSes (w/ community contributions)
- Migrate hardcoded textures, music + sound sfx out of the source code and into config files
- This will allow the game to be easily skinned, for a whole new experience.
- Phase 4: ???
- I'd love to port this to Raylib.
- Bonus: Introduce unit-tests
- Phase 1: port the C code almost as-is to minimize bugs introduced
Cause it's a game-changing, bad-ass language that unlocks super-powers and was a fun learning experience.
zrc/
- Ziglang port (by @deckarep)src/
- C-based version (original by @rapiz1)
- Built and tested against Zig 0.13.0 release
- Ensure SDL2 is installed for your OS/Platform
- From the root folder:
zig build run
Want to hack on this project with me? I will welcome all contributions that improve the code while keeping it faithful to the original DungeonRush project. I'd like the game to look and run identical. I'd like help with the phases outlined above. There's plenty of low-hanging fruit that is relevant to beginners and experienced a-like.
However, code will be rejected that needlessly complicates the game or does not run identical to the original C project.
If people want to change the overall look and feel or game logic, please fork DungeonRush and change it however you like! It is open-source after all!
- Zig doesn't have
do/while
so they've all been replaced withwhile
with a break on anegated
condition. - Before anyone complains about the port looking like ugly Zig code written like C, this is why I'm taking a multi-phase approach. If you've ever done migrations, changing too many things at once introduces bugs, especially when tests don't exist.
- All original development was done on Apple MacOS Silcon, contributions are welcome for other OSes.
- The game has some multi-player networking code, I don't care about it at the moment so it's not started.
- It's very possible this manual port has introduced a bug or two, the game needs to be well tested.
- Introduce heroes that have innate abilities like a Frost Hero that is immune to cold attacks
and is able to dish out there own cold attacks. Or a Fire Hero that can't be frozen. Yeah,
dumb shit like that.
- This would make the game a little more interesting because you can pick up cerrtain heroes as part of the strategy to help you cope with the certain level.
- Introduce themed levels, like a frost level where most or all baddies are cold-based.
- Introduce upgrades along the way, loot upgrade your heroes.
- β Gamepad support, it might be fun to not always use the damn keyboard.
- Weather effects, snow, rain, wind, fog-of-war, etc.
- Show temporary animated scores when certain events occur like picking up loot