April 25, 2019, 04:18:34 AM

Author Topic: Code only runs when there is an event  (Read 92 times)

Offline Cosmo

  • Jr. Member
  • **
  • Posts: 15
Code only runs when there is an event
« on: April 09, 2019, 03:59:54 PM »
My code only runs when there is an event. it shouldn't.

There are a lot of files in my project so here's a brief rundown

The main loop calls a function L_Main() (it's also the same if this function is integrated into the main loop. L_Main() then calls L_Redraw() and L_EventLoop() (again, integrating the eventloop function into the main loop has no effect) L_EventLoop() handles event loop handling and sets a variable that L_Main() uses to call several other functions that do various things. However, even the main loop only runs when there is an event. It should run all the time, especially since there are no loops at all in L_EventLoop() and Default is set to return, and then L_Main() returns immediately after.

Offline Derron

  • Hero Member
  • *****
  • Posts: 1953
Re: Code only runs when there is an event
« Reply #1 on: April 09, 2019, 04:05:56 PM »
you use "WaitEvent" somewhere.

Also: if you use MaxGUI then you are into "event driven" programming.
to have done stuff more or less "often" (like in a game) then you might think about creating a timer - and to listen to ticks of this timer to then handle your "game logic".


check this out (example 2):
https://blitzmax.org/docs/en/api/brl/brl.timer/

bye
Ron