I'm new to programming, so I might be asking a silly question. I'm trying to make a game from "Python Crash Course", but when I am trying to run it, the graphics don't show. I tried to insert different print-messages, and can see that my loop is running. I reinstalled pygame, to make sure that it is not what is causing me problems.
I ran the script from visual studio code, from IDLE and the terminal, without any luck. I'm using a macbook with catalina. I sent it to my friend, who can run it without any problems on his linux system.
In VSC I can see, when I hover the mouse over screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
, that it says display: MissingModule
, but I can't seem to figure out what this means.
import pygame
from settings import Settings
from ship import Ship
import game_functions as gf
def run_game():
"""Initialize pygame, settings and screen object."""
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
# Make a ship
ship = Ship(screen)
# Start the main loop for the game.
while True:
gf.check_events(ship)
ship.update()
gf.update_screen(ai_settings, screen, ship)
# Make the most recently drawn screen visible.
pygame.display.flip()
run_game()
I get this traceback when I stop the program:
^CTraceback (most recent call last):
File "/Users/camilla/Desktop/Projekter/AlienInvasion/alien_invasion.py", line 28, in <module>
File "/Users/camilla/Desktop/Projekter/AlienInvasion/alien_invasion.py", line 23, in run_game
File "/Users/camilla/Desktop/Projekter/AlienInvasion/game_functions.py", line 26, in update_screen
screen.fill(ai_settings.bg_color)