Controller button held down

SGDK only sub forum

Moderator: Stef

Post Reply
teepo
Newbie
Posts: 9
Joined: Sun Feb 10, 2013 8:06 am

Controller button held down

Post by teepo » Sun Feb 10, 2013 11:48 am

Hi.. I'm a pretty new programmer and I'm new to sega genesis and game programming in general. I'm using sgdk

I want to know, how can you detect if a button is held down and constantly do something while it is held down. for instance moving a character right while the right button is held down?

I looked into the sgdk joypad handling source code and it says it updates controller state at each vblank period and only fires an event whenever a state change is detected.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sun Feb 10, 2013 4:47 pm

Hi,

You should look into the sample source code.
The cube flat example exactly do what you want to do to make the cube spinning faster or slower :

http://code.google.com/p/sgdk/source/br ... lat/main.c

The method you have to use is

Code: Select all

joyState = JOY_readJoypad(joy_number);
so it returns the current button state of the specified joystick.

teepo
Newbie
Posts: 9
Joined: Sun Feb 10, 2013 8:06 am

Post by teepo » Sun Feb 10, 2013 6:10 pm

Thanks :D

For some reason, looking through the samples escaped my mind completely.

Post Reply