Mar-07-2019, 03:41 PM
(This post was last modified: Mar-07-2019, 03:41 PM by ghost0fkarma.)
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 |
import pygame, sys from pygame. locals import * pygame.init() fps = 30 fpsClock = pygame.time.Clock() DisplaySurface = pygame.display.set_mode(( 640 , 480 )) pygame.display.set_caption( "Boat Game" ) white = ( 255 , 255 , 255 ) boatIMG = pygame.image.load( "boatIMG.png" ) backgroundIMG = pygame.image.load( "water_background.png" ) heartIMG = pygame.image.load( "heart.png" ) enemy_bullet = pygame.image.load( "bullet_enemy.png" ) boatx = 400 boaty = 400 while True : for event in pygame.event.get(): if event. type = = QUIT: pygame.quit() sys, exit() if event. type = = pygame.KEYDOWN: if event.key = = pygame.K_LEFT: boatx - = 5 elif event.key = = pygame.K_RIGHT: boatx + = 5 elif event.key = = pygame.K_UP: boaty - = 5 elif event.key = = pygame.K_DOWN: boaty + = 5 if boatx = = 120 : boatx = 125 elif boatx = = 460 : boatx = 455 elif boaty = = 300 : boaty = 305 elif boaty = = 410 : boaty = 405 DisplaySurface.blit(backgroundIMG, [ 0 , 0 ]) DisplaySurface.blit(boatIMG, (boatx, boaty)) pygame.display.update() fpsClock.tick(fps) |