Skip to main content

Densetsu

A Zelda-themed demo demonstrating physics and "AI" techniques.

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.

Sources #

ā€“ Sprites and images: Sourced directly fromĀ The Legend of Zelda: A Link to the PastĀ and fromĀ zfgc.com
ā€“ 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Ā noproblo.dayjo.org