Small fixes to prevent possible issues down the road

Thanks @objc
This commit is contained in:
2026-05-02 09:16:37 +10:00
parent 96f7942049
commit 9d35e4862e
2 changed files with 28 additions and 4 deletions
+9 -4
View File
@@ -127,11 +127,14 @@ int main() {
//initialize the monster object pool and run the setup function
initMonsterObjectPool(&vm);
//run the onStep function (or die if it's undefined)
//setup
Toy_bindVM(&vm, invokeOnReady, NULL);
Toy_runVM(&vm);
Toy_resetVM(&vm, true, false);
//onStep is called each frame
Toy_bindVM(&vm, invokeOnStep, NULL);
while (!WindowShouldClose()) {
//input
if (IsKeyDown(KEY_UP)) player.position.y -= 5.0f;
@@ -139,10 +142,8 @@ int main() {
if (IsKeyDown(KEY_LEFT)) player.position.x -= 5.0f;
if (IsKeyDown(KEY_RIGHT)) player.position.x += 5.0f;
//run the onStep function (or die if it's undefined)
Toy_bindVM(&vm, invokeOnStep, NULL);
//run the onStep function
Toy_runVM(&vm);
Toy_resetVM(&vm, true, false);
//drawing
BeginDrawing();
@@ -157,6 +158,10 @@ int main() {
EndDrawing();
}
//clear onStep
Toy_resetVM(&vm, true, false);
//cleanup
Toy_bindVM(&vm, invokeOnFinished, NULL);
Toy_runVM(&vm);
Toy_resetVM(&vm, true, false);