Jul-16-2020, 08:39 AM
(This post was last modified: Jul-16-2020, 08:39 AM by KieranPage.)
Hi ive recently started coding something in pygame and have been following along with a set of tutorial but recently whenever you hover over the close button in the pygame window it just freaks out and closes I have recently converted it from python to visual basic
If it helps here is my code:
If it helps here is my code:
import pygame as pg import random from Settings import * class Game: def __init__(self): #Initialases Game window pg.init() pg.mixer.init() self.screen= pg.display.set_mode ((width, height)) pg.display.set_caption(Title) self.clock=pg.time.Clock() self.running = True def new (self): #Starts game upon death self.all_sprites = pg.sprite.Group() self.run def run(self): #Game Loop self.playing = True while self.playing: self.clock.tick (fps) self.events() self.update() self.draw() def update(self): #Game loop Update self.all_sprites.update() def events(self): #Game loop events for event in pg.event.get(): if event.type == pg.QUIT: if self.playing: self.playing = False self.running=False def draw(self): #Game loop draw self.screen.fill(Black) self.all_sprites.draw(self.screen) pg.display.flip() def show_start_screen(self): #Show The start Screen pass def show_go_screen(self): #Shows The Game Over Screen pass g = Game() g.show_start_screen() while g.running: g.new() g.show_go_screen() pg.quit() #And here is my Settings Script That it imports Title = "Platform Adventure" width = 480 height = 600 fps = 60 #Colours White = (255, 255, 255) Black = (0, 0, 0) Red = (255, 0, 0) Light_Blue = (0, 255, 255)