Add window.
This commit is contained in:
parent
0f9efd4d0b
commit
ed13737c0d
@ -1,10 +1,10 @@
|
||||
import pygame
|
||||
from window import Window
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pygame.init()
|
||||
pygame.display.set_caption('Snake')
|
||||
surface = pygame.display.set_mode(size=(800, 600))
|
||||
window = Window(title='Snake', size=(800, 600))
|
||||
|
||||
clock = pygame.time.Clock()
|
||||
framerate = 25
|
||||
|
||||
@ -15,7 +15,7 @@ if __name__ == '__main__':
|
||||
if event.type == pygame.QUIT:
|
||||
shall_abort = True
|
||||
|
||||
surface.fill((0, 0, 0))
|
||||
window.reset()
|
||||
|
||||
clock.tick(framerate)
|
||||
pygame.display.flip()
|
||||
|
||||
13
snake/window.py
Normal file
13
snake/window.py
Normal file
@ -0,0 +1,13 @@
|
||||
import pygame
|
||||
|
||||
|
||||
class Window:
|
||||
def __init__(self, title, size):
|
||||
pygame.init()
|
||||
pygame.display.set_caption(title)
|
||||
self.__surface = pygame.display.set_mode(size=size)
|
||||
|
||||
|
||||
def reset(self):
|
||||
self.__surface.fill((0, 0, 0))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user