I'm new to programing and I need help to move my player (image) to left and right (hopefully with keybindings)
I really don't know what I'm doing and I just need help, please help
Here's my code so far:
import pygame
# Intialize the pygame
pygame.init()
# Resulution?
screen = pygame.display.set_mode((800, 600))
# Title and Logo
pygame.display.set_caption("Båtisens Herre")
icon = pygame.image.load('img.png')
pygame.display.set_icon(icon)
#Background
background = pygame.image.load("bakgrunn.png")
# Player
playerImg = pygame.image.load('King Arthur2.png')
playerX = 100
playerY = 200
def player(x, y):
screen.blit(playerImg, (x, y))
#game loop
running = True
while running:
# RGB (red, green blue)
screen.fill((248, 58, 226))
playerY -=0
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
#Background(2)
screen.blit(background, (0, 0,))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
player(playerX, playerY)
pygame.display.update()