added 3 surfaces with auto switching
This commit is contained in:
0
surface_switching_test/surfaces/__init__.py
Normal file
0
surface_switching_test/surfaces/__init__.py
Normal file
0
surface_switching_test/surfaces/objects/__init__.py
Normal file
0
surface_switching_test/surfaces/objects/__init__.py
Normal file
12
surface_switching_test/surfaces/objects/text.py
Normal file
12
surface_switching_test/surfaces/objects/text.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import pygame.font
|
||||
import os
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class RegularText:
|
||||
def __init__(self, text):
|
||||
font = pygame.font.Font(SCRIPT_DIR + '/../resources/Tuffy_Bold.ttf', 32)
|
||||
self.surface = font.render(text, True, (0, 0, 0))
|
||||
self.rect = self.surface.get_rect()
|
||||
|
BIN
surface_switching_test/surfaces/resources/Tuffy_Bold.ttf
Normal file
BIN
surface_switching_test/surfaces/resources/Tuffy_Bold.ttf
Normal file
Binary file not shown.
21
surface_switching_test/surfaces/sf_1.py
Normal file
21
surface_switching_test/surfaces/sf_1.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import pygame
|
||||
from surface_switching_test.surfaces.objects import text as surface_text
|
||||
|
||||
class Surface(pygame.Surface):
|
||||
def __init__(self, window_size):
|
||||
super().__init__(window_size, pygame.SRCALPHA)
|
||||
self.test = 0
|
||||
self.running = True
|
||||
self.next_surface = 'sf_2'
|
||||
self.countdown = 100
|
||||
|
||||
def update(self):
|
||||
self.fill((255, 0, 0))
|
||||
|
||||
text = surface_text.RegularText('Surface stopping and swtiching to {0} in: {1}'.format(self.next_surface,
|
||||
str(self.countdown)))
|
||||
self.blit(text.surface, text.rect)
|
||||
|
||||
self.countdown -= 1
|
||||
if self.countdown < 0:
|
||||
self.running = False
|
21
surface_switching_test/surfaces/sf_2.py
Normal file
21
surface_switching_test/surfaces/sf_2.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import pygame
|
||||
from surface_switching_test.surfaces.objects import text as surface_text
|
||||
|
||||
class Surface(pygame.Surface):
|
||||
def __init__(self, window_size):
|
||||
super().__init__(window_size, pygame.SRCALPHA)
|
||||
self.test = 0
|
||||
self.running = True
|
||||
self.next_surface = 'sf_3'
|
||||
self.countdown = 100
|
||||
|
||||
def update(self):
|
||||
self.fill((0, 255, 0))
|
||||
|
||||
text = surface_text.RegularText('Surface stopping and swtiching to {0} in: {1}'.format(self.next_surface,
|
||||
str(self.countdown)))
|
||||
self.blit(text.surface, text.rect)
|
||||
|
||||
self.countdown -= 1
|
||||
if self.countdown < 0:
|
||||
self.running = False
|
21
surface_switching_test/surfaces/sf_3.py
Normal file
21
surface_switching_test/surfaces/sf_3.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import pygame
|
||||
from surface_switching_test.surfaces.objects import text as surface_text
|
||||
|
||||
class Surface(pygame.Surface):
|
||||
def __init__(self, window_size):
|
||||
super().__init__(window_size, pygame.SRCALPHA)
|
||||
self.test = 0
|
||||
self.running = True
|
||||
self.next_surface = 'sf_1'
|
||||
self.countdown = 100
|
||||
|
||||
def update(self):
|
||||
self.fill((0, 0, 255))
|
||||
|
||||
text = surface_text.RegularText('Surface stopping and swtiching to {0} in: {1}'.format(self.next_surface,
|
||||
str(self.countdown)))
|
||||
self.blit(text.surface, text.rect)
|
||||
|
||||
self.countdown -= 1
|
||||
if self.countdown < 0:
|
||||
self.running = False
|
Reference in New Issue
Block a user