-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmvc.py
33 lines (25 loc) · 783 Bytes
/
mvc.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
import pygame
from pygame import MOUSEBUTTONUP, QUIT
from model.chessboard import Chessboard
from view.ChessboardView import ChessboardView
from controller.Click import Click
from stockfish import Stockfish
def game_loop(model, graphics):
end = False
click = Click(model)
while not model.is_ended() and not end:
for event in pygame.event.get():
if event.type == MOUSEBUTTONUP:
pos = pygame.mouse.get_pos()
click.notify(pos, graphics)
if event.type == QUIT:
end = True
def run():
model = Chessboard()
graphics = ChessboardView(model)
model.register_observator(graphics)
pygame.init()
# Game loop
game_loop(model, graphics)
if __name__ == '__main__':
run()