Mar-07-2019, 03:41 PM
(This post was last modified: Mar-07-2019, 03:41 PM by ghost0fkarma.)
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)Hello, I would like to make a game where objects(enemy_bullet) come down from the top of the screen and the player(boatIMG) has to dodge them. I'm very confused on how to go about this. Any tips and tricks are appreciated!
