Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- pygame.init()
- white = (255,255,255)
- black = (0,0,0)
- red = (255,0,0)
- gameDisplay = pygame.display.set_mode((800,600))
- pygame.display.set_caption('Slither')
- gameExit = False
- lead_x = 300
- lead_y = 300
- lead_x_change = 0
- lead_y_change = 0
- clock = pygame.time.Clock()##clock
- while not gameExit:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- gameExit = True
- if event.type == pygame.KEYDOWN:
- if event.key == pygame.K_LEFT:
- lead_x_change = -10
- if event.key == pygame.K_RIGHT:
- lead_x_change = 10
- if event.key == pygame.K_UP:
- lead_y_change = -10
- if event.key == pygame.K_DOWN:
- lead_y_change = 10
- if event.type == pygame.KEYUP:
- if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
- lead_x_change = 0
- if event.key == pygame.K_UP or event.key == pygame.K_DOWN:
- lead_y_change = 0
- lead_x += lead_x_change
- lead_y += lead_y_change
- gameDisplay.fill(white) ## color de el fondo de pantalla
- pygame.draw.rect(gameDisplay, black, [lead_x,lead_y,10,10]) ##dibujar un rectangulo
- pygame.display.update()## despues de tener todos los ajustes graficos renderizamos
- clock.tick(15)##clock
- pygame.quit()
- quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement