added 3 surfaces with auto switching
This commit is contained in:
35
surface_switching_test/main.py
Normal file
35
surface_switching_test/main.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import pygame
|
||||
from surface_switching_test.surfaces import sf_1, sf_2, sf_3
|
||||
|
||||
WINDOW_SIZE = (800, 600)
|
||||
|
||||
VALID_SURFACES = [
|
||||
'sf_1',
|
||||
'sf_2',
|
||||
'sf_3'
|
||||
]
|
||||
|
||||
|
||||
def main():
|
||||
pygame.init()
|
||||
|
||||
window = pygame.display.set_mode(WINDOW_SIZE)
|
||||
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
running = True
|
||||
surface = globals()['sf_1'].Surface(WINDOW_SIZE)
|
||||
while running:
|
||||
clock.tick(15)
|
||||
surface.update()
|
||||
window.blit(surface, surface.get_rect())
|
||||
|
||||
if not surface.running:
|
||||
next_surface = surface.next_surface
|
||||
if next_surface not in VALID_SURFACES:
|
||||
raise Exception('Given surface is not listed in valid surfaces!')
|
||||
surface = globals()[next_surface].Surface(WINDOW_SIZE)
|
||||
|
||||
pygame.display.flip()
|
||||
|
||||
pygame.quit()
|
||||
Reference in New Issue
Block a user