08-10-2022, 03:03 PM
(This post was last modified: 08-10-2022, 03:07 PM by James D Jarvis.)
I like in-program generated graphics.
I fiddled with it for a couple seconds and changed the key handling code in the navigation to only use one call to _keyhit to handle the direction moved instead of 4 calls to _keydown. Not sure if it saves many (if any) cycles but it structures things to make room for collision testing later if you want to add any and it eliminates the need for if then's that don't relate to user input.
I fiddled with it for a couple seconds and changed the key handling code in the navigation to only use one call to _keyhit to handle the direction moved instead of 4 calls to _keydown. Not sure if it saves many (if any) cycles but it structures things to make room for collision testing later if you want to add any and it eliminates the need for if then's that don't relate to user input.
Code: (Select All)
kd = _KeyHit
Select Case kd
Case keyUP
player.y = player.y - playerSpeed: t = t + 1
If player.y < 0 Then player.y = 0
Case keyDOWN
player.y = player.y + playerSpeed: t = t + 1
If player.y > _Height(map) Then player.y = _Height(map)
Case keyLEFT
player.x = player.x - playerSpeed: t = t + 1
If player.x < 0 Then player.x = 0
Case keyRIGHT
player.x = player.x + playerSpeed: t = t + 1
If player.y > _Height(map) Then player.y = _Height(map)
Case Esc
End
End Select