I've been following along with the pygame project in 'Python Crash Course.' Copying the exact code because I am very new to python. When I run my code, the game window opens up, and the image appears in the correct initial place. I cannot get the image to move as it is supposed to. When I use the code that is commented out in the while loop to move the image, it works. However, as I continue to follow the steps in the book, it moves that functionality into separate files that are imported into the main file. I have copied it exactly, but the image will not move.
import sys
import pygame
from settings import Settings
from ship import Ship
import game_functions as gf
def run_game():
# main game loop
ai_settings = Settings()
pygame.init()
screen = pygame.display.set_mode((ai_settings.screen_width,
ai_settings.screen_height))
ship = Ship(screen)
pygame.display.set_caption("Alien Invasion!")
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
# elif event.type == pygame.KEYDOWN:
# if event.key == pygame.K_RIGHT:
# ship.rect.centerx += 1
elif event == pygame.KEYDOWN:
if event.key == pygame.K_RIGHT:
ship.moving_right = True
elif event == pygame.KEYUP:
if event.key == pygame.K_RIGHT:
ship.moving_right = False
gf.check_events(ship)
ship.update()
gf.update_screen(ai_settings, ship, screen)
run_game()