- I want to know why I get an error in this code.
- I am trying to upload a character in JPG format and it gives me an error.
- I am using IDLE and it is python 3.7.3
import pygame
pygame.init() #Initialize the game
win = pygame.display.set_mode((1000,700)) # Sets the window size
pygame.display.set_caption("First Game") # Title of window in the string
*walkRight = [pygame.image.load('Person.JPG')]* # load image
x = 100
y = 690
width = 10
height = 10
vel = 5
isJump = False
jumpCount = 5 # timer for mid-air
left = False
right = False
run = True
while run:
pygame.time.delay(100) # waits for 100 miliseconds = 0.1 second
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] and x > vel: # left
x -= vel
if keys[pygame.K_RIGHT] and x < 500 - width - vel: # right
x += vel
if not(isJump): # not jumping
if keys[pygame.K_SPACE]:
isJump = True
else:
if jumpCount >= -5:
checker = 1 # positive jumpCount
if jumpCount < 0:
checker = -1 # negative jumpcount
y -= (jumpCount ** 2) * 0.5 * checker
jumpCount -= 1
else:
isJump = False # allows the player to jump again
jumpCount = 5 # how long it is in mid air
win.fill((255,255,255)) # Fills the screen black
pygame.draw.rect(win, (255, 0, 0), (x, y, width, height))
pygame.display.update() # updates the screen each time
pygame.quit()
Why does the place marked * give me an error?