pythonpgzero

Can you connect a controller to Pygame Zero?


I have programming as a subject in school, and this is our last project of the semester. For our last task we are going to use replit.com, which use PygameZero. Which from my understanding, is a easier version of Pygame, which again is a version of python more focused on making games (correct me if im wrong).

I want to make a Street Fighter type game, and because of that i really want to use two controller for it (because i want a PvP game). I have searched, but the turorials i find are for Pygame, and i can't find any for Pygame Zero. Either that, or it is some semi-advanced stuff that i don't understand. If anyone knows how to connect controllers to Pygame Zero, it would help a ton!

And if controllers matter, i have Xbox One controllers, a switch pro controller and a gamecube controller (whith a gamecube to usb adapter). Allthough i mainly want to use the xbox controllers if thats possible.

thanks so much in advance!

PS: Im relativly new to programming, so i would really apreciate if you could dumb down your answers to the point that i can understand it!


Solution

  • Pygame Zero does support controllers and PS4 and Xbox One controllers both work.

    This book is a great resource for beginners in Python who want to make games in Pygame Zero. It also has some more information on joysticks here and here.

    Also regarding Sembei Norimaki's comment, you basically have to try and see if the code in sixAxis.py at that website works with your controller. See the bottom of the file and edit it to see if you can get it to work.