Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: TBEM sample 1 - For whom the bell tolls

  1. #1

    TBEM sample 1 - For whom the bell tolls

    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]
    Attached Files Attached Files

  2. #2
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,869
    Rep Power
    404

    Re: TBEM sample 1 - For whome the bells toll

    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

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,795
    Rep Power
    10

    Re: TBEM sample 1 - For whome the bells toll

    Mike I get GPF in module after 2 execution. See image.

    Ciao
    Eros
    Attached Images Attached Images
    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

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,139
    Rep Power
    733

    Re: TBEM sample 1 - For whome the bells toll

    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

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,795
    Rep Power
    10

    Re: TBEM sample 1 - For whome the bells toll

    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

  6. #6

    Re: TBEM sample 1 - For whome the bells toll

    Sorry guys for the inconvenience, yes you had to download the latest version.

  7. #7
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,869
    Rep Power
    404

    Re: TBEM sample 1 - For whome the bells toll

    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

  8. #8

    Re: TBEM sample 1 - For whome the bells toll

    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.

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,139
    Rep Power
    733

    Re: TBEM sample 1 - For whome the bells toll

    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

  10. #10

    Re: TBEM sample 1 - For whom the bell tolls

    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

Page 1 of 2 12 LastLast

Similar Threads

  1. TBEM sample - SetRepeat
    By Michael Hartlef in forum TBEM module - thinBasic Event Manager module
    Replies: 4
    Last Post: 19-10-2008, 00:01
  2. TBEM sample - Zones
    By Michael Hartlef in forum TBEM module - thinBasic Event Manager module
    Replies: 0
    Last Post: 18-10-2008, 19:03

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •