Low level game engine

The following information is no longer up to date, since the game changed.
Additional info:
This was written for older version of the game, and it is highly inaccurate now!

This describes the Game Engine. That includes objects, characters, physics, movement, abd entire core. sing this gamme engine I wrote, the game is implemented.


This is sub-layout for documentation pages

Top

1 Introduction

In order to make the game, there are entities. It can be Player, Monster, or just some wall or bonus.
All these objects have certain things in common. It is position, size, collision, etc.
Therefore, every object that is in game world, inherits from GameObject class.

2 GameObject

The GameObject represents something, that can be set up (collision can be added, Physics can be added to the object, position, size...)
To suit the needs.

High-level classes, such as Player, Character, just set up the GameObject in appropriate way.

3 Segment

A game world is divided to multiple Segments.
Segment is rectangle in the world.
Without segments, having player rectangle (red), if we would like to determine what static objects it collides (blue), it would require to check for collision for all the (blue) objects.

With segments, the situation will be as follows:

Here, the server will check for collision with only the blue rectangles, that collide the parent segment (S1) of the player. That reduces the complexity greatly.

This system is applied to following:

4 Collision shapes

In order to check for collision between two Game Objects, there must be some geometrical shape, and mathematical formula for checking for shape intersection.
So far, available shapes are: Rectangle, Circle, Limited line, where Limited line is line, defined on some interval \(I=(A, B)\) where \(A \in \!R, B \in \!R, A \leq B\), where \(I\) defines interval on the \(x\) axis

Therefore, such a shape (CollisionCircle, CollisionRectangle, ...) can be attached to Game Object, and is given some identifying name


4.1 Name identifiers

Name identifier is used to identify some specific collision shape attached to the Game Object.
For example, Game Object might have several collisions attached, but at most one collision of one identifying name:

Then, from within code, if check for physical collision for movement is done, BUMPER collisions are used for such a task.
If, however, check for collision between projectile and character shall be done, from Projectile, BUMPER is used, from character, HITBOX is used, and these shapes are checked mathematically for collision

5 Physics

Can be attached to any GameObject.
Contains methods for computing collision between such a GameObject and the rest of the world (objects that can cause physical collision).
The collision resolving is very complex topic, full of math, definitions, and formulas, all explained here

6 Character

This class is base for any living creature. Mainly for Player and Monster.
It allows to modify health, max health, allows damage character, ask whether he is dead or alive.
Also allows to move character left / right / jump.

7 Player

Contains all info that is necessary for player in the game.

8 Monster

TODO

9 PlayerMedalResolver

WARNING! no longer up to date!

Contains public methods, such as onBonusPickedUp, onPlayerDowned, onZombieKilled.
They are called from various places, such as from Player, Map, ProjectileBase....

10 UserGameStats

TODO

11 Setting Position to down-centre


11.1 The objective

Given a GameObject with some origin position, and bumper collision. Let A be a point on a bumper collision such as the x coordinate is in the centre of the rectangle and y axis in on the bottom of the rectangle.

Given target point T, the task is to set the object's origin position so that the point A = T. (the point positions equal)



11.2 General example