My son and I want to create a little car racing game. If I press the "arrow up" key the car should drive "forwards" and if LEFT oder RIGHT is pressed (simultaneously) the car should rotate accordingly. So I tried this:
Code: Select all
...
Function rotateCar(direction)
DebugPrint("rotateCar")
EndFunction
Function moveTrack(speed)
DebugPrint("moveTrack")
EndFunction
Function p_HandlerFunc(msg)
Switch(msg.action)
Case "OnKeyDown":
If msg.key = "LEFT" Then rotateCar("left")
If msg.key = "RIGHT" Then rotateCar("right")
If msg.key = "UP" Then moveTrack(1)
If msg.key = "DOWN" Then moveTrack(-1)
EndSwitch
EndFunction
Repeat
WaitEvent
Forever
What is the best way to this situation?
Thanks in advance!