Hyperbolic Game Engine

Written by Ines Bultmann and Filippa Piazolo

The goal of our project was to design a 2D hyperbolic game engine in p5.js using the Poincaré disk as the hyperbolic model. The inspiration for the game engine came from the arcade game “Asteroids”. In that game one can steer a spaceship and shoot lasers on flying asteroids to get points and reach different levels.

In our project we wanted to implement the basic structures that can be used in every game strategy, such as movement, steering and collision detection.

The first thing to implement was the movement of all objects. Other than in the Euclidean space in the Poincaré disk the straight lines are either the diameter or circular arcs orthogonal to the unit circle called geodesics. At every timestep all objects must follow one geodesic determined by the position and direction of the object.

The “spaceship” can also be steered manually. The left and right arrows are used to rotate the object, changing its direction. The upper arrow is used to move the ship along the geodesic as described above.

As part of the movement, the speed and size of the objects needed to be adjusted according to the location on the disk. The speed and size are defined constant in the Euclidean space. On the Poincaré disk the objects get slower and smaller towards the boundary for our Euclidean point of view. The speed and so the position of an object is evaluated through the angular change (\(Δα\)) of a point \(p\) on its geodesic \(g\). The angular change can be calculated by $$Δα = s\cdot\left(1-\frac{|p|^2}{2r}\right)$$ with \(s\) being the constant Euclidean speed and \(r\) being the Euclidean radius of geodesic \(g\).

For collision detection of two objects, we used the hyperbolic distance between the positions of those objects. When the distance between those is smaller than both radii together the objects collide. The hyperbolic distance of point \(p\) and point \(q\) is defined as $$d(p,q) = \textrm{arcosh}\left(1+2\frac{|p-q|^2r^2}{(r^2- |p|^2)(r^2- |q|^2)}\right)$$ where \(r\) is the radius of the Poincaré disk and \( |\cdot|\) is the Euclidean norm.

We created two different game modes. Both can be found on github.

The single player version where the goal is to shoot asteroids can be found on the branch “hyperbolic”.

The multiplayer version where the goal is to shoot one another can be found on the branch “1vs1-game”.

There is also a simple Euclidean asteroids version on the branch “euclidean_space” from the very beginning.  

Leave a Reply

Your email address will not be published. Required fields are marked *