GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Source-Code-from-Tutorials/Pygame/14_PythonGameDevelopment.py at master · vidgit/Source-Code-from-Tutorials Expand file tree/ Copy path14_PythonGameDevelopment.pyMore file actions 88 lines (52 loc) · 1.69 KB / Copy path14_PythonGameDevelopment.pyFile metadata and controls88 lines (52 loc) · 1.69 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 import pygame import time pygame.init() white = (255,255,255) black = (0,0,0) red = (255,0,0) display_width = 800 display_height = 600 gameDisplay = pygame.display.set_mode((display_width,display_height)) pygame.display.set_caption('Slither') gameExit = False lead_x = display_width/2 lead_y = display_height/2 lead_x_change = 0 lead_y_change = 0 clock = pygame.time.Clock() block_size = 10 FPS = 30 font = pygame.font.SysFont(None, 25) def message_to_screen(msg,color): screen_text = font.render(msg, True, color) gameDisplay.blit(screen_text, [display_width/2, display_height/2]) 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 = -block_size lead_y_change = 0 elif event.key == pygame.K_RIGHT: lead_x_change = block_size lead_y_change = 0 elif event.key == pygame.K_UP: lead_y_change = -block_size lead_x_change = 0 elif event.key == pygame.K_DOWN: lead_y_change = block_size lead_x_change = 0 if lead_x >= display_width or lead_x < 0 or lead_y >= display_height or lead_y < 0: gameExit = True lead_x += lead_x_change lead_y += lead_y_change gameDisplay.fill(white) pygame.draw.rect(gameDisplay, black, [lead_x,lead_y,block_size,block_size]) pygame.display.update() clock.tick(FPS) message_to_screen("You Lose, go outside you fool", red) pygame.display.update() time.sleep(2) pygame.quit() quit() |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |