Hi, I am encountering a huge problem , when using waitevent() , does this command cause a pause in the program? It seems that since my main game loop is inside of a function, my object (a turtle) only moves when a mouse i moved, and all movement is ceased when I dont do anything. Does it sound like waitevent is the problem here? Here is my code:
Const screenWidth = 800 Const screenHeight = 600 ;window setup window = CreateWindow ("Title",0,0,screenWidth, screenHeight) panel = CreatePanel (0,0,screenWidth, screenHeight,window) canvas = CreateCanvas (0,0,screenWidth, screenHeight,panel) SetBuffer CanvasBuffer (canvas) SetGadgetLayout panel,1,2,1,2 SetGadgetLayout canvas,1,2,1,2 menu = WindowMenu (window) menu_game = CreateMenu ("Game",0,menu) menu_start = CreateMenu ("Home", 5, menu_game) menu_blank = CreateMenu ("",0,menu_game) menu_begin = CreateMenu ("Begin",10,menu_game) menu_time = CreateMenu ("Time",20,menu) menu_music = CreateMenu ("Music",40,menu) menu_help = CreateMenu ("Help",50,menu) menu_howTo = CreateMenu ("How to play",51,menu_help) menu_blank = CreateMenu ("",0,menu_help) menu_about = CreateMenu ("About",52,menu_help) UpdateWindowMenu window ;global Global timer = MilliSecs() Global totalframes = 32 Global speed Global animspeed = 200 Global turtle = LoadAnimImage ("animatedTurtle.png",128,64,0,totalframes) Global turtlespeed = 5 Global game_mode = 0 ;images Global splashScreen = LoadImage ("mainscreen.png") Global background = LoadImage ("background.png") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; MAIN LOOP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; While Not KeyHit(1) Cls id = WaitEvent () Select id Case $803 End Case $1001 ed = EventData () Select ed Case 5 game_mode = 0 SetGadgetShape panel,0,0,screenwidth, screenheight SetGadgetShape canvas,0,0,screenwidth, screenheight Case 10 game_mode = 1 SetGadgetShape panel,0,0,screenwidth, screenheight-200 SetGadgetShape canvas,0,0,screenwidth, screenheight End Select End Select If game_mode = 1 Then gameLoop() If game_mode = 0 Then splashScreen() SetStatusText (window,"X: "+MouseX()+" Y: "+MouseY()) FlipCanvas (canvas) Wend ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Function splashScreen() DrawBlock splashScreen,0,0 End Function Function gameLoop() DrawBlock background,0,0 DrawImage turtle,ImageXHandle(turtle)+turtleSpeed,320,speed If MilliSecs() > timer + animspeed speed = speed+ 1 turtlespeed = turtlespeed + 1 If speed = totalframes Then speed = 0 timer = MilliSecs() EndIf End Function