PDA

View Full Version : TBEM - Event manager module V1.10



Michael Hartlef
20-03-2008, 16:55
Hi folks,

I think I have the syntax settled and it is ready to be published. TBEM - Event manager module for thinBasic. It will help you set up events for a game. Well, it could be used for other uses too, but I was thinking more game related, when I was developing it. Included with the module is a little help file that describes the syntax right now. I will wirte some samples tonight to relieve the power of this little module. I'm pretty excited about it as I think it is really a helper when you develop games. Ok, enough bragging. Like I said, samples will follow soon, but the ones who want to play with it allready, download it now.

Update October 18th, 2008: Version 1.10 uploaded. Bugfixes plus new zone commands

Here is just a little console sample:




uses "TBEM"
uses "Console"

dim event1, event2 as long
dim y,q,z as long
dim stime,dtime,etime as dword
q = 0
z = 0
y = 0

%evg_system = 1
%evg_user = 2

%evt_game = 1
%evt_gui = 2
%evt_next = 3

function FinishIt()
console_writeline(y+") Finish")
q = 99
function = 0
end function

function getTime()
y += 1
console_writeline(y + ") TimeDiff="+dtime)
function = 0
end function

event1 = TBEM_AddEvent("getTime",%evt_gui,getTickcount,%evg_system,%TRUE)
event2 = TBEM_AddEvent("FinishIt",%evt_game,getTickcount+300,%evg_system,%TRUE)


stime = gettickcount
while q = 0
etime = gettickcount
dtime = etime - stime
TBEM_AddTrigger ( %evt_gui)
TBEM_AddTrigger ( %evt_game)
TBEM_run(%evg_system)
wend

console_writeline("TriggerCount="+TBEM_GetTriggerCount+" EventCount="+TBEM_GetEventCount)

console_writeline("Press any key...")
Console_waitkey

Petr Schreiber
20-03-2008, 18:07
Thanks a lot Mike,

this kind of event oriented game programming will be something new for me, and I am looking forward to it.
The thinBASIC functions and module links are very poweful combo! I am sure it will start new era of thinBASIC games 8)


Petr

Michael Hartlef
21-03-2008, 01:39
Ok Eros, I uploaded a new version and added your requested command.

Petr Schreiber
21-03-2008, 09:02
Hi Eros,

I think this module deserves separate forum section, else this post will get lost in sea of new messages, and that would be a pity.


Thanks,
Petr

ErosOlmi
21-03-2008, 09:04
Already done ;D

http://community.thinbasic.com/index.php?board=154.0

I'm just now moving posts in there.
Michael is moderator.

Ciao

Michael Hartlef
23-03-2008, 22:23
Updated the module because auf a serious pointer bug. Please download it from the first post.

kryton9
23-03-2008, 23:32
Thanks Mike for the update!

Michael Hartlef
25-03-2008, 22:15
Hi,

please download the latest release. There was some nasty timing probs when you used several self repeating events.

Thanks to Eros for testing.

Lionheart008
11-09-2008, 14:56
Hi dear Michael :-)

.. question about your "TBEM"... Can you explain to me what is the content of the 'event manager module'? Do you need it for "Games"? ... your example is only useful for the console?...or may be a good thing for window gui too? perhaps it's rubbish I told, but I am only curious to understand what is TBEM ;-))

best regards, hope your scripts are running well with the new thinBasic version,

greetings with a lot of sunshine from centre of germany, lionheart

Michael Hartlef
11-09-2008, 15:12
Hi lionheart,

you can use TBEM for everything that needs to be done repeatly/automatically. There are 2 main parts of the event module, events and triggers. First you have to tell the modul which event functions exists on which trigger they can react. Triggers are fired by your code, when ever you need them. TBEM then looks if some events needs to be processed and will call the specific functions.

I had mostly games in my mind but maybe it is good for windows apps too. But don't confuse TBEM-events with windows events. Two different things. And they are not console only. It was just a quick sample I came up with.

I will will try to come up with more samples so it will be easier to understand.

Thanks, yes it is sunny here too. But enjoy it as they predict that it will be the last warm days in the year.

Lionheart008
11-09-2008, 17:22
Hi Michael again:-)

thank you for information input... good to now what's possible with thinBasic and the tools, it's better for me to check an example to understand it...


you can use TBEM for everything that needs to be done repeatly/automatically. There are 2 main parts of the event module, events and triggers.

perhaps I can use it for my open gl exercises or windows gui I want to build... I think TBEM is useful for big data amounts (?) you can proof or check selected entries or creating games they are using always the same routines... I will see it...

if you have some example for testing, I can help you :-)

have a nice evening, bye, lionheart

qt: I have tested your example and have got this result:
"TriggerCount =0" and "EventCount = 2"... ??? - that's ok?...

Michael Hartlef
11-09-2008, 19:33
Yes, that's ok.

Michael Hartlef
18-10-2008, 19:05
New version 1.10 is available in the most top post. Besides a few bugfixes it introduces zones.

Zones are rectangular and/or box spaces which have a trigger type and trigger data attached to them. Before you use TBEM_RUN you can check all active zones if a given point is inside a zone. If it is, the zone will fire a trigger and so activates existing events.

Have fun
Michael

Petr Schreiber
18-10-2008, 19:18
Hi Mike,

thanks for really important tweak of the module!
Thanks for documenting it too :)


Petr

ErosOlmi
18-10-2008, 19:38
Thanks Michael.

Module and help downloaded.
Will be present in next thinBasic release.

1000 thanks
Eros

kryton9
18-10-2008, 21:12
Great addition to an already powerful module Mike, thanks!

Michael Hartlef
18-10-2008, 22:14
Thanks guys. I hope the new stuff works good.

Michael Hartlef
18-10-2008, 23:51
Ok folks,

please redownload the file. I fixed the little misbehaviour with repeating events that Eros reported.

Petr Schreiber
18-10-2008, 23:54
Thanks Mike,

what was the reason of trouble?


Petr

kryton9
19-10-2008, 06:40
Thanks for the quick fix Mike!

Michael Hartlef
19-10-2008, 07:34
Thanks Mike,

what was the reason of trouble?


Petr


The reason was not thinking before I changed it ;)

I switched the following IF Structures


If @currEvent.intervalcount <> 0 Then
While @currEvent.starttime <= time
@currEvent.starttime = time + @currEvent.intervaltime
Wend
End If
If @currEvent.intervalcount > 0 Then
@currEvent.intervalcount = @currEvent.intervalcount - 1
If @currEvent.intervalcount = 0 Then @currEvent.repeatFlag = %FALSE
End If


Sorry
Michael