BlitzFramework - The perfect interaction with BVM!

Community Forums/Showcase/BlitzFramework - The perfect interaction with BVM!

JaviCervera(Posted 2004) [#1]
I have release this package, which provides an appropiate framework to make a game, using Blitz3D and BVM (BlitzVirtualMachine), Koriolis' scripting engine.

It basically provides an event system architecture to Blitz, and adds "actors", this is, anything that has a behaviour. You can define a handler for each type of actor, which is a function which is called every frame AUTOMATICALLY by BlitzFramework to update the actor, and you can process all the messages that the actor has received. This way it gives the impression that all the actors are acting simultaneously in the world.

The appropiate way to interact between actors is to send messages between them. The message id 0 is sent by BlitzFramework to all the actors when they are created, so when the handler receives this message, it can load the stuff (textures, meshes, etc). You can use any other message ids to do whatever you need (for example, a bullet actor would send a message id 1 -or whatever number you like- to the actor it has collided with, and when this actor processes its messages, it finds the message id 1, and must reduce its own health and such :)).

This is free for whatever you want, as long as you don't violate the license terms of Blitz3D and BVM.

http://www.galeon.com/jedive/storage/BlitzFramework.zip (20 Kb).

[EDIT]Right click and 'Save Link Target As..' or whatever it is[/EDIT]


JaviCervera(Posted 2004) [#2]
The set of new functions included, they are explained in the 'readme' file:

SendMessage(id, data1=0, data2=0, custom$="", actor=0)
GetMessage.Msg(actor=0)
NextMessage(actor=0)

LoadScript$(file$)

CreateActor%(name$)
ActorSetInt(actor,index,value)
ActorSetFloat(actor,index,value#)
ActorSetString(actor,index,value$)
ActorGetInt%(actor,index)
ActorGetFloat#(actor,index)
ActorGetString$(actor,index)
CountActors%()
GetActor%(index)
FindActor%(name$, index=1)
FreeActor(actor)

EndMain()



Litobyte(Posted 2004) [#3]
Hey this sounds great! :)

Weird nobody here post its own comments.

I'll give it a look if I find the time!


JaviCervera(Posted 2004) [#4]
Weird nobody here post its own comments.
Usually happens to me :)


Koriolis(Posted 2004) [#5]
Very nice use of BVM :)
I especially like that it shows how to do parallel programming (sort of) pretty simply.
Well done Jedive.

As a side not it's worth noting that with the OOP extension of BVM 2, doing such an event system will be close to straightforward: just have a base class "Actor" a and a main loop that call methods of the actors( -> event handlers) in response to appropriate events. Then, creating a new actor is just a matter of deriving the "Actor" class and redefining the methods for which you want a specialized behaviour :D
Once BVM2 finished I will most certainly provide a framework similar to yours, updated to use the new features.
Until then, congratulations and thanks again Jedive.


JaviCervera(Posted 2004) [#6]
Hi Koriolis :)

I have found a bug, and I don't know what is causing that. If you run the example in BlitzFramework and wait for a minute or so, it returns a 'Memory Access Violation'... if you run in Debug mode, you see that the problem is in the Dll function BVM_Run()... maybe a bug in BVM?


Koriolis(Posted 2004) [#7]
I have just checked, you have a stack overflow. Returning a nice "stack overflow" error is also on my todo list, so next time you run into this you'll know immediately the problem :most certainly some infinite loop or a return value you forgot to pop.
Here this is the second one: you forgot to pop the return value here:
		BVM_SelectEntryPoint Main\EntryPoint
		If BVM_Invoke_BlitzFramework()=False Then RuntimeError BVM_GetLastErrorMsg$()
		;!!!HERE!!!
Just do
		BVM_SelectEntryPoint Main\EntryPoint
		If BVM_Invoke_BlitzFramework()=False Then RuntimeError BVM_GetLastErrorMsg$()
		BVM_PopInt()
and it's OK :)


JaviCervera(Posted 2004) [#8]
Yes! It's perfect now! Cool :)


Beaker(Posted 2004) [#9]
Does sound good. Some things like this take a while to absorb, and work out where you might use it.

The best way to show off something is to provide a meaty demo of it in action. :)


JaviCervera(Posted 2004) [#10]
A port of Rob's FPS Shell would be cool, but i don't have the time yet to do it... maybe by the end of june, when i finish my exams.


ashmantle(Posted 2004) [#11]
This is really cool.. thanks alot ^^ I will have a field day on this one...

EDIT: ugh? somehow that link only sends me to http://galeon.hispavista.com/


JaviCervera(Posted 2004) [#12]
Yeah, I said that you need to download it by right clicking on it and selecting 'Save Link Target As...'.


ashmantle(Posted 2004) [#13]
Well.. I get an error when trying to extract it with Winrar.
Either unknown archive format or corrupt file it saiz..


JaviCervera(Posted 2004) [#14]
Works perfectly here, also using WinRAR. I downloaded it with Mozilla FireFox.


ashmantle(Posted 2004) [#15]
lol... this is so weird.. it is 32kb on my disk, but you said its supposed to take 20kb?

I have tried again and again with similar results.. darn..


JaviCervera(Posted 2004) [#16]
It's exactly 20k. I have mailed it to ya.