4.3 KiB
Boulevard Combattant 2D Engine
What does the engine do?
The goal of the engine is to determine a representation of the element described in the gameplay package.
Functionality
The engine can create a window apply an aspect ratio, and dynamically as the window resize maintain the graphic environment as the selected aspect ratio.
Display 2d model on the screen apply texture/shader to them, every basic geometric transformation: translation, rotation, scaling.
Built-in HUD system, the engine is able to create an object and make it keep track of the position/scaling of the camera. For this release three types of ui element exist: basic geometric shape, text and progress bar but this is a really easy system to expand on.
Sound is also managed by the engine, with the help of the OpenAl library we can recreate 3d sound, doppler effect and such in the game albeit these effects are unused by the game at the moment.
Behaviour
At every call of the engine.render()
method every Object added to the render queue is rendered in accordance with the shader chosen.
How does it work?
Because our engine uses the OpenGL API every object in the scene is represented by a vertex array object, this array keep track of every vertex, indices, color and textureUV information. All of these informations are encapsulated in the VertexArray
class.
A vertex array work in tandem with a shader to show the object as our artist intended, shader are written in the glsl standard of the OpenGl library. Those small programs are sent to the gpu and are used in two phases, the vertex calculation and the fragment one, the first is used to calculate the position of the vertex in the game world and through the projection, the second one is used to calculate which color each pixel on the screen should be. These two part essential for the creation of an object are encapsulated in the ObjectGl
class which is the most used class in the engine.
Through this class you can apply transformation to the object, modify shader, vertex array etc...
Now these objects are used by the engine class who store every one of them in a arrayList
, at every call of the render()
method these ObjectGl
are draw on the screen according to the rule specified in their shader and vertex array.
Inputs are collected via the use of the update()
method for every interaction a callback has been created in the Input
package through these callbacks we can fetch for example which key has been pressed on a keyboard.
Brief package presentation
camera
A camera is represented by a 3D vector in the world space the main class in the package camera can be used to modify the position, zoom in or out. Tracking class are used to control automatically the behavior of the camera.
TrackingSF3ThirdStrick
is an imitation of the camera behavior in the game Street Fighter 3 Tracking is updated every frame in the engine.update()
method
graphics
Here are the class who make the connection between our program and the OpenGl API as we talked in the How does it work ? section.
gui
Every class here inherited from the UIDummy
class, they represent special type of ObjectGl
who translate/scale with the camera.
input
Button
was created to allow rebinding of the key, a feature that has not been added in the game yet.
GamepadInput
and KeyboardInput
are the classes used to fetch which key has been used every frame
loader
In some optimization effort some texture are loaded all at once and reused without ever needing to reload the texture from the file.
math
Every class used to represent the geometrical shape Primitive
, and the operation associated with it Matrix4f
and Vector3f
.
object
The ObjectGl
class and his derivatives as we explained in the How does it work ?
section.
object_wrapper
Some type of structure need to use multiple ObjectGl
at once like Text
sound
Basic OpenAl implementation completely functional, not used.
utils
Every tool needed for accessing files and create buffers.
Engine
The main class in which you can control the whole behavior of the graphical application. The game should be created around the class.