-
Notifications
You must be signed in to change notification settings - Fork 0
/
State.py
57 lines (43 loc) · 1.12 KB
/
State.py
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
import pygame
import Colors
import Images
from Entities import *
import PyPong
ACTIVE = "game"
class GameState(object):
def init(self, screen):
self.screen = screen
self.__paddle1 = Paddle(self.screen, (50,50), True)
self.__paddle2 = Paddle(self.screen, (PyPong.WIDTH - 50, 50), False)
self.__table = Table(self.screen, (200, 350))
self.__net = Net(self.screen, (499, 300))
self.__ball = Ball(self.screen, (200, 100))
self.__entities = [self.__paddle1, self.__paddle2, self.__table, self.__net, self.__ball]
def tick(self):
self.__ball.tick()
self.__table.tick()
self.__net.tick()
self.__paddle1.tick()
self.__paddle2.tick()
check_impacts(self.__entities)
def render(self):
self.screen.fill(Colors.WHITE)
self.__table.render()
self.__net.render()
self.__ball.render()
self.__paddle1.render()
self.__paddle2.render()
class MenuState(object):
def init(self, screen):
self.screen = screen
def tick(self):
pass
def render(self):
pass
game_state = GameState()
menu_state = MenuState()
def active_state():
if ACTIVE == "menu":
return menu_state
else:
return game_state