chore: split monolithic header to proper program files, add vec2 ruby class to proxy element position etc., other cleanup

This commit is contained in:
2026-06-01 22:13:50 +01:00
parent 872d878ddc
commit dcb8b46245
21 changed files with 3153 additions and 2037 deletions
+28 -25
View File
@@ -6,15 +6,15 @@
The goal of this project is to build a high performance cross-desktop game engine for 2d games,
When a developer wishes to build a game they generally have 2 options, either they can code the entire game themselves by using a pure rendering library and handling all teh assets etc. themselves, this gives them a lot of control over how the game behaves and can usually also allow them to do a lot of optimizations specific to their idea, but it means they will have to make the coordinate systems and data store, asset management systems etc. all by themselves, on the other hand they could use a game engine.
When a developer wishes to build a game they generally have 2 options, either they can code the entire game themselves by using a pure rendering library and handling all the assets etc. themselves, this gives them a lot of control over how the game behaves and can usually also allow them to do a lot of optimizations specific to their idea, but it means they will have to make the coordinate systems and data store, asset management systems etc. all by themselves, on the other hand they could use a game engine.
the most significant advantage of using game engines when building a game is simplifying development process.
They do this by allowing the developer to do a lot more out of teh box without having to reinvent the wheel themselves:
They do this by allowing the developer to do a lot more out of the box without having to reinvent the wheel themselves:
- They allow making teh game only once but having it work crossplatform on multiple different types of systems
- They allow asset management of game asstes like images, textures, audios etc. without teh need to ensure a uniform format and loading them or decoding them manually
- They also usually have built in physics engines for the coordinate system, which do not need to be reimplemented with al that math by teh developer, and these are done in optimized hot loops for greater performance.
- They allow making the game only once but having it work crossplatform on multiple different types of systems
- They allow asset management of game asstes like images, textures, audios etc. without the need to ensure a uniform format and loading them or decoding them manually
- They also usually have built in physics engines for the coordinate system, which do not need to be reimplemented with al that math by the developer, and these are done in optimized hot loops for greater performance.
The engine is expected to be built in a low level context (for high performance), but allow using it from a high level simpler environment without losing any of the performance. It should also make the development process of a game easy with any common parts for games implemented and reusable.
@@ -39,7 +39,7 @@ They extend a node's behaviour.
So in godot you first define the blueprint, the structure of the game using the ui (or the markup files), and then attach scripts to the nodes to extend their behaviour and actually make them work, these scripts can intercommunicate using events.
Then the godot runtime extracts these scenes and builds teh node tree out of them and runs the scripts attached to the loaded nodes.
Then the godot runtime extracts these scenes and builds the node tree out of them and runs the scripts attached to the loaded nodes.
these scripts are generally written in gdscript which is an interpreted language that is prcompiled to bytecode when the project is built and later on is executed by a runtime-VM.
@@ -72,8 +72,8 @@ It is primaririly a ruby library for rendering and input capture.
It is very good for fast prototyping as it has very simple methods and uses ruby which is very good for fast prototyping (see next sec).
But it does not have a scene or nodes or object system of it's own, all such systems are to be implemented by the developer themselves, and while it provides methods for loading and using of assets they still need to be managed manually. This comes with the up that the developer can chose what kind of system they want to use.
It also requires teh ruby runtime and teh full source code when sharing making it less than ideal for any production games.
Also any kinds of GPU shading requires teh OpenGL libraries to be used directly and it provides no proper access to them.
It also requires the ruby runtime and the full source code when sharing making it less than ideal for any production games.
Also any kinds of GPU shading requires the OpenGL libraries to be used directly and it provides no proper access to them.
As per their own homepage: Gosu is mainly used to teach or learn Ruby.
Comparisions of architectures:
@@ -81,16 +81,16 @@ Comparisions of architectures:
- Data layout
- In the node based system that godot uses each entity (node), stores all it's data in a single object
- This means that when an object is to be worked on it can be used from a single place. It also closely follows a OOP like idea meaning it is simpler for developers more used to it.
- But it creates cache locality problems for example when teh physics system wants to move all elements forward, each object will have to be loaded and then updated and as objects do not have to be together in memory it causes a lot of access overhead.
- On the other hand ECS systems (like the one that can be used in unity), seperate pure data (compoenents) from teh entities.
- But it creates cache locality problems for example when the physics system wants to move all elements forward, each object will have to be loaded and then updated and as objects do not have to be together in memory it causes a lot of access overhead.
- On the other hand ECS systems (like the one that can be used in unity), seperate pure data (compoenents) from the entities.
- This means that when a system wishes to work on a single kind of compoenent it can use tight loops to leverage performance gains from cpu cache locality.
- It also scales very well for having way more entities as entities only use up space for the compoenents they require.
- But it is also a much more complex mental model for the developer to work with.
- Behaviour control
- In godot the bahaviour is very tightly attached to each node, and when executing teh game the behaviour of each node is run fully before going on to the next, this means that similar behaviour like physics is recalculated for each node seperately
- In godot the bahaviour is very tightly attached to each node, and when executing the game the behaviour of each node is run fully before going on to the next, this means that similar behaviour like physics is recalculated for each node seperately
- While in unity most scripts are global systems, these systems can bulk operate on data making them better at potential multithreading or cpu optimizations.
- but they require ore boilerplate code as logic has to be filtered down to apply to the correct nodes manually rather than by vrtue of existing on a node.
- While in a more simple framework like gosu these are all dependant on teh developers implementation.
- While in a more simple framework like gosu these are all dependant on the developers implementation.
^ Gosu. (n.d.). Gosu Homepage. [online] Available at: https://www.libgosu.org/ [Accessed 13 May 2026].
^ Unity Docs. (n.d.). Unity Entity Component System concepts. [online] Available at: https://docs.unity3d.com/Packages/com.unity.entities@6.5/manual/concepts-intro.html [Accessed 13 May 2026]. See sub-links.
@@ -100,11 +100,11 @@ Comparisions of architectures:
## Embedded scripting
This engine does not use a UI builder. And so all gameplay logic, entity behaviour, definitions etc. must be implemented directly through code.
Because of this it is important to use a well established language in which teh developer can write their code.
Because of this it is important to use a well established language in which the developer can write their code.
Embedded scripting languages are programming lanaguges that are designed to be embedded in a host programming language. The embedded language is often an interpreted language which teh host is a compiled static typed language. They allow adding code to teh program that can be modified and interpreted at runtime. They are often used to extend on teh functionality of teh host language. And they also allow using functions defined in the host language which are usually much more performance optimized.
Embedded scripting languages are programming lanaguges that are designed to be embedded in a host programming language. The embedded language is often an interpreted language which the host is a compiled static typed language. They allow adding code to the program that can be modified and interpreted at runtime. They are often used to extend on the functionality of the host language. And they also allow using functions defined in the host language which are usually much more performance optimized.
They are usually very lightweight (so that teh final binary doesn't get bloated and runs fast enough). They are very useful for cuztom DSL/syntax.
They are usually very lightweight (so that the final binary doesn't get bloated and runs fast enough). They are very useful for cuztom DSL/syntax.
And according to [this aticle](https://caiorss.github.io/C-Cpp-Notes/embedded_scripting_languages.html) they are particularly useful for game engines.
@@ -125,12 +125,12 @@ The target users for this project could be one of 2 categories:
- The engine can be used by game developers to create high performance games quickly.
- The games are also built cross-platform meaning they can use the same project to export for different kinds of users.
- The standalone output of teh game engine means tehy wont have to worry about sharing multiple files and makes releases easier.
- The standalone output of the game engine means they wont have to worry about sharing multiple files and makes releases easier.
- And for my own games it would help create a unique brand image for my games, it also helps out with any potential licensing issues with using external engines in my games.
2. Educators
- The game engine can be used by educators to teach programming / game development to students without making them build all teh systems from scratch.
- The game engine can be used by educators to teach programming / game development to students without making them build all the systems from scratch.
- Using such an engine means that the students could be taught about paradigms like ecs and OOP in a simple environment.
- They would also be learning ruby, which is an arguably very good for rapid prototyping due to its forgiving and highly readable syntax.
@@ -246,7 +246,7 @@ core:
- The world can render everything in view based on camera, and everything inside here is in world coordinates
- shaders, layers on top of teh world, (per world, not possible per entity)
- shaders, layers on top of the world, (per world, not possible per entity)
extra:
@@ -257,11 +257,14 @@ extra:
- sprite system (tiled, animated, static etc.)
- 9 segment ui system
- audio playing
- network interface, with a lib to work with rack backends (and generic socket api)
- network interface, with a lib to stream data rom & a server instance also built into the packer binary (should allow ruby scripting the backend)
- persistence store
- rng helpers
- tweening system
- layout system
- tweening helpers
- layout system (with tree like grouping of elements that inherit transform of parent)
- video player (ffmpeg texture and audio streams) (requires ffmpeg at runtime)
- super simple neural network system (with training and runtime phases) (if i have enough time)
## Embedded scripting language choice.
@@ -269,7 +272,7 @@ Why ruby is great for development for the runtime of this engine:
- Dynamic typing. it has almost no type declarations on variables, and duck typing means any object with particular behaviour can be treated the same.
- Expressive syntax. ruby has one of the most expressive syntax that improves code readability by a lot, it allows operator overloading, very clean dsl structures, minimal puntuation neccessary, and a lot of syntactic shortcuts.
- Very rich standard library. teh ruby std lib has a lot of helpers for json, sockets, networking, file management, multithreading, regex etc.
- Very rich standard library. the ruby std lib has a lot of helpers for json, sockets, networking, file management, multithreading, regex etc.
- It also has a lot of inbuilt datatypes with helper methods that allow doing a lot of stuff. it has integers with no hard maximum, floating point numbers, strings and arrays, but it also has symbols, hashmaps and regex etc. for much faster development.
And as its official website itself states, ruby is easy to write, easy to read with natural syntax like spoken language.
@@ -281,15 +284,15 @@ And as its official website itself states, ruby is easy to write, easy to read w
For these reasons and my personal familiarity with the languge i've planned to use ruby as the languge in which the game engine is written code for.
More specifically we will use the `mruby` version as it allows for embedding a lightweight ruby VM into our engine that can run the scripts without needing an external interpreter.
`Mruby` is a very lightwieght impleemntation of teh ruby runtime and also supports semi-compiled bytecodes.
The engine could compile the developers scripts into mruby bytecode when building the application and when it is to be used the teh mruby vm can run these bytecodes.
`Mruby` is a very lightwieght impleemntation of the ruby runtime and also supports semi-compiled bytecodes.
The engine could compile the developers scripts into mruby bytecode when building the application and when it is to be used the the mruby vm can run these bytecodes.
^ Mruby.org. (2026). mruby - Lightweight Ruby. [online] Available at: https://mruby.org/ [Accessed 13 May 2026].
^ Ruby (2019). Ruby Programming Language. [online] Ruby-lang.org. Available at: https://www.ruby-lang.org/en/ [Accessed 13 May 2026].
##
- then a draft one of teh requirements with justification of each based on the previous sections
- then a draft one of the requirements with justification of each based on the previous sections
Requirements v1: