-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
63 lines (49 loc) · 1.6 KB
/
test.py
File metadata and controls
63 lines (49 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import pygame as pg
from pygame.constants import *
#GAMESETTINGS
WIDTH = 1600
HEIGHT = 900
aspect_ratio = (WIDTH, HEIGHT)
FPS = 60
#COLORGAMUT
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 50 , 50)
GREEN = (0, 255, 0)
BLUE = (50, 50 , 255)
class Game:
def __init__(self):
#INITIALIZATION
pg.init()
pg.font.init()
self.font1 = pg.font.SysFont('Comic Sans MS', 100)
self.font2 = pg.font.SysFont('Comic Sans MS', 50)
self.title = self.font1.render('SNAKE 2P', False, BLUE, RED)
self.press = self.font2.render('PRESS ANY KEY', False, BLACK, GREEN)
self.textpos1 = self.title.get_rect(center=(asp_x//2, asp_y//4*1))
self.textpos2 = self.press.get_rect(center=(asp_x//2, asp_y//4*3))
pg.display.set_caption('SNAKE 2P')
self.display = pg.display.set_mode(aspect_ratio)
self.game_over = False
self.clock = pg.time.Clock()
def start_new(self):
#NEW GAME
self.sprites = pg.sprite.Group()
def start_screen(self):
intro = True
while intro:
self.display.fill(GREEN)
self.display.blit(self.title, self.textpos1)
self.display.blit(self.press, self.textpos2)
for event in pg.event.get():
if event.type == QUIT:
pg.quit()
break
elif event.type == KEYDOWN:
intro = False
break
pg.display.update()
def play(self):
if __name__ == "__main__":
Game().start_screen()
Game().play()