0

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:

  1. why the game window shows different size on different resolution monitors,
  2. and why the game runs at a very low speed on the internal monitor?
  3. Is that because of the monitor resolution?
  4. 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")
Bruce Hu
  • 1
  • 3
  • 1
    Please post your code: https://stackoverflow.com/help/mcve – skrx Oct 27 '18 at 20:35
  • Is 2880x1800 the native resolution of your monitor? – ChatterOne Oct 27 '18 at 20:45
  • `pygame.display.set_mode((width, height))` may not have the same pixel size as your computer. If you show us the code where the window size is being defined I can confirm this and post an answer as to how this is fixed. –  Oct 28 '18 at 13:11

0 Answers0