I have been trying to make a game controller that uses gpiozero on pycharm that is compatible with pygame
this is the code for main:
import pygame
import controller as con
pygame.init()
fps = pygame.time.Clock()
pygame.init()
screen = pygame.display.set_mode((1000, 1000))
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if con.right_b_pressed():
print('its working now!')
pygame.display.update()
fps.tick(30)
for controller:
`
import os
os.environ['GPIOZERO_PIN_FACTORY'] = os.environ.get('GPIOZERO_PIN_FACTORY', 'mock')
from gpiozero import Button
def right_b_pressed():
rightbutton = Button(27)
if rightbutton.when_held == 0:
return True
else:
return False
def left_b_pressed():
leftbutton = Button(17)
if leftbutton.when_held() == 0:
return True
else:
return False
def up_b_pressed():
upbutton = Button(20)
if upbutton.when_held() == 0:
return True
else:
return False
I was expecting it to print ‘its working now’ but has not