Results 1 to 5 of 5

Thread: Little problem with geteventfunc, seteventfunc

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Little problem with geteventfunc, seteventfunc

    Hi Mike,

    I had some time to start to play with TBEM module, but I found a little problem which demonstrates following script.
    Maybe it is just that I misunderstood something.

    The script should add 5 rabbits and 3 wolves ( no, I am not drunk, just test sample ):
    [code=thinbasic]
    uses "CONSOLE"
    uses "TBEM"

    begin const
    %evt_AddElement = 1
    end const

    Scene_Init()

    ' -- Prepair events
    dim eventAdd as long
    eventAdd = TBEM_AddEvent("Scene_AddRabbit", %evt_AddElement)
    TBEM_Addtrigger(%evt_AddElement)
    TBEM_setRepeat(eventAdd, %TRUE, 1000)

    console_PrintLine("Program started, it will add 5 rabbits, 3 wolves and then end ")

    while Scene_Built = 0
    ' -- Our event loop
    TBEM_Run
    wend

    ' -- Aux functions
    sub Scene_Init()
    Global Scene_Built as long = 0
    Global Scene_NumRabbits as long = 0
    Global Scene_NumWolves as long = 0
    end sub

    sub Scene_AddRabbit()

    if Scene_NumRabbits = 5 then
    TBEM_SetEventFunc(eventAdd, "Scene_AddWolf")
    console_printline("-- Time to spawn wolves")
    else
    incr Scene_NumRabbits
    console_printline("Rabbit"+STR$(Scene_NumRabbits)+" added")
    endif

    end sub

    sub Scene_AddWolf()

    if Scene_NumWolves = 3 then
    TBEM_SetEventFunc(eventAdd, "Scene_AddRabbit")
    Scene_Built = 1
    else
    incr Scene_NumWolves
    console_printline("Wolf"+STR$(Scene_NumWolves)+" added")
    endif

    end sub
    [/code]

    After adding 5 rabbits and changing the func to add wolves it GPFs.


    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

  2. #2

    Re: Little problem with geteventfunc, seteventfunc

    Hi Petr,

    sorry for the inconvenience. I didn't test this properly. But I foudn the bug allready and know how to fix it. I will release a new version tonight.

    Michael

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Little problem with geteventfunc, seteventfunc

    No problem,

    thanks a lot.
    Programming dynamic allocation stuff is always dangerous, but when tuned right it is perfect


    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

  4. #4

    Re: Little problem with geteventfunc, seteventfunc

    Hi Petr,

    please download the new version from here:

    http://community.thinbasic.com/index...11718#msg11718

    It was a pointer bug but should be squished for now.

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Little problem with geteventfunc, seteventfunc

    Thanks for quick fix,

    now it works as it should on my PC, very nice!


    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

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
  •