Mike, thanks for this module and now sample script, help and source. Another major step into making thinBasic an awesome game development environment!
Hi folks,
here is the first example that hopefully shows a little about the TBEM module. It feature a self repeating event.
[code=thinbasic]
' TBEM sample 1 by Michael Hartlef, 2008
USES "TBASS"
uses "TBEM"
USES "Console"
USES "FILE"
DIM sFile AS STRING '---Filename to load
DIM Channel AS DWORD '---Audio channel to use
DIM SamChannel AS DWORD '---Sample channel to use
dim count as long
dim eventSnd as long
dim retval as long
count = 13
%evt_sound = 1
function playsfx() as long
count -= 1
if count > 0 then
TBASS_ChannelPlay(SamChannel, %TBASS_TRUE)
console_writeline("Number of SoundFX left: "+count)
endif
end function
' Setup output for the default device
' n = TBASS_Init (Device, Frequency, Flags, Win, clsID)
IF TBASS_Init(-1, 44100, 0, 0, 0) = 0 THEN
console_Writeline("Can't initialize device. Program aborted")
else
' Set the volume level
TBASS_SetVolume(50)
' Now ask which file to load
sFile = APP_SourcePath+"soundfx\bells007.wav"
' Check if file exists
if file_exists(sFile) = %FALSE then
console_Writeline("File " & sFile & $crlf & "does not exixts.")
else
' File does exist now load as a sample using that filename
Channel = TBASS_SampleLoad(%TBASS_FALSE, sFile, 0, 0, 1, %TBASS_SAMPLE_FLOAT )
IF Channel = 0 THEN
' whatever it is, it isn't playable
console_Writeline( "Can't play the file " & sFile)
else
' Create a Sample playback Channel
SamChannel = TBASS_SAMPLEGetChannel(Channel,%TBASS_FALSE)
' File does exist now create a stream using that filename
' SamChannel = TBASS_StreamCreateFile(%TBASS_FALSE, sFile, 0, 0, %TBASS_SAMPLE_LOOP or %TBASS_STREAM_PRESCAN )
IF SamChannel = -1 THEN
' Error trying to get a channel
console_Writeline("No Channel. Can't play the file " & sFile)
else
' Valid File now set it to play
'Add an event to the event manager
eventSnd = TBEM_AddEvent("playsfx",%evt_sound)
'Repeat the sound every 5 seconds
TBEM_SetRepeat(eventSnd,%TRUE,5000)
'Fire a trigger to start runnign the event
TBEM_AddTrigger(%evt_sound)
Console_Writeline("It's 12 o'clock midnight...")
while count <> 0
'Check and run active events
retval = TBEM_Run
wend
ENDIF
ENDIF
ENDIF
endif
' Clearup TBASS
TBASS_Free
console_writeline("Press any key...")
console_waitkey
[/code]
Mike, thanks for this module and now sample script, help and source. Another major step into making thinBasic an awesome game development environment!
Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server
Mike I get GPF in module after 2 execution. See image.
Ciao
Eros
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Hi Mike,
fantastic, repeated events are very nice!
I also got GPF, but then I downloaded latest version and the "clock" works as expected.
The sound is like from horror movie
Thanks,
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
SORRY, MY FAULT.
I didn't download latest version from http://community.thinbasic.com/index...11718#msg11718
Now all is ok.
Thanks
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Sorry guys for the inconvenience, yes you had to download the latest version.
Petr, "For whom the bell tolls" is a song by Metallica, and it has a similar bell sound in the song. You might want to check it out, it is a classic.
But the event module is new and very exciting that is for sure!
Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server
Ahhh someone who knows I'm big into Heavy Metal. It's my absolute favorite type of music.
On June 11th, my wife and me are going to see KISS. That will be awesome and probably the last chance to see them live. Who knows how long they are gonna playing and when they are back in germany the next time. I think it is allready 8 years since they were here the last time.
Hi Mike,
hope you will enjoy the concert in summer, do will they still have the classic black and white mad shader on the faces?
Regarding the module, if I get it correctly, the eventIDs must be different across various eventGroups?
Thanks,
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Hi Petr,
yes, since around 1998 they are back in the masks after a long time wearing no masks.
The eventID is basically the memory location of the event structure. So each event gets a new ID. It has nothing to do with the eventGroup. I had the idea to have event groups if you need to make sure that certain events run before others. Like for an example,
you have events that draw the gui. Then there are events that deal with the game logic. Another one draws the game content. So you create three eventgroups
[code=thinbasic]
'Define eventgroups
%evg_gui = 1
%evg_gamelogic = 2
%evg_drawgame = 3
'Game loop
while gameactive = %TRUE
'... do some other stuff
TBEM_Run(%evg_gamelogic)
TBEM_Run(%evg_drawgame)
TBEM_Run(%evg_gui)
wend
[/code]
It is not necessary to create and use groups, the default group is 0 and so if don't assign an event to a group, it will allways be in
the default group.
Ciao
Michael
Bookmarks