Skip to content

TheOnliestMattastic/BTA-RRR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โš”๏ธ BTA-RRR: Battle Tactics Arena โ€” Refactored & Remastered

BTA-RRR Banner

Last Commit Repo Size Code Size License

Portfolio GitHub Email

๐Ÿ”ญ Overview

BTA-RRR is a turn-based tactical grid combat game built in Lร–VE2D (Lua framework). Originally a monolithic CS final project, it's been completely refactored into a modular, well-documented codebase following clean architecture principles.

The game features:

  • 16x16 grid-based tactical combat with 30+ character classes
  • Vim-style navigation (hjkl + arrows) โ€” a dual-purpose system for practicing vim while playing
  • Turn-based initiative system with action points and resource management
  • State machine architecture separating game logic from presentation
  • Professional Lua patterns โ€” metatables, dependency injection, data-driven design

The codebase is designed to be readable and maintainable, with clear separation of concerns and every design decision documented.

๐ŸŽฎ Quick Start

Prerequisites

  • Lร–VE2D (0.10.2 or later) โ€” Download from love2d.org
  • Git โ€” For cloning the repo
  • Lua 5.1+ โ€” Usually bundled with Lร–VE2D

Installation & Running

# Clone the repository
git clone https://github.com/TheOnliestMattastic/BTA-RRR.git
cd BTA-RRR

# Run with Lร–VE2D
love .

That's it. The game boots directly from main.lua.

๐Ÿ•น๏ธ Gameplay Controls

Keyboard

  • hjkl โ€” Vim-style movement (h=left, j=down, k=up, l=right)
  • Arrow Keys / WASD โ€” Alternative directional input
  • Tab โ€” Toggle focus between map and action menu
  • j/k โ€” Navigate menu up/down (when menu has focus)
  • Space โ€” End turn
  • Return โ€” Confirm action (move, attack, etc.)
  • Escape โ€” Quit game

Mouse

  • Move โ€” Hover over tiles for visual feedback
  • Left Click โ€” Select tiles, characters, or activate menu buttons
  • Release โ€” Confirm action (buttons activate on release)

๐Ÿ—‚๏ธ Project Structure

main.lua                 # Entry point, state machine, window setup
โ”œโ”€โ”€ states/              # Game states (menu, game loop)
โ”‚   โ”œโ”€โ”€ menu.lua         # Main menu state
โ”‚   โ””โ”€โ”€ game.lua         # Main gameplay loop and orchestration
โ”œโ”€โ”€ core/                # Game logic and systems
โ”‚   โ”œโ”€โ”€ character.lua    # Character entity, stats, animations
โ”‚   โ”œโ”€โ”€ gameState.lua    # Turn order, win conditions, AP management
โ”‚   โ”œโ”€โ”€ turnManager.lua  # Initiative rolls, turn progression
โ”‚   โ”œโ”€โ”€ inputHandler.lua # Keyboard/mouse/vim input routing
โ”‚   โ”œโ”€โ”€ gameUI.lua       # HUD rendering (stats, menu, turn order)
โ”‚   โ”œโ”€โ”€ map.lua          # Tile grid, collision, rendering
โ”‚   โ”œโ”€โ”€ gameLogic.lua    # Combat calculations, damage, range checks
โ”‚   โ”œโ”€โ”€ assetRegistry.lua # Centralized asset loading
โ”‚   โ””โ”€โ”€ gameInit.lua     # Setup and dependency injection
โ”œโ”€โ”€ config/              # Data (not logic)
โ”‚   โ”œโ”€โ”€ characters.lua   # Character class definitions (30+)
โ”‚   โ”œโ”€โ”€ tilesets.lua     # Tileset/map configurations
โ”‚   โ”œโ”€โ”€ ui.lua           # UI layout constants
โ”‚   โ””โ”€โ”€ fx.lua           # Visual effects (damage numbers, etc.)
โ”œโ”€โ”€ lib/                 # Third-party libraries
โ”‚   โ””โ”€โ”€ anim8.lua        # Animation library (vendored)
โ””โ”€โ”€ assets/              # Sprites, fonts, tilesets
    โ”œโ”€โ”€ sprites/chars/   # Character spritesheets
    โ””โ”€โ”€ fonts/           # Game fonts

Key Architectural Principle: Data lives in config/, logic lives in core/, presentation lives in states/. No circular dependencies.

๐Ÿ’ฌ Code Standards (WHAT/WHY/HOW)

Every function follows a structured comment pattern:

-- =============================================================================
-- MODULE_NAME
-- =============================================================================
-- WHAT: One sentence describing what this does
-- WHY:  One sentence explaining why it's needed
-- HOW:  One sentence explaining the implementation approach
-- NOTE: [Optional] Gotchas, alternatives, or reminders
-- =============================================================================

This isn't busy-workโ€”it makes code self-documenting and intentional. You know exactly why something exists.

๐ŸŽฏ Design Philosophy: KISSME

  • Keep It Stupidly Simple โ€” Code clarity over cleverness. If it's complex, break it smaller.
  • Modularize Everything โ€” Each module has one job. Find what you need fast.
  • Data-Driven โ€” Configuration lives in tables; logic stays in functions.
  • Object-Oriented โ€” Lua metatables for clean entity management (Character, GameState, Map, etc.)

No over-engineering. No premature optimization. Just clean, readable, maintainable code.

๐Ÿ“š Core Systems

Turn System

  • Initiative: D&D-style d20 + SPD roll (see turnManager.lua)
  • Action Points (AP): Gained at turn start (usually +2, capped at 4)
  • Movement: Manhattan distance calculation, validates range before execution
  • Combat: Range check + damage formula: damage = attacker.pwr - defender.def (with minimum 1)

Character Classes

30+ distinct classes with unique stat profiles:

Stat Range Purpose
HP 12-32 Health pool
PWR 4-8 Damage output
DEF 1-8 Damage reduction
DEX 2-6 Hit accuracy/evasion
SPD 2-5 Movement range + initiative modifier
RNG 1-4 Attack range

See config/characters.lua for the full roster (Ninjas, Samurai, Mages, Brawlers, Knights, etc.).

Map & Collision

  • 16x16 tile grid, 32px per tile
  • Randomized tileset selection (procedural variety)
  • Character collision detection
  • Range highlighting for movement/attacks

๐Ÿš€ Development Workflow

Adding a New Character Class

  1. Add entry to config/characters.lua with stats, sprite path, animation definitions
  2. Add sprite sheets to assets/sprites/chars/<className>/
    • SpriteSheet.png (16x16 frames, 4 directions, 3-5 animation states)
    • Faceset.png (portrait for UI)
  3. Register in states/game.lua by instantiating with Character.new(className, x, y, stats)
  4. Test locally with love .

Adjusting Game Balance

All balance lives in config/characters.lua (stats) or core/character.lua (AP gain):

function Character:gainAP(amount)
    self.ap = math.min(self.ap + (amount or 2), self.maxAP)  -- Change "2" to adjust
end

Debugging Input Flow

  • inputHandler:getFocus() returns "map" or "menu"
  • inputHandler.uiFocus shows which UI element has focus
  • Print input in states/game.lua keypressed/mousepressed handlers

๐Ÿ“‹ Known Limitations & Roadmap

Current Gaps

  • Action menu buttons are placeholders โ€” Not all actions are implemented yet
  • No persistent saves โ€” Game state doesn't persist between sessions
  • No AI opponents โ€” Multiplayer/AI would be next-level features
  • No ability system โ€” Tags exist in character data but aren't used yet
  • No diagonal movement โ€” Animations locked to cardinal directions

Refactoring Priorities (for recruiter appeal)

  1. Implement Ability System โ€” Registry with cost/range/effects (shows system design)
  2. Event Bus Architecture โ€” Replace direct function calls with event system (loose coupling)
  3. Data Serialization โ€” Save/load with proper schema (production readiness)
  4. Unit Tests โ€” Test game logic: damage calculations, range checks (quality assurance)
  5. Performance Profiling โ€” Document optimization decisions (engineering rigor)

๐Ÿ› ๏ธ Useful Commands

# Run game
love .

# Check code syntax
lua -c core/character.lua

# View recent commits
git log --oneline -10

# Find all TODOs
grep -r "TODO" core/

๐ŸŽ“ Learning Resources

If you're curious about game architecture, check these out:

๐Ÿ›ธ License

This project is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.

๐Ÿ‘ฝ Contact

Curious about my approach to architecture, code design, or game development? Want to discuss refactoring strategies or hire for a role where clean code matters?

Portfolio GitHub Email

"The only way to do great work is to love what you hate." โ€” Deliberately Inverted

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages