AB,
I always advocate the game loop, but experimentation is fun so try different things.
Reasons:
1] For complex event driven fast moving games, all the action takes place in one ordered loop - much easier to debug
2] Events can occur at any time and may also be running at the same time using the same variables - chaos
3] The main UI thread may not be updated while running in an event thread
4] If events keep coming faster than they take to complete they can stack up
Compare these 2 programs
When there are multiple events, potentially firing at the same time using the same variables it can get complicated, so I think the game loop makes things simpler, even though for a very small program it looks like added complexity. There are cases where it doesn't really matter - like button presses.
Main thing is try it out whatever way you like and be prepared to change - I tend to write little prototypes to test ideas out.
I always advocate the game loop, but experimentation is fun so try different things.
Reasons:
1] For complex event driven fast moving games, all the action takes place in one ordered loop - much easier to debug
2] Events can occur at any time and may also be running at the same time using the same variables - chaos
3] The main UI thread may not be updated while running in an event thread
4] If events keep coming faster than they take to complete they can stack up
Compare these 2 programs
Code:
ball = Shapes.AddEllipse(20,20)
GraphicsWindow.MouseMove = OnMouseMove
Sub OnMouseMove
x = GraphicsWindow.MouseX
y = GraphicsWindow.MouseY
Shapes.Animate(ball,x-10,y-10,100)
Program.Delay(100)
EndSub
Code:
ball = Shapes.AddEllipse(20,20)
GraphicsWindow.MouseMove = OnMouseMove
While("True")
If (mouseMove) Then
x = GraphicsWindow.MouseX
y = GraphicsWindow.MouseY
Shapes.Animate(ball,x-10,y-10,100)
Program.Delay(100)
mouseMove = ""
EndIf
EndWhile
Sub OnMouseMove
mouseMove = "True"
EndSub
When there are multiple events, potentially firing at the same time using the same variables it can get complicated, so I think the game loop makes things simpler, even though for a very small program it looks like added complexity. There are cases where it doesn't really matter - like button presses.
Main thing is try it out whatever way you like and be prepared to change - I tend to write little prototypes to test ideas out.