I've been trying to code a game where a turkey has to dodge bullets, this is a 2d game so it only goes up, down, left, and right. I tried putting in the logic of the game "asteroids" where the asteroids spawn randomly but still no luck.
import pygame
bakcground = pygame.image.load("Bulletspix/Grass BG.png")
PlayerTurk = pygame.image.load ("Bulletspix/turkey.png")
playerTurkx = 450
playerTurky = 800
vel = 1
pygame.display.set_caption("game")
screen = pygame.display.set_mode((800, 900))
playerTurkx = 350
playerTurky = 350
vel = 1
def player():
screen.blit(PlayerTurk, (playerTurkx , playerTurky))
running = True
while running:
#Oprion of quitting
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Background
screen.fill((0, 0, 0))
screen.blit(bakcground, (0, 0))
#movement
Input = pygame.key.get_pressed()
if Input[pygame.K_LEFT] and playerTurkx >0:
playerTurkx -= vel
if Input[pygame.K_RIGHT]and playerTurkx <730:
playerTurkx += vel
if Input[pygame.K_UP]and playerTurky >0:
playerTurky -= vel
if Input[pygame.K_DOWN]and playerTurky <500:
playerTurky += vel
player()
pygame.display.update()
pygame.quit()