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
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.
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.
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:
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
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:
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
This class is base for any living creature. Mainly for Player
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.
Contains all info that is necessary for player in the game.
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)