Hey all. I'm working on a prototype for a shooter, and it has aimable shooting. Here's the code block that handles inputs.
throw.x = 0
throw.y = 0
if throw.x
= 0 and throw.y
= 0 then throw.x
= 1
spacepress = true
call spawn_shot
(0, throw.x
, throw.y
)
arrow() just contains the ASCII arrow key data. The arrow key section acts like a joystick and respects held inputs to aim 8-way, with "neutral" position resulting in aiming to the right by default (sidescroller like Gradius). I have an aiming indicator and this is behaving properly.
What's unusual is that this IS working for shooting in all of the 8-way input directions... except up-left. It will aim that way, but the spacebar isn't causing a shot to spawn. There is shot to ship collision, but every shot carries the index of the ship that created it - that's what the first parameter "0" is in spawn_shot, and the collision routine ignores matching ships and shots to avoid friendly fire, so the shot isn't immediately hitting the player's ship here.
EDIT: This is really weird. Further bug testing showed that only certain combinations of three keys do not play nice with _keydown. Specifically, it doesn't like up, left, and space together. When I held left, then added holding space, then pressed up, the aiming indicator did not move to aiming up-left.