Densetsu is a simple game demo built to demonstrate several physics and artificial intelligence techniques as part of a final year University project. The game uses assets from the seminal Super Nintendo game, The Legend of Zelda: A Link to the Past, and challenges players to dash around, sword in hand, collecting rupees, while avoiding (or fighting off) enemy guards.

The game features custom rigid body physics and a separating axis theorem (SAT)-based collision to model all physical actions and reactions in the world. Surface friction is modelled alongside air resistance/drag (the latter affecting airborne projectiles such as the boomerang). Different surfaces have different friction coefficients and these can be altered at runtime, such as when the ground become slicker in the rain.

Movement is all calculated using real(-ish) physics, be it linear momentum for player and AI movement or angular momentum in the case of the spinning boomerang. The effect of mass can best be seen in the “black holes” which are incredibly dense and suck in everything around them (well, everything that isn’t nailed down to the ground or it wouldn’t be a very fun game).

The guard’s artificial intelligence went through two major iterations. In the first, AI agents used the Theta* algorithm (an A* variation) for pathfinding alongside simple finite state machines to search out and chase down the player. Once in contact enemies simply charged in at full-speed to attack the player. The video included above is from this first iteration.

The second version of Densetsu replaced finite state machines with more powerful and versatile behaviour trees. A blackboard system was used to simulate agent-to-agent communication which allowed groups of enemy guards to (or at least appear to) work together to take down the player. This culminated in an Assassin’s Creed-esque combat system in which enemies cluster around the player but only attack (or feint an attack!) one by one. Second video Coming Soon!


– Sprites and images: Sourced directly from The Legend of Zelda: A Link to the Past and from
– Title Screen Music: The Legend of Zelda: A Link to the Past ‘Triforce Majeure’ (OC Remix)
– Game Over Music: DJ ShaK – Legend of Zelda NES Remix
– Song of Storms remix: The Legend of Zelda: Ocarina of Time ‘Thunderstruck’ (OC Remix)
– Dark World remix: The Legend of Zelda: A Link to the Past ‘Dark World Orchestrated’
– Sound effects: The Legend of Zelda: Ocarina of Time and A Link to the Past via