Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 no screen is generated
#1
hello I’ve got this issue. I run the program I dont see the new screen that is supposed to be generated although program runs. I’ve googled for almost 2hrs and tried bunch of stuff but none of them worked or maybe I've placed them wrongly. I have W10 and newest Python and I'm a complete noob.

# first PyGame
 
 
# přístup do knihovny PyGame
import pygame
 
import pygame.display
pygame.display.init()
 
# velikost okna
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 800
SCREEN_TITLE = "Krosovka"
 
# barvy RGB
WHITE_COLOR = (255, 255, 255)
BLACK_COLOR = (0, 0, 0)
# Clock k aktualizaci eventů a frames
clock = pygame.time.Clock()
pygame.font.init()
font = pygame.font.SysFont('comicsans', 75)
 
class Game:
 
 
 
    # FPS
    TICK_RATE = 60
 
 
    def __init__(self, title, width, height):
        self.title = title
        self.width = width
        self.height = height
 
       
        # vytvoří okno dle specifikace
        self.game_screen = pygame.display.set_mode((width, height))
        # vybarví okno bíle
        self.game_screen.fill(WHITE_COLOR)
        pygame.display.set_caption(title)
       
    # hlavní herní LOOP
    def run_game_loop(self):
        is_game_over = False
 
is_game_over = False
 
while not is_game_over:
 
        # LOOP, který kontroluje eventy
        # Myš, klávesnice...
        for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    is_game_over = False
                         
                   
                print(event)
 
   
   
# updatuje GRAFIKU
pygame.display.update()
       
# zapnutí FPS
clock.tick(TICK_RATE)
 
 
 
new_game = Game(SCREEN_TITLE, SCREEN_WIDTH, SCREEN_HEIGHT)
new_game.run_game_loop()
 
 
 
 
 
 
 
 
 
pygame.quit()
 
 
    # nakreslí čtverec (kde, barva, x, y, šířka, výška
    ## pygame.draw.rect(game_screen, BLACK_COLOR, [350, 350, 100, 100])
    # nakreslí kruh (kde, barva, x, y, (poloměr))
    ## pygame.draw.circle(game_screen, BLACK_COLOR, (400, 300), 50)
 
    # umístění obrázku
    ## game_screen.blit(player_image, (375, 375))
 
    # nahrát obrázek
    ## player_image = pygame.image.load("player.png")
    # zvětšení obrázku
    ## player_image = pygame.transform.scale(player_image, (50, 50))
thanks for your help
Quote
#2
you had your while loop dedented not within the run_game_loop method properly. You can also just use pygame.init() to initialize every module.

# first PyGame
 
 
# přístup do knihovny PyGame
import pygame

pygame.init()
 
#import pygame.display
#pygame.display.init()
 
# velikost okna
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 800
SCREEN_TITLE = "Krosovka"
 
# barvy RGB
WHITE_COLOR = (255, 255, 255)
BLACK_COLOR = (0, 0, 0)
# Clock k aktualizaci eventů a frames
clock = pygame.time.Clock()
#pygame.font.init()
font = pygame.font.SysFont('comicsans', 75)
 
class Game:
 
 
 
    # FPS
    TICK_RATE = 60
 
 
    def __init__(self, title, width, height):
        self.title = title
        self.width = width
        self.height = height
 
       
        # vytvoří okno dle specifikace
        self.game_screen = pygame.display.set_mode((width, height))
        # vybarví okno bíle
        self.game_screen.fill(WHITE_COLOR)
        pygame.display.set_caption(title)
       
    # hlavní herní LOOP
    def run_game_loop(self):
        is_game_over = False
 
        is_game_over = False
         
        while not is_game_over:
         
            # LOOP, který kontroluje eventy
            # Myš, klávesnice...
            for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                        is_game_over = True
                             
                       
                    print(event)
         
           
           
            # updatuje GRAFIKU
            pygame.display.update()
               
            # zapnutí FPS
            clock.tick(60)
 
 
 
new_game = Game(SCREEN_TITLE, SCREEN_WIDTH, SCREEN_HEIGHT)
new_game.run_game_loop()
 
 
 
 
 
 
 
 
 
pygame.quit()
 
 
    # nakreslí čtverec (kde, barva, x, y, šířka, výška
    ## pygame.draw.rect(game_screen, BLACK_COLOR, [350, 350, 100, 100])
    # nakreslí kruh (kde, barva, x, y, (poloměr))
    ## pygame.draw.circle(game_screen, BLACK_COLOR, (400, 300), 50)
 
    # umístění obrázku
    ## game_screen.blit(player_image, (375, 375))
 
    # nahrát obrázek
    ## player_image = pygame.image.load("player.png")
    # zvětšení obrázku
    ## player_image = pygame.transform.scale(player_image, (50, 50))
Quote
#3
HOLY hell thank you so much!!!
metulburr likes this post
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [PyGame] pygame.draw.rect function stretches across the screen instead of moving BubblesTheGiraffe 2 337 Jun-11-2019, 08:32 PM
Last Post: metulburr
  How to get screen to clear? mzmingle 5 763 Oct-10-2018, 12:36 PM
Last Post: metulburr
  Make a screen appear without using import ctrembla 10 1,251 Sep-29-2018, 07:52 AM
Last Post: DeaD_EyE
  [PyGame] How to stop the sprite's movement when it touches the edges of the screen? mrmn 5 2,006 May-13-2018, 06:33 PM
Last Post: mrmn
  [PyGame] Copying the Screen (PyGame) Zman350x 4 1,690 Feb-11-2017, 08:26 PM
Last Post: Zman350x
  [PyGame] text-to-screen help Zman350x 9 2,779 Jan-13-2017, 12:27 AM
Last Post: Zman350x

Forum Jump:


Users browsing this thread: 1 Guest(s)