Each actor has an 'onStep' function, if set

Replaced the global 'onStep' with 'onFrame', otherwise it works the
same.
This commit is contained in:
2026-05-13 17:55:35 +10:00
parent c539f9aa9e
commit eb8115aa7e
5 changed files with 92 additions and 111 deletions
+6 -4
View File
@@ -1,6 +1,7 @@
#pragma once
#include "toy_vm.h"
#include "toy_function.h"
#include "raylib.h"
//sprites loaded from disk
@@ -13,19 +14,20 @@ typedef struct SpriteData {
//Actors loaded from scripts
typedef struct ActorData {
SpriteData* sprite;
Toy_Function* onStep;
Vector2 position;
//TODO: animation
int health;
bool enabled;
} ActorData;
//object pool system
void initActorAPI(Toy_VM* vm);
void freeActorAPI(Toy_VM* vm);
void processActorStep(Toy_VM* vm);
void processActors(Toy_VM* vm);
void drawActors(Toy_VM* vm);
void loadSprite(Toy_Bucket** bucketHandle, Toy_Value key, const char* fname, int width, int height);
ActorData* spawnActorAt(Toy_Bucket** bucketHandle, Toy_Value key, int xpos, int ypos);
ActorData* spawnActorAt(Toy_Bucket** bucketHandle, Toy_Value key, Toy_Function* onStep, int xpos, int ypos);
//opaque hook
Toy_Value handleActorAttributes(Toy_VM* vm, Toy_Value compound, Toy_Value attribute);