Skip to content

bonskari/GameByAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

50 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

GameByAI - 3D Game Engine

A 3D first-person game created with AI assistance using Rust and macroquad.

๐Ÿฆ€ About

This project creates a classic first-person 3D gameplay experience using modern Rust development with the macroquad game framework. The development process is AI-assisted, combining learning with practical game development.

๐Ÿ†• NEW: Hybrid ECS A Pathfinding System* - The game now features a complete Entity Component System with intelligent A* pathfinding, reusable components, and excellent performance (120+ FPS after lighting optimization).

๐Ÿš€ Getting Started

Prerequisites

  • Rust (installed via rustup)
  • Cargo (comes with Rust)

Building and Running

# Clone the repository
git clone https://github.com/bonskari/GameByAI.git
cd GameByAI

# Build the project
cargo build

# Run the game
cargo run

# Run the visual test mode with AI pathfinding
cargo run -- visual-test

# Run visual test with custom duration
cargo run -- visual-test -d 30

๐ŸŽฎ Game Features

  • โœ… Full 3D first-person rendering with textured walls, floors, and ceilings
  • โœ… Complete ECS architecture with 253 entities (52 walls, 100 floors, 100 ceilings)
  • โœ… Hybrid ECS A pathfinding system* with reusable Pathfinder component
  • โœ… Intelligent TestBot navigation using A* algorithm for optimal pathfinding
  • โœ… Texture-based rendering with proper material lookup system
  • โœ… ECS collision detection working seamlessly with grid-based detection
  • โœ… Excellent performance maintaining 120+ FPS consistently (after lighting optimization)
  • โœ… Modern 3D graphics with procedural textures โš ๏ธ (dynamic lighting disabled for performance)
  • โœ… Integrated testing system with automated bot navigation
  • โœ… Real-time minimap with pathfinding visualization
  • โœ… First-person controls (WASD movement, mouse look, jumping)
  • โœ… Cross-platform support via macroquad
  • โœ… AI-assisted development process

๐Ÿ—๏ธ ECS Architecture

The game features a complete Entity Component System (ECS) implementation with hybrid pathfinding:

Core ECS Components

  • Transform - Position, rotation, and scale for all entities
  • StaticRenderer - Texture-based rendering with material types
  • Collider - Physics-engine-style collision with shapes and materials
  • Player - Player-specific data and settings
  • Wall/Floor/Ceiling - Level geometry components with texture mapping
  • MaterialType - Texture material system (Wall, Floor, Ceiling variants)
  • ๐Ÿ†• Pathfinder - Reusable A* pathfinding component for any entity
  • ๐Ÿ†• TestBot - Automated testing bot with waypoint navigation

ECS Systems

  • Rendering System - Handles texture lookup and 3D rendering for 253 entities
  • Collision Detection - Grid-based collision using entity component queries
  • ๐Ÿ†• PathfindingSystem - Processes all entities with Pathfinder components
  • Physics Integration - Gravity, jumping, and physics via direct component access

Hybrid Pathfinding Model

  • TestBot Component: Manages high-level behavior (waypoints, test duration)
  • Pathfinder Component: Handles low-level pathfinding (A* algorithm, path following)
  • Reusable Design: Any entity can add a Pathfinder component for intelligent navigation
  • A Algorithm*: Proper heuristic-based pathfinding with obstacle avoidance
  • Performance Optimized: Binary heap implementation for efficient pathfinding

Current ECS Implementation Status

  • โœ… Player Entity: Fully migrated to ECS with Transform + Player components
  • โœ… 253 Static Entities: 52 walls, 100 floors, 100 ceilings all ECS-based
  • โœ… ECS Rendering System: StaticRenderer actively rendering all ECS entities
  • โœ… Texture System: Complete material-based texture rendering via ECS
  • โœ… ECS Collision Detection: Grid-based collision working perfectly
  • โœ… ๐Ÿ†• Hybrid Pathfinding: TestBot + Pathfinder components working together
  • โœ… Performance: Excellent 120+ FPS with full ECS rendering and pathfinding (lighting system disabled)
  • โš ๏ธ Technical Debt: Dynamic lighting system exists but disabled for performance reasons

