I'm a newbie of python. Currently learning Python with Eric Matthes' 《Python Crash Course》. In the book, there is a project to build a game called 'Alien Invasion' with Python and pygame module.
The game window size was defined as 1200*800.
When I run the game in macbookpro (screen resolution is 2880 x 1800), the game window size is apparently larger than 1200*800. But when I run it on an external monitor (connected to the same macbookpro), the window size looks like 1200*800.
Mose puzzling, though the game runs smoothly on the external monitor, it runs extremely slow (unusually poor performance) on the macbookpro internal monitor.
Could anyone please help me with:
- why the game window shows different size on different resolution monitors,
- and why the game runs at a very low speed on the internal monitor?
- Is that because of the monitor resolution?
- How can I fix this problem?
Thanks!
My Code in class Setting:
class Settings():
def __init__(self):
self.screen_width = 1200
self.screen_height = 800
self.bg_color = (230, 230, 230)
My Code to call the Settings class:
import sys
import pygame
from pygame.sprite import Group
from settings import Settings
from ship import Ship
import game_functions as gf
from game_stats import GameStats
from button import Button
from scoreboard import Scoreboard
from sound import Sound
def run_game():
pygame.init()
ai_settings = Settings()
sound = Sound()
screen = pygame.display.set_mode(
(ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")