Amon
Member
- Joined
- Nov 19, 2018
- Messages
- 88
Hi guys.
I'm getting input jitters when holding keydown. Best way to describe it is with this code. Code is bare minimum. The image jitters when keydown (key) is pressed and when checking it using DrawText("" + KeyDown(KEY_LEFT), 0, 0), it shows it switching from 1 to 0 to 1 etc.
[edit] Ok, it's not a bug. It's my keyboard. After unplugging it and plugging it back in the issue has not returned. I guess I'll be getting new keyboard tomorrow.
I'm getting input jitters when holding keydown. Best way to describe it is with this code. Code is bare minimum. The image jitters when keydown (key) is pressed and when checking it using DrawText("" + KeyDown(KEY_LEFT), 0, 0), it shows it switching from 1 to 0 to 1 etc.
[edit] Ok, it's not a bug. It's my keyboard. After unplugging it and plugging it back in the issue has not returned. I guess I'll be getting new keyboard tomorrow.
Cerberus:
Strict
Import mojo
Function Main:Int()
New Game()
Return 0
End
Class Game Extends App
Field x:float
Field y:float
Field speed:float
Field image:Image
'summary:The OnCreate Method is called when mojo has been initialized and the application has been successfully created.
Method OnCreate:Int()
'Set how many times per second the game should update and render itself
SetUpdateRate(60)
image = LoadImage("yellowtile.png", 1)
speed = 3
x = 400
y = 300
Return 0
End
'summary: This method is automatically called when the application's update timer ticks.
Method OnUpdate:Int()
If KeyDown(KEY_LEFT)
x -= 2
EndIf
If KeyDown(KEY_RIGHT)
x += 2
EndIf
Return 0
End
'summary: This method is automatically called when the application should render itself, such as when the application first starts, or following an OnUpdate call.
Method OnRender:Int()
Cls()
DrawImage(image, x, y, 0)
DrawText("KEYLEFT " + KeyDown(KEY_LEFT), 0, 0)
DrawText("KEYRIGHT " + KeyDown(KEY_RIGHT), 0, 10)
Return 0
End
'summary: This method is called instead of OnRender when the application should render itself, but there are still resources such as images or sounds in the process of being loaded.
Method OnLoading:Int()
Return 0
End
'summary: This method is called when the application's device window size changes.
Method OnResize:Int()
Return 0
End
'#REGION Code to handle susped status of the game goes here
'summary: OnSuspend is called when your application is about to be suspended.
Method OnSuspend:Int()
Return 0
End
'summary: OnResume is called when your application is made active again after having been in a suspended state.
Method OnResume:Int()
Return 0
End
'#END REGION
'#REGION Code to handle game closing goes here:
'summary: This method is called when the application's 'close' button is pressed.
Method OnClose:Int()
Return Super.OnClose()
End
'summary:This method is called when the application's 'back' button is pressed.
Method OnBack:Int()
Return Super.OnBack()
End
'#END REGION
End
Last edited: