GUVI
Back

I've written this code but it doesn't seems to work. Can anyone help?

Created 2 years ago
42 Views
1 Comments
VarunjvSBUs
@VarunjvSBUs
VarunjvSBUs
@VarunjvSBUsProfile is locked. Login

import pygame, sys

from pygame.locals import*

catx =10

caty =10

screen = 0

def myquit():

pygame.quit()

sys.exit()

def check_inputs(events):

global catx, caty, screen

for event in events :

if event.type == QUIT:

quit()

else:

if event.type == KEYDOWN:

if event.key == K_ESCAPE:

myquit()

elif event.key == K_LEFT:

catx -= 5

print("Move Rect LEFT")

elif event.key == K_RIGHT:

catx +=5

print("Move Rect RIGHT")

else:

print(event.key)

screen.fill((0,0,0))

pygame.draw.rect(screen,(255,255,255),(catx,50,50,10))

pygame.display.update()

def main():

global screen

pygame.init()

window = pygame.display.set_mode((600,480))

pygame.display.set_caption("Slither.exe-The snake game")

screen = pygame.display.get_surface()

pygame.display.update()

while True:

check_inputs(pygame.event.get())

main()

Comments
Please login to comment.
 
Powered by habitate.io Habitate