-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
46 lines (34 loc) · 1.4 KB
/
main.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
import pygame
import numpy as np
import sys
#from Game.Board import Board
from Game.game import Game
pygame.init()
def main():
board_size = 4
shift = 150
# screen resolution
resolution = (570, 720)
screen = pygame.display.set_mode(resolution)
# board = Board(board_size, board_size, board_size, shift, screen)
game = Game(screen, board_size, shift, screen.get_width(), screen.get_height())
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit() # Exit the program when the window is closed
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT and game.start and not game.board.game_over:
game.board.move_left()
if event.key == pygame.K_RIGHT and game.start and not game.board.game_over:
game.board.move_right()
if event.key == pygame.K_UP and game.start and not game.board.game_over:
game.board.move_up()
if event.key == pygame.K_DOWN and game.start and not game.board.game_over:
game.board.move_down()
# Start game with
if event.key == pygame.K_SPACE and not game.start:
game.start_game()
game.update_window()
if __name__ == "__main__":
main()