My code consists of a joystick PyGame module that updates the variable self.mmcount when the left stick's vertical axis is moved. My issue is that it updates the mmcount variable too frequently that it's very hard to get to a specific integer. I presume the solution is to add a delay to the IF statements. For example, every two seconds check if the left stick is pointing up.
These are the IF statements that update the self.mmcount variable:
if joy1.get_button(3) == 1:
self.mmcount -= 1
if joy1.get_button(2) == 1:
self.mmcount += 1
Entire code:
class Menu:
def run(self):
self.intro = True
self.clock = clock
self.mmcount = 1
while self.intro:
self.get_joys()
def get_joys(self):
if joy1.get_button(3) == 1:
self.mmcount -= 1
elif joy1.get_button(2) == 1:
self.mmcount += 1
if self.mmcount > 3:
self.mmcount = 3
elif self.mmcount < 1:
self.mmcount = 1
m = Menu()
while True:
m.run()