Blitz Virtual Machine rocks!

Miscellaneous Forums/Content Creation Tools/Blitz Virtual Machine rocks!

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

Thans for your answers. I worked on this very hard last night, and I have ducesfully implemented BVM in my engine the way I wanted to do it.

It were easier than I thought. I just created one context for the main script and another context for the entities.

When the csFrame() function is called from the main loop of the main script, it handles the entities the following way:

- Change the current context to the entities one.
- Do a For... Each loop to hanle all the entities (each entity has a Type variable)
- The entity var has a field with the script module of the entity, and another field with the entry point to the function that controls the entity, so i set the correct entry point for the context, i pop the entity, and invoke the virtual machine.
- After all the entities are processed, i restore the main context.

The good thing is that it works perfectly now and I have only lost 5 fps as much (the Century map ran @ 120-125 fps before with collisions and entities on it, now it rans @ about 120 fps).

A function that controls an entity has the following structure:

Function info_player_start(entity.csEntity)
Select Entity\Msg$
   Case "MsgCreate"
      ;Stuff that the entity has to initialize (mesh that it uses, etc)
   Case "MsgFrame"
      ;Standard frame nessage, the default message it receives every frame
   Case "MsgDestroy"
      ;Free stuff here, cos the entity will be deleted after executing this function
End Select
End Function

"MsgFrame" is the message sent when no entities has sent a message to the current entity. A bullet would for example sent this entity a "MsgBulletHit" message, and this entity would react to this message (decrease health, etc).

I would like to see something on BVM: The possibility to define constants in the .bcs file. The engien uses a lot of constants for the function flags, and now I have to include a file on all the scripts. I would like to simply add these contants to the .bcs file and this way these constants are known when compiling the scripts :)

Oh! And '[]' type arrays would be also cool :D But this is not that important for me, I am currently simply hiding array fields inside types to the scripts, and read them using functions.