Hi guys,
Want to dev some games for the Gameshell, but having trouble with even the most basic of things.
I was following this link to get something simple going, and no matter what I do, any key quits the app, and I’m not sure why.
I was taking some key press ideas from Programming GameShell games with Python and the Arcade library and since I was unable to install Arcade on my Gameshell, I decided to go the Pygame route as it’s already installed by default.
FYI, what I did was create a test.py in the games folder, and created a .sh file in the Launcher folder called Test.sh which just runs python ~/games/test.py - this works as I can edit the python file in nano directly, save it, then just click the “Test” game on the launcher menu. Is this how you guys test/do things for the gameshell?
Basically, the problem is that if I press the Menu button, it quits as expected, but if I push any other key, it also quits, instead of moving the rectangle as per this code:
import pygame
successes, failures = pygame.init()
print("{0} successes and {1} failures".format(successes, failures))
screen = pygame.display.set_mode((720, 480))
clock = pygame.time.Clock()
FPS = 60 # Frames per second.
KEY_MENU = pygame.K_ESCAPE
KEY_UP = pygame.K_UP
KEY_DOWN = pygame.K_DOWN
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
# RED = (255, 0, 0), GREEN = (0, 255, 0), BLUE = (0, 0, 255).
rect = pygame.Rect((0, 0), (32, 32))
image = pygame.Surface((32, 32))
image .fill(WHITE)
while True:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == KEY_MENU:
quit()
elif event.key == KEY_UP:
rect.move_ip(0, 2)
elif event.key == KEY_DOWN:
rect.move_ip(0, -2)
screen.fill(BLACK)
screen.blit(image, rect)
pygame.display.update() # Or pygame.display.flip()
I feel that if I can’t get Pygame stuff working, I might resort to learning Love2D, as it is supported and installed too and can be run on other platforms as well.