๐ŸŽจ Texture System

The game features a complete texture loading and rendering system:

Loaded Textures

  • tech_panel.png - Wall textures
  • hull_plating.png - Wall textures
  • control_system.png - Wall textures
  • energy_conduit.png - Wall textures
  • floor.png - Floor textures with linear filtering
  • ceiling.png - Ceiling textures

Material System

  • MaterialType enum with Wall, Floor, Ceiling variants
  • Texture lookup by material type
  • Proper UV mapping for all surfaces
  • Linear filtering for smooth texture rendering

๐Ÿง  AI Pathfinding System

The game features an advanced hybrid ECS pathfinding system:

A* Pathfinding Algorithm

  • Heuristic-based pathfinding for optimal route calculation
  • Binary heap optimization for efficient node processing
  • Obstacle avoidance with proper wall detection
  • Grid-based navigation integrated with map system
  • Diagonal movement support with proper cost calculation

Pathfinder Component (Reusable)

  • Target position tracking for navigation goals
  • Path calculation and storage for smooth movement
  • Movement and rotation speeds configurable per entity
  • Path following logic with waypoint progression
  • Stuck detection and recovery for robust navigation

Visual Debugging

  • Real-time minimap visualization showing:
    • Blue areas: A* explored nodes (search area)
    • Red areas: Actual pathfinding routes
    • Yellow circle: Current target waypoint
    • Green dot: Player/bot position and direction

๐Ÿ› ๏ธ Technologies Used

  • Rust - Systems programming language
  • macroquad - Simple and easy to use 2D/3D game framework
  • Custom ECS - Complete Entity Component System implementation
  • A Pathfinding* - Intelligent navigation with binary heap optimization
  • Texture Loading - PNG texture support with material system
  • Grid-based Collision - Efficient spatial collision detection
  • Cargo - Rust package manager and build system
  • clap - Command line argument parsing

๐Ÿ“ Project Structure

โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.rs              # Main entry point and CLI
โ”‚   โ”œโ”€โ”€ cli.rs               # Command line interface
โ”‚   โ”œโ”€โ”€ game/
โ”‚   โ”‚   โ”œโ”€โ”€ mod.rs           # Game module
โ”‚   โ”‚   โ”œโ”€โ”€ state.rs         # Game state management
โ”‚   โ”‚   โ”œโ”€โ”€ player.rs        # Player mechanics
โ”‚   โ”‚   โ”œโ”€โ”€ map.rs           # Level data and rendering
โ”‚   โ”‚   โ”œโ”€โ”€ input.rs         # Centralized input handling
โ”‚   โ”‚   โ”œโ”€โ”€ ecs_state.rs     # ECS game state
โ”‚   โ”‚   โ””โ”€โ”€ rendering/       # 3D graphics engine
โ”‚   โ”œโ”€โ”€ ecs/                 # Entity Component System
โ”‚   โ”‚   โ”œโ”€โ”€ mod.rs           # ECS module exports
โ”‚   โ”‚   โ”œโ”€โ”€ entity.rs        # Entity management
โ”‚   โ”‚   โ”œโ”€โ”€ component.rs     # Component storage
โ”‚   โ”‚   โ”œโ”€โ”€ world.rs         # ECS world container
โ”‚   โ”‚   โ”œโ”€โ”€ system.rs        # System management
โ”‚   โ”‚   โ”œโ”€โ”€ components.rs    # Game-specific components
โ”‚   โ”‚   โ”œโ”€โ”€ systems.rs       # Game-specific systems
โ”‚   โ”‚   โ”œโ”€โ”€ pathfinding.rs   # ๐Ÿ†• A* pathfinding algorithms
โ”‚   โ”‚   โ”œโ”€โ”€ query.rs         # Query system
โ”‚   โ”‚   โ””โ”€โ”€ resource.rs      # Resource management
โ”‚   โ””โ”€โ”€ testing/
โ”‚       โ”œโ”€โ”€ mod.rs           # Testing module
โ”‚       โ”œโ”€โ”€ tests.rs         # Unit tests
โ”‚       โ”œโ”€โ”€ runner.rs        # Test runner
โ”‚       โ””โ”€โ”€ screenshot_validator.rs # Visual validation
โ”œโ”€โ”€ cpp_backup/              # Previous C++ implementation
โ”œโ”€โ”€ scripts/                 # Build and utility scripts
โ”œโ”€โ”€ Cargo.toml              # Rust dependencies and metadata
โ”œโ”€โ”€ .gitignore              # Git ignore patterns
โ””โ”€โ”€ README.md               # This file

๐ŸŽฏ Development Status

  • โœ… Basic project setup
  • โœ… Rust toolchain configuration
  • โœ… macroquad integration
  • โœ… Advanced 3D graphics engine with procedural textures
  • โœ… Complete player movement system (WASD, mouse look, jumping)
  • โœ… Level loading and rendering system
  • โœ… ๐Ÿ†• Hybrid ECS A pathfinding system*
  • โœ… ๐Ÿ†• Reusable Pathfinder component for any entity
  • โœ… ๐Ÿ†• Intelligent TestBot with A navigation*
  • โœ… Visual debugging and testing system
  • โœ… Minimap with real-time pathfinding visualization
  • โœ… Automated testing with AI bot navigation
  • โœ… Entity Component System (ECS) implementation
  • โœ… Centralized input system
  • โœ… Full ECS architecture with pathfinding integration

๐ŸŽฎ Controls

  • WASD - Move and strafe
  • Mouse - Look around (FPS-style)
  • Space - Jump
  • Tab - Toggle between 3D and 2D view
  • M - Toggle mouse capture
  • Esc - Exit game

๐Ÿงช Testing

The project includes an advanced automated visual test system with AI pathfinding:

Visual Test Mode

The visual test mode runs comprehensive testing including lighting performance and AI bot navigation:

# Run the complete visual test suite (lighting + bot navigation)
cargo run -- visual-test

# Run with custom bot navigation duration (default: 15 seconds)
cargo run -- visual-test --duration 30
cargo run -- visual-test -d 30

The visual test will:

  • ๐Ÿ”† Test lighting performance first with progressive light count testing
  • Generate optimal paths using A* pathfinding algorithm
  • Navigate through waypoints automatically with intelligent pathfinding
  • Visualize pathfinding on the minimap in real-time
  • Test wall collision detection and avoidance
  • Display progress with overlay information
  • Complete automatically after the specified duration

Lighting Performance Tests (Always Included)

Every visual test run includes a progressive lighting test sequence:

  • Baseline Test: Performance with no lights (3 seconds)
  • Single Light Test: Performance with 1 light (2 seconds)
  • Multiple Lights: Performance with 8 strategically placed lights (3 seconds)
  • Many Lights: Performance with 50 random lights (4 seconds)
  • Stress Test: Performance with 100+ lights if previous tests show good performance (3 seconds)

This helps measure the impact of the lighting system on performance and identify optimal light counts for smooth gameplay.

What You'll See:

  • Main 3D View: Full first-person 3D rendering
  • Minimap (top-right):
    • Blue areas: A* algorithm exploration
    • Red areas: Calculated pathfinding routes
    • Yellow circle: Current target waypoint
    • Green dot: AI bot position and direction
  • Overlay (top-left): Progress information and test status
  • Console Output: Real-time pathfinding calculations and navigation updates

๐Ÿ›๏ธ Architecture Highlights

ECS + A* Pathfinding Integration

  • Modular Design: Pathfinding is a reusable component system
  • High Performance: 120+ FPS with full pathfinding calculations
  • Scalable: Any number of entities can use pathfinding simultaneously
  • Intelligent Navigation: Proper obstacle avoidance and optimal routing

Component Separation

  • TestBot: High-level waypoint management and test behavior
  • Pathfinder: Low-level A* pathfinding and movement execution
  • Transform: Position and rotation data
  • Clean Architecture: Each component has a single responsibility

๐Ÿค Contributing

This is a learning project focused on AI-assisted game development. Feel free to explore the code and suggest improvements!

Try these techniques

https://diglib.eg.org/items/93fc78c0-71fa-4511-8564-a7e5268bf27a

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors