Tower of Time: A Time-Travel Tower Defense Game Developed with AI Assistance
Are you a game development enthusiast eager to create your own game but unsure where to begin? Today, I’ll introduce you to Tower of Time, a game developed by a beginner. The creator participated in the Beginner’s Jam Summer 2025 event. After exploring various game themes, they decided to combine time travel with tower defense mechanics. Due to time constraints and it being their first real game project, they chose the tower defense genre. Below is a detailed look at Tower of Time.
Game Concept and Core Mechanics
Tower of Time is a tower defense game featuring time-rewind mechanics. Players can control a spaceship to move around the map and build defenses. When overwhelmed by enemies, players can rewind time to rebuild their defenses. The game incorporates a Chrono Meter™ resource for rewinding time, which is replenished by defeating enemies. Key mechanics include:
-
Players can build structures on empty tiles directly below their spaceship. Constructing each structure takes time during which the player cannot move. -
Enemies spawn from one side of the map, aiming to steal the player’s time-travel power. Initially, there are too many enemies to repel, forcing players to use their time powers. -
RewindableSprite, a generic Phaser game object, allows enemies to be rewound. When the REWIND button is pressed, enemies enter REWIND mode, and each frame held rewinds one step. When released, enemies switch back to FORWARD mode. -
Enemies use the A* algorithm for pathfinding. If a path to the destination is not found, they stop moving and become idle. During pathfinding, enemies randomly target positions within tiles to make movement more dynamic. -
The game features multiple enemy types with varying speeds and HP values, differentiated by color tinting. The WaveSystem allows for customizing enemy types, quantities, and spawn intervals in waves.
Game Development Process
Prototype Development
The creator began by building a level using tilemaps, enabling the player character to fly around and collide with walls. They added the ability to build structures directly below the player, created an end goal and enemy spawner, and implemented time-rewind functionality. These foundational features laid the groundwork for the game.
AI-Assisted Development
Approximately 95% of the codebase was generated with AI assistance. Tools like Augment Code, Cursor (primarily in Agent mode), and Claude Sonnet 4 played significant roles. The developer leveraged these tools to handle complex code logic, such as player movement and interaction, building systems, enemy AI, and time-rewind mechanics. When encountering issues like bugs or performance bottlenecks, the developer would ask the AI to add debug logs to identify and resolve problems.
Key Feature Development
-
Player Movement and Interaction: The player can move in all four directions using arrow keys, with gamepad support planned. The player sprite rotates to face the direction of movement. When moving, the tile below the player is highlighted with a semi-transparent white square, visible only if the player is above a non-path tile. -
Building System: Players can build structures on non-path tiles. The game tracks which tiles contain buildings to enable selling functionality. Buildings are rendered in a lower layer than the player sprite. -
Enemy AI and Pathfinding: Enemies move toward targets using the A* algorithm. If a path is not found, they stop and become idle. During pathfinding, enemies randomly target positions within tiles to avoid linear movement. -
Time-Rewind Mechanic: The RewindableSprite object records its state and can render itself using recorded states during rewinding. When rewinding, enemy animations play in reverse. When the REWIND button is released, all state records after the current timeOffset are discarded.
Game Features and Gameplay
Unique Time-Rewind Mechanic
Players can rewind time using Chrono Meter™ resources. However, excessive rewinding strengthens enemies, so players must use this ability wisely. This mechanic adds strategic depth to the game.
Diverse Tower Types
The game offers four tower types:
-
Basic Tower: Shoots bullets at a default rate of one per second with a configurable radius. It detects enemies within range and fires bullets toward them. -
Sniper Tower: Twice the range and bullet speed of the basic tower but fires slower. -
Slowdown Tower: Periodically applies a slow effect to enemies within its circular range. -
Splash Tower: Fires blasts at intervals, damaging all enemies within its radius.
Energy Management System
Players have a set amount of energy, which is used to build towers and rewind time. Energy gradually regenerates over time but stops during rewind mode. Defeating enemies drops EnergyCrystals, which players can collect to increase their energy. Crystals disappear after 15 seconds, flashing for the last 5 seconds to alert players.
Wave-Based Enemy Spawning
Enemies spawn in waves according to predefined configurations. Each wave consists of multiple enemy types with specified quantities and spawn intervals. A new wave begins only after all enemies from the current wave are defeated. When a wave starts, a “WAVE n START!” overlay appears briefly.
Game Art and Sound Design
Visual Effects
-
Goal: Designed as a purple gem with a subtle glow and shadow, featuring a pulsing light effect. -
EnergyCrystals: Similar to the goal, but with a pale blue glow and shadow. They also pulsate slightly and fade out before disappearing. -
Enemy HP Bars: When an enemy’s HP is below max, a small HP bar above it displays remaining HP in green and background in red. The HP bar updates during time rewinding to reflect enemy position changes.
Sound Effects
-
Background Music: Different tracks play on various scenes. For example, music-menu
plays on the Title screen and stops when the game starts.music-game
plays in the Level scene. During rewind mode,music-game-reverse
plays from the position where the normal track left off. -
In-Game Sounds: Sounds are triggered for different actions, such as menu highlighting, button selection, enemy explosions, and tower shooting. For instance, the shoot
sound plays when Basic and Sniper Towers fire, theslow
sound when the Slowdown Tower activates, and theblast
sound when the Splash Tower attacks.
Project Structure and Technical Stack
Project Structure
src/
├── main.ts # Entry point and configuration
├── scenes/ # Scenes (Title, Level, Configure)
├── prefabs/ # Prefabs (Player, Towers, Enemies)
├── systems/ # Systems (Energy, Building, Config)
├── components/ # Components (Input, Rewind)
├── ui/ # UI components (Bars, Menus, Dialogs)
└── utils/ # Utilities (Sound, Music, Keys)
public/
├── assets/ # Assets (Images, Sounds, Fonts)
├── style.css # Basic CSS styles
index.html # Game entry point
Technical Stack
-
Engine: Phaser 3 (v3.90.0) with Phaser Editor v4. -
Language: TypeScript. -
Build Tool: Vite.
Game Development Experience and Lessons Learned
Development Challenges and Solutions
-
Player Movement: Initially, the player ship had movement inertia, causing random spinning when moving. The developer adjusted it to make the ship instantly rotate to the input vector while maintaining acceleration and deceleration for speed. -
Building System: Early on, buildings were rendered above the player sprite. The developer adjusted the layering system to ensure the player sprite stays on top. -
Time-Rewind Mechanic: When first implemented, enemies would stop animating after prolonged rewinding and fail to resume movement upon release. The developer added logic to discard state records after the current timeOffset when releasing the REWIND button. -
Enemy Pathfinding: After rewinding, enemies would sometimes ignore the path and head straight for the goal. The developer modified the code to recalculate paths when exiting rewind mode.
AI-Assisted Development Experience
-
Prototyping Speed: AI greatly accelerated prototyping. For example, when implementing player movement, the AI quickly generated code based on the developer’s prompts. -
Code Optimization: AI tends to generate extensive code. The developer had to review and optimize it, eliminating redundancies to improve efficiency. -
Debugging Assistance: When encountering bugs, the developer would ask the AI to add debug logs to pinpoint issues. However, if the AI struggled to resolve a problem, the developer would rephrase the prompt or provide additional context to guide the AI.
Game Impact and Future Prospects
Tower of Time demonstrates that even beginners can create games with the help of AI. It offers players a unique time-travel tower defense experience. Looking ahead, the developer plans to refine game balance, introduce more enemy and tower types, and enhance the storyline and level design.
FAQ
How to Run and Build the Game?
-
Prerequisites: Install Node.js and pnpm. -
Running the Game: Run pnpm install
to install dependencies andpnpm dev
to start the development server. -
Building the Game: Use pnpm build
to generate production code.
What Input Devices Are Supported?
The game supports both keyboard and gamepad input. Players can move using arrow keys or a gamepad analog stick and perform actions using the Spacebar or the A button on a gamepad.
How to Customize Game Settings?
The game features a ConfigSystem that stores important constants and configuration values. Players can adjust these settings via the Configure menu. For example, they can modify wave configurations, enemy type parameters, player speed, and maximum energy levels.
Conclusion
Tower of Time is a unique time-travel tower defense game developed by a beginner with AI assistance. It showcases the potential of AI in game development and provides valuable insights for aspiring game developers. By exploring the game’s development process and features, you can gain a deeper understanding of how to create your own games. The game’s source code and related resources are available on GitHub at https://github.com/m4v3k/tower-of-time. Feel free to explore and draw inspiration for your game development journey.
As AI continues to advance, we can expect more innovative games to emerge. Perhaps one day, you’ll use AI to create a game that captivates players worldwide.