Skip to content

kuhree/gg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# GG (Go Game Engine)

GG is a bunch of classic games written in Go. It's designed to create classic arcade-style games using ASCII characters for rendering.

> [!warning] I built this on the side to try and get more familiar with Go. I wouldn't rely on this, but it was a fun project.
> I'd estimate ~40% of the code was AI generated (if you can't tell). No tests, no docs, but I may revisit in the future.

## Features

- Fixed timestep for core gameplay logic, physics, and collision detection
- Support for multiple game states (Main Menu, Gameplay, Pause, Game Over)
- Customizable game elements (levels, player, camera, AI enemies, NPCs, obstacles, weapons, power-ups)
- Dev mode with extra features like:
  - Performance metrics (FPS)
  - Debug information overlay
  - Entity bounding box visualization
  - Collision detection visualization
  - Slow motion and frame-by-frame stepping

## Implemented Games

The `examples/` directory contains implementations of classic 2D games, including:

1. Frames - not a game but useful for testing "FPS"
2. Space Invaders
3. Conway's Game of life
4. Breakout*
5. Flappy Bird

> \*Not yet implemented

## Project Goals

- Implement multiple classic arcade games
- Create a full game experience (gameplay loop, start screen, pause functionality, settings, high score/leaderboards etc.)

## Getting Started

1. Clone the repo `git clone git.littlevibe.net/kuhree/gg`
2. Run the app `go run cmd/gg/main.go`

## Usage

The game launcher can be used in the following ways:

- `gg`: Launch a menu to choose games
- `gg [game]`: Launch directly into a specific game
- `--debug`: Enable Debug logging
- `--overlay`: Enable Debug overlay
- `--time`: Target time in FPS
- `--fps`: Target fps
- `--height,--width`: Target height/width of the render

While in game:

- Use arrow keys or WASD for movement
- Spacebar for primary action (shoot, jump, etc.)
- 'P' to pause the game
- 'ESC/Q' to pause/quit the current game 

Developer tools:

- '1' to toggle debug information overlay
- '2' to toggle performance metrics display
- 'F4' to toggle entity bounding box visualization
- 'F5' to toggle collision detection visualization
- '_' and '+' to increase/decrease level

For game-specific controls and instructions, refer to the in-game help menu or the individual game's documentation in the `examples/` directory.

## Architecture

The GG (Go Game Engine) project follows a modular architecture designed for maintainability, extensibility, and ease of use. Here's an overview of the project structure:

```
gg/
├── cmd/
│   └── gg/
│       └── main.go
├── internal/
│   ├── engine/
│   └── utils/
├── examples/
│   ├── spaceinvaders/
│   │   └── game.go
│   └── ...
├── go.mod
├── go.sum
└── README

```

### Key Components

1. **cmd/gg/**: Contains the main application entry point.

2. **internal/**: Houses the core engine components and game-specific code.

   - **engine/**: Core engine components.
     - **config/**: Config file management
     - **core/**: Central game loop, state management, etc.
     - **events/**: event handling and management
     - **leaderboard/**: leaderboards file management
		 - **objects/**: Common game objects that can be used across different games.
     - **render/**: Rendering system for ASCII graphics.
     - **scenes/**: Scene loading
   - **utils/**: Utility functions and helpers.

3. **examples/**: Individual game implementations using the engine.

### Adding a New Game

To add a new game:

1. Create a new directory under `examples/` with your game's name.
2. Implement your game logic in a `game.go` file within this directory.
3. Use the engine components from the `internal/engine/` package to handle core functionality.
4. Add any game-specific assets to the `assets/` directory.
5. Update the main game launcher in `cmd/gg/main.go` to include your new game.

## License

MIT License

About

terminal games in Go (public mirror)

Topics

Resources

Stars

Watchers

Forks