• Stars
    star
    302
  • Rank 138,030 (Top 3 %)
  • Language
    Rust
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The source code that accompanies Hands-on Rust: Effective Learning through 2D Game Development and Play by Herbert Wolverson

Hands-on Rust Source Code

This repository contains the source code for the examples found in Hands-on Rust. These are also available from my publisher, PragProg and are shared with their permission.

The examples included are:

Installing Rust

This code covers the Rust and Your Development Environment chapter. It is designed to help you get a working Rust toolchain together, and understand the tools Rust provides.

  • Hello World---the obligatory first Rust program we all encounter.
  • Clippy---an example showing Clippy in action, finding a common issue.
  • Clippy Fixed---the Clippy example, now working without suggestions.

First Steps with Rust

This code covers the First Steps with Rust chapter. It is designed to teach language basics.

Build Your First Game with Rust

This code covers the Build Your First Game with Rust chapter. It takes the knowledge from the previous two chapters and helps you make your first game, Flappy Dragon.

  • Hello, Bracket Terminal---import that bracket-lib crate, learn about dependencies and writing to the screen.
  • Flappy States---learn to manage the overall structure of the game with states.
  • Flappy Player---add a player to the game, flapping on command.
  • Flappy Dragon---your first playable game, an ASCII mode Flappy Dragon game.
  • Flappy Bonus---Bonus content, showing Flappy Dragon with graphics and smooth movement.

Flappy Bonus has an accompanying bonus online tutorial.

Build a Dungeon Crawler

This code covers the Build a Dungeon Crawler chapter. It starts a new game that will form the basis of the remainder of the book.

  • Dungeon Map---helps you organize your code into modules, build a blank map, and understand tile map storage.
  • Dungeon Player---adds a player who can walk around the map, introducing game-loop based input handling, state management and interactions between structures.
  • Dungeon Rooms---introduces using algorithms to build a basic dungeon map, and the concept of a map builder API.
  • Dungeon Graphics---adds tile-based rendering to the game, giving you a dungeon you can walk around.

Compose Dungeon Denizens

This code covers the Compose Dungeon Denizens chapter. It introduces the Entity-Component System architecture and focuses on composing dungeon elements from reusable parts.

  • Player ECS---converts the simple player handler to use entities, components and systems. Introduces multi-file modules and using procedural macros. Demonstrates fearless concurrency, and how easy Rust can make it to benefit from concurrency.
  • ECS Monsters---walks you through using the same systems to support monsters in your game. Adds initial collision detection, allowing you to kill monsters by walking into them.

Take Turns with the Monsters

This code covers the Take Turns with the Monsters chapter. It expands upon game states by transitioning between states and implementing a turn-based game structure.

  • Wandering Monsters---Introduces code to make the monsters wander randomly through the dungeon.
  • Turn Based---applies state management to make the game turn based. You move, then the monsters move.
  • Messages of Intent---introduces using the ECS to store messages of intent, allowing you to separate functionality between systems and use the underlying storage system as a messaging system. Makes monsters and the player use the same system to apply movement, but with different movement inputs.

Health and Melee Combat

This code covers the Health and Melee Combat chapter. It adds health to both the player and monsters, and implements a simple combat system. It also adds a heads-up display to show the current game status. It emphasizes code re-use.

  • Health---adds hit points to the game and adds health display. It also introduces the concept of rendering layers, tooltips and naming entities.
  • Combat---allows you to damage monsters by bumping into them, and lets them damage the player.
  • Healing---introduces health restoration, initially by waiting.

Victory and Defeat

This code covers the Victory and Defeat chapter. It adds winning and losing conditions to the game.

  • The Gauntlet---all about trait implementation, and using traits to make Dijkstra Maps work. Monsters path towards the player.
  • Losing---detect when the player is dead, and use a game state to display a "you lost" message. Offer to play again, resetting the game state.
  • Winning---adds an amulet to the map. When the player reaches the amulet, the game state changes to a "you won" screen.

Fields of View

This code covers the Fields of View chapter. It implements traits to provide functionality from bracket-lib---specifically fields of view. It then limits monsters to chasing what they can see, and adds spatial memory.

  • Field of View---introduces the concept of vision, and implements it via traits. Limits the player to displaying only what they can currently see.
  • Monstrous Eyesight---adds fields of view to monsters, reusing the same code. Monsters now only chase the player when they can see it.
  • Memory---keep track of where you've been with a dungeon map memory system. Show areas you've previously visited, but not areas you've yet to discover.

More Interesting Dungeons

This code covers the More Interesting Dungeons chapter. It teaches the reader to create new traits, and use them interchangeably via a trait interface. It covers various popular procedural generation techniques, providing tips and tricks along the way.

  • Traits---convert map generation into a trait-based API and dynamically select algorithms at run-time.
  • Traits: Rooms---convert your existing room generator to a trait-based map builder.
  • Cellular Automata---implement your first real map provider, and learn to use Cellular Automata to make an interesting map.
  • Drunkard's Walk---implement a second map generation technique, and learn about bounded iteration.
  • Prefabs---learn to hand design your own level content, and apply it.
  • Test Harness---a convenient structure for testing map builders without having to play the game over and over. Demonstrates the utility of making traits generic and then building separate harnesses in which to test them.

Map Themes

This code covers the Map Themes chapter. It extends upon reusable traits by creating a generic rendering system that can visually theme any level to the tileset of your choice.

  • Themed Maps---separates the dungeon graphics into one theme, and adds a forest map theme.

Inventory and Power-Ups

This code covers the Inventory and Power-Ups chapter. It teaches you to build items with composition, manage their storage and implement item interactions.

  • Potions and Scrolls---Learn to implement items, reusing a lot of existing code. Adds health potions and a magic mapping item to the game.
  • Carrying Items---learn to use components to represent an item in inventory, and iterate it to display the player's inventory. Use carried items when you want to.

Deeper Dungeons

This code covers the Deeper Dungeons chapter. It extends your data storage system to provide for multi-level dungeons, with the end-game item only appearing on the final level.

  • More Levels---is about making more dungeon levels, showing you how your game structure is reusable and can readily be extended into a deeper game.

Combat Systems and Loot

This code covers the Combat Systems and Loot chapter. Learn to design your entities as data---in TOML files. Learn to de-serialize the files, and use them as templates to spawn items and monsters.

  • Loot Tables---introduces serialization with Serde, and the power it provides for quickly extending your game. Migrate your monsters to simple data files, allowing for quick iteration of new baddies.
  • Better Combat---further extends the data-driven aspects of the game by letting you design weapons and change monster difficulty. Change how monsters spawn, providing for a difficulty curve.

More Repositories

1

rltk

Roguelike Toolkit - Modern C++ (14) SFML-based toolkit for creating roguelikes.
C++
297
star
2

bgame

Nox Futura - sort of like Dwarf Fortress in space.
C++
183
star
3

noxfutura

Nox Futura is a Rust port of the C++ project of the same name. It's a Dwarf Fortress like, in 3D (and a futuristic setting). It's also a passion project, so I'm not expecting formalized release dates!
Rust
122
star
4

rustyroguelike

Following along with the /r/roguelikedev tutorial session, in Rust and implementing my own library as well!
Rust
116
star
5

roguelike-celebration-2020

Code for my Procedural Map Generation talk at the Roguelike Celebration 2020
Rust
61
star
6

secbot-2021-7drl

7-day Roguelike, 2021 (Success)
Rust
23
star
7

bevy-test

A quick and dirty Space Invaders type game in Bevy, with attached tutorial.
Rust
20
star
8

dankestdungeon

A 7DRL Project, using Emscripten to create a simple roguelike system in C++ that runs in the browser.
C++
19
star
9

png2rex

A quick utility for turning PNG files into REXPaint xp files.
C++
15
star
10

rust_brain_teasers

Source code to accompany the Rust Brain Teasers book.
Rust
15
star
11

bqos-oss

Bracket QOS - a Quality of Service/Experience server system writtin in Rust. Derived from the excellent LibreQOS Project.
Rust
14
star
12

ArdanUltimateRustFoundations

Course Material for Ardan Labs - Ultimate Rust: Foundations
Rust
14
star
13

Ardan-1HourAsync

Code accompanying the 1 Hour Dive into Async live stream.
Rust
13
star
14

png2rex_rs

Utility for converting PNG files to REX Paint .xp files.
Rust
9
star
15

rf-signals

RF planning system for WISPs, and a port of various RF algorithms to pure Rust.
JavaScript
9
star
16

cpumap-pping

A work-in progress experimenting with merging xdp-pping and xdp-cpumap-tc into one BPF program, with a view to helping LibreQoS and BracketQOS obtain this information in a scalable manner.
C
6
star
17

pyrite_box

Fun project making something that looks a bit like the old SSI Gold Box games.
Rust
6
star
18

libre_qos_rs

Some helpers for LibreQOS, written in Rust.
Rust
4
star
19

TechSupportRL

A quick roguelike for fun, as a break from writing Black Future. Should work as an RLTK example.
C++
4
star
20

bracket-ui

A user-interface library for bracket-lib.
Rust
3
star
21

rltk2

The Roguelike Toolkit, Version 2 - Very Much in development, I don't recomend trying to use it yet!
C++
3
star
22

rusty-jam-2

Entry for Rusty Jam 2 ( https://itch.io/jam/rusty-jam-2 )
Rust
3
star
23

gravity_well

A simple two-player (shared keyboard) game in which you collect salvage and try not to fall into a black hole.
Rust
3
star
24

Ardan-NR-2023-07

Rust
2
star
25

noxunreal

Unreal Engine version of Nox Futura. Relies on libnox.
Lua
2
star
26

ArdanRustDebugOptimize

In-Development repo for Rust Debugging & Optimization
Rust
2
star
27

Ardan_2023_07_24_Live

Live code repo for Ardan 2023/07/24 training
Rust
1
star
28

llm_rust_article_1

Rust
1
star
29

Ardan_2023_05_18_Live

Live coded repo for 2023-05-18 Rust 1
Rust
1
star
30

UltimateRust1-EcoSystem

Code to accompany Ardan Labs - Ultimate Rust 1, Condensed class.
Rust
1
star
31

ArdanLabs_RustInYourEnterprise

Code that accompanies the Introducing Rust into your Company Ecosystem talk
Rust
1
star