Thanks to visit codestin.com
Credit goes to github.com

Skip to content

shpaker/tnk9x

Repository files navigation

tnk9x

A modern remake and tribute to the classic arcade game Battle City (NES, 1985), built with Go and Ebiten. This project combines a passion for the original game with learning Go, Clean Architecture principles, and game development.

GitHub: https://github.com/shpaker/tnk9x

Development Status

Core

  • Game loop (delta time)
  • Collision detection (tank-tank, tank-wall, bullet-wall, bullet-tank, bullet-HQ)
  • Boundary collision
  • Tank movement/rotation/braking
  • Bullet mechanics
  • Enemy spawning
  • Surface types (brick, steel, forest)
  • Surface types (water, ice)
  • Surface mechanics (ice sliding, water blocking)

Player

  • Controls (keyboard)
  • Lives/respawn
  • Tank levels (0-3)
  • Damage system (level down on hit)
  • Bonuses (grenade, tank, star)
  • Power-ups (bullet speed, reinforced bullets, bullet limit)
  • Bonuses (helmet, timer, shovel)

Enemies

  • Spawning system
  • AI (Lua scripts)
  • Level system (probability-based)
  • Types (basic, fast, rapid fire, heavy)
  • Heavy tank health overlay
  • AI difficulty scaling

HQ

  • Vulnerability/explosion
  • Victory/defeat overlays
  • Defeat screen
  • Protection mechanics

UI

  • Level selection
  • Pause overlay
  • Debug info (FPS, TPS, lives, enemies)
  • HUD (lives, score)
  • Main menu
  • Game over screen
  • Settings

Audio

  • Sound effects
  • Background music
  • Engine loop
  • Volume config

Infrastructure

  • Clean Architecture
  • Dependency injection
  • Repository pattern
  • Specs system
  • Unit tests (collision, audio)
  • Test coverage (>80%)
  • CI/CD
  • Performance profiling

Installation and Running

Requirements: Go 1.24+, optionally — Just.

git clone https://github.com/shpaker/tnk9x.git
cd tnk9x
just deps         # Install dependencies (or go mod download)

# Run the game
just run          # or go run cmd/main.go

# Build binary
just build        # binary will be in dist/tnk9x

# Checks
just fmt
just lint
just test

Architecture

The project follows Clean Architecture principles with clear separation of concerns across four layers. Dependencies point inward: outer layers depend on inner layers through interfaces.

Dependency Flow

┌────────────────────────────────────────────────────────┐
│  Presentation Layer                                    │
│  ┌──────────────┐  ┌──────────────┐                    │
│  │   States     │  │   Adapters   │                    │
│  │              │  │              │                    │
│  │ StageState   │  │ Renderer     │                    │
│  │ StageSelect  │  │ Input        │                    │
│  │              │  │ Sound        │                    │
│  └──────┬───────┘  └───────┬──────┘                    │
│         │                  │                           │
│         └─────────┬────────┘                           │
│                   │ (depends on)                       │
│                   ▼                                    │
└────────────────────────────────────────────────────────┘
                    │
┌───────────────────▼─────────────────────────────────────┐
│  Application Layer                                      │
│  ┌──────────────┐  ┌──────────────┐                     │
│  │  Use Cases   │  │   Services   │                     │
│  │              │  │              │                     │
│  │ TankActions  │  │ Collision    │                     │
│  │ Collision    │  │ Animation    │                     │
│  │ Sound        │  │ Coordinate   │                     │
│  └──────┬───────┘  └──────┬───────┘                     │
│         │                 │                             │
│         └─────────┬───────┘                             │
│                   │ (manipulates)                       │
│                   ▼                                     │
└─────────────────────────────────────────────────────────┘
                    │
┌───────────────────▼─────────────────────────────────────┐
│  Domain Layer                                           │
│  ┌───────────────────────────────────────────────────┐  │
│  │  Entities (Tank, Bullet, Block, HQ, etc.)         │  │
│  │  Value Objects (Position, Size, Direction)        │  │
│  │  Session Entities (GameSession, StageSession)     │  │
│  └───────────────────────────────────────────────────┘  │
│                   ▲                                     │
└───────────────────┼─────────────────────────────────────┘
                    │ (reads/writes)
┌───────────────────▼─────────────────────────────────────┐
│  Infrastructure Layer                                   │
│  ┌──────────────┐  ┌──────────────┐                     │
│  │ Repositories │  │   Raw Files  │                     │
│  │              │  │              │                     │
│  │ Game         │  │ FileSystem   │                     │
│  │ Processed    │  │              │                     │
│  └──────────────┘  └──────────────┘                     │
└─────────────────────────────────────────────────────────┘

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Clone of the classic arcade game Battle City (NES, 1985), built with Go.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published