I'm trying to build a snake game in my Mac using Python3 and Pygame, but when I run the game with python3 snakegame.py, the app called Python just keeps jumping up and down on the desktop (I assume loading to open), but it never does open. I'm not sure if I have to open it with Python Launcher or something else. Thank you! Here is my code if you need it:
import pygame
def drawGrid(w, rows, surface):
sizeBtwn = w // rows
x = 0
y = 0
for l in range(rows):
x = x + sizeBtwn
y = y + sizeBtwn
pygame.draw.line(surface, (255,255,255), (x,0),(x,w))
pygame.draw.line(surface, (255,255,255), (0,y),(w,y))
def redrawWindow(surface):
global rows, width
surface.fill((0,0,0))
drawGrid(width,rows, surface)
pygame.display.update()
def main():
global width, rows
width = 500
rows = 20
win = pygame.display.set_mode((width, width))
#s = snake((255, 0, 0), (10, 10))
flag = True;
clock = pygame.time.Clock()
while flag == True:
pygame.time.delay(50)
clock.tick(10)
redrawWindow(win)
pass
main()