gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Going beyond the gba default game buttons?

#59266 - bmnb1234 - Sun Oct 30, 2005 9:27 pm

Hi
I am working a game project that requires me to go beyond the gba default game buttons
is it possible to have single tap normal fire but hold a key and get a enable a second repose. I now this old system but in commando on the Atari 2600 it fired normal shots if you taped the key quickly but when you held down the key it fired a grenade. Do you think it is possible on this gba? Any one got ideas where I should start?

Thank you for your time!
Jason

#59270 - tepples - Sun Oct 30, 2005 10:00 pm

It's the same as handling autorepeat.

Make an array of 10 elements, one for each button. For each frame, for each button: If the button is not pressed, set the element to 0. Otherwise, if the element is less than its maximum value, add 1 to the element.

Then in the game logic, if the value of A is 1 then shoot, and if the value of A is 30 (or so) then throw a grenade.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#59428 - bmnb1234 - Tue Nov 01, 2005 8:20 pm

Thanks I must have overlooked it!

#63427 - falvarez - Tue Dec 13, 2005 1:10 am

tepples wrote:

Then in the game logic, if the value of A is 1 then shoot, and if the value of A is 30 (or so) then throw a grenade.


I guess you mean that, in the game logic, you check the value when the button is released and shoot or throw the grenade depending on that value.

Checking when a button is pressed or released is easy :-).

Best regards.