Skip to content

MuffinMufido/BasicGameEngine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text Engine

Work in Progress - This project is actively being developed.

A 2D tile-based text adventure game engine built with C++ and SDL2. Create interactive games with grid-based movement, dialogue systems, and scene management.

Course

This project follows EECS 498: Game Engine Architecture from the University of Michigan.

The course teaches how to build a game engine from scratch, progressing from a hard-coded C++ text adventure to a flexible 2D engine with Lua scripting, Box2D physics, and SDL graphics.

Features

  • Actor System - Game objects with customizable properties (sprites, dialogues, movement)
  • Scene Management - Multiple levels with easy transitions
  • Dialogue System - Proximity-based and contact-based dialogue triggers
  • Template System - Reusable actor definitions to reduce repetition
  • Health & Scoring - Built-in player stats with HUD display
  • Intro Sequences - Customizable intro screens with images, text, and music
  • Win/Lose States - Configurable game over screens

Requirements

  • C++20 compiler
  • CMake 3.10+
  • SDL2, SDL2_image, SDL2_ttf, SDL2_mixer (vendored)

Building

cmake -B build
cmake --build build

Running

./build/hw4

The resources/ directory must be in the working directory.

Project Structure

text_engine/
├── src/                    # Source files
├── include/                # Header files
├── resources/
│   ├── game.config         # Game settings
│   ├── rendering.config    # Display settings
│   ├── scenes/             # Level files (.scene)
│   ├── actor_templates/    # Reusable actor definitions (.template)
│   ├── images/             # Sprites and assets
│   └── fonts/              # TrueType fonts
└── vendored/               # Third-party libraries

Configuration

game.config

{
  "initial_scene": "level1",
  "intro_images": ["intro1", "intro2"],
  "intro_text": ["Welcome!", "Press any key..."],
  "font": "default.ttf",
  "intro_bgm": "music.ogg",
  "game_over_bad_image": "lose.png",
  "game_over_good_image": "win.png",
  "hp_image": "heart.png"
}

rendering.config

{
  "x_resolution": 800,
  "y_resolution": 800,
  "camera_offset_x": 0,
  "camera_offset_y": 0
}

Creating Content

Scenes

Scene files (.scene) define levels with actors:

{
  "actors": [
    {
      "actor_name": "player",
      "x": 5,
      "y": 5,
      "view_image": "player.png"
    },
    {
      "template": "wall",
      "x": 0,
      "y": 0
    }
  ]
}

Actor Templates

Templates (.template) define reusable actor properties:

{
  "view_image": "wall.png",
  "blocking": true
}

Reference templates in scenes with the template field. Scene properties override template defaults.

Actor Properties

Property Description
actor_name Identifier (use "player" for the player)
x, y Grid position
vel_x, vel_y Velocity per frame
view_image Sprite filename
blocking Blocks movement if true
nearby_dialogue Text shown when player is adjacent
contact_dialogue Text shown when player touches actor
transform_scale_x, transform_scale_y Sprite scaling
transform_rotation_degrees Sprite rotation

Dialogue Commands

Special tags in dialogue text trigger game events:

Tag Effect
[health down] Decrease player health
[score up] Increase player score
[proceed to <scene>] Load another scene
you win Trigger win condition

Controls

  • WASD - Move player
  • Any key - Advance intro/dialogue

License

MIT

About

A game engine i am making following https://eecs498.com/.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published