mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
docs: spelling mistakes correction
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
|
||||
# Preface
|
||||
|
||||
The game engine is incomplete and still evolving, as such this page should be considered outdated at all times...
|
||||
|
||||
# Game Engine
|
||||
|
||||
The Toy programming langauge was designed from the beginning as an embedded scripting language for some kind of game engine. Different iterations have existed with different implementations, some of which could charitably be said to function. The current version, and the most stable and feature complete so far, has reached a point where it needs some kind of concrete engine to improve any further.
|
||||
The Toy programming language was designed from the beginning as an embedded scripting language for some kind of game engine. Different iterations have existed with different implementations, some of which could charitably be said to function. The current version, and the most stable and feature-complete so far, has reached a point where it needs some kind of concrete engine to improve any further.
|
||||
|
||||
Currently, the engine exists within its own repository, which can be found here:
|
||||
|
||||
@@ -20,19 +21,19 @@ The engine proper is invoked with just three lifecycle functions`:
|
||||
#include "box_engine.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
//initialize the drive system
|
||||
Toy_initDriveSystem();
|
||||
Toy_setDrivePath("scripts", "assets/scripts");
|
||||
//initialize the drive system
|
||||
Toy_initDriveSystem();
|
||||
Toy_setDrivePath("scripts", "assets/scripts");
|
||||
|
||||
//invoke the engine
|
||||
Box_initEngine("scripts:/init.toy"); //passing in the specified init file
|
||||
Box_execEngine();
|
||||
Box_freeEngine();
|
||||
//invoke the engine
|
||||
Box_initEngine("scripts:/init.toy"); //passing in the specified init file
|
||||
Box_execEngine();
|
||||
Box_freeEngine();
|
||||
|
||||
//clean up the drive system when you're done
|
||||
Toy_freeDriveSystem();
|
||||
//clean up the drive system when you're done
|
||||
Toy_freeDriveSystem();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
```
|
||||
@@ -40,7 +41,7 @@ int main(int argc, char* argv[]) {
|
||||
The engine proper holds the following elements:
|
||||
|
||||
* SDL2 video and audio elements
|
||||
* Framerate controls
|
||||
* Frame rate controls
|
||||
* Toy interpreter
|
||||
* Input keyboard mapping dictionaries
|
||||
* The root node
|
||||
@@ -57,26 +58,26 @@ The nodes form a deep tree-like structure, with the "root node" at it's base.
|
||||
|
||||
## Node Structure
|
||||
|
||||
The fundemental building block of the engine's logic is the node structure - nodes can represent anything within the game world, from entities to abstract global systems. You can think of entities as having a 1:1 mapping to Toy scripts, as each one is given bytecode on initialization that populates its internals (external libraries like the runner library are still possible).
|
||||
The fundamental building block of the engine's logic is the node structure - nodes can represent anything within the game world, from entities to abstract global systems. You can think of entities as having a 1:1 mapping to Toy scripts, as each one is given bytecode on initialization that populates its internals (external libraries like the runner library are still possible).
|
||||
|
||||
A node holds the following elements:
|
||||
|
||||
* A reference to it's parent
|
||||
* An array of references to its children, and bookkeeping variables for tracking them
|
||||
* A dictionary of functions defined in the Toy script
|
||||
* A single SDL texture reference, and controls for rendering it (including as an animated spritesheet)
|
||||
* A single SDL texture reference, and controls for rendering it (including as an animated sprite sheet)
|
||||
* Position, motion and scale values
|
||||
|
||||
The nodes are deeply integrated with Toy scripts, while Toy was written specifically for this purpose. The tree-like structure of the nodes all exist entirely within the computer's heap memory as a result of Toy's memory model - this comes with performance drawbacks and cleanup requirements. Child nodes should never be referenced directly, as they may be `NULL` references that have been released, but not yet pruned.
|
||||
The nodes are deeply integrated with Toy scripts, while Toy was written specifically for this purpose. The tree-like structure of the nodes all exist entirely within the computer's heap memory as a result of Toy's memory model - this comes with performance drawbacks and clean up requirements. Child nodes should never be referenced directly, as they may be `NULL` references that have been released, but not yet pruned.
|
||||
|
||||
The rules of execution for scripts and functions is as follows:
|
||||
|
||||
* The script is executed during node initialization
|
||||
* All functions (regardless of name) are stored within the node - effectively preserving the scope of the script as a whole
|
||||
* These functions can now be invoked from elsewhere in the program
|
||||
* Certian function names (listed below) are invoked at specific times during the game loop throughout the entire node tree
|
||||
* Certain function names (listed below) are invoked at specific times during the game loop throughout the entire node tree
|
||||
* If the specially named functions do not exist, the node is simply skipped
|
||||
* Every function, which is intended to be called through `callNodeFn()` or at specific times in the loop must take the `opaque` node as its first argument
|
||||
* Every function, which is intended to be called through `callNodeFn()` or at specific times in the loop, must take the `opaque` node as its first argument
|
||||
|
||||
## Special Function Names
|
||||
|
||||
@@ -105,7 +106,7 @@ NOTE: `onLoad()` is invoked every time a node is loaded - but `onInit()` is only
|
||||
|
||||
A series of libraries are provided to allow Toy to interface and control the engine. In addition, the libraries stored within Toy's `repl/` directory are also available (see the main page for the list).
|
||||
|
||||
During startup, the script named `init.toy` in the the assets/scripts directory is executed. This file can be used to configure input mappings, as well as initializing the window and node tree.
|
||||
During startup, the script named `init.toy` in the assets/scripts directory is executed. This file can be used to configure input mappings, as well as initializing the window and node tree.
|
||||
|
||||
* Engine Library
|
||||
* Node Library
|
||||
@@ -113,3 +114,4 @@ During startup, the script named `init.toy` in the the assets/scripts directory
|
||||
* Music Library
|
||||
* Sound Library
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user