AnythingMapping
AnythingMapping

Reputation: 377

Pygame multiple user inputs

I'm trying to develop a team based asteroids type game. Its going well except for the multiple user inputs to a single machine... Can anyone recommend a method for getting and updating 6 players using a single computer? is it even possible? at the moment I'm working with a couple of old XBox controllers and a keyboard and its almost working...

is it possible to add additional keyboards?

and would you arrange the code into one big get events function or is there a better way to check for user inputs at this scale?

Cheers,

Upvotes: 0

Views: 493

Answers (1)

john dikeman
john dikeman

Reputation: 61

I've never seen anyone try to connect multiple keyboards to an application, so I don't really think that it's possible, sadly. However, pygame does have a pretty rad Joystick module that you can use to initialize as many controllers as you like. I would recommend making a Player object for each one, then calling joystickObject.getAxis(axisIndex) every loop to get the data. You'll just have to figure out the axis/button indexes for the controller. I'm currently working on a project with multiple controllers, so let me know if you need any specific help!

Upvotes: 1

Related Questions