Skip to content

Commit 3011550

Browse files
committed
GUI Prototype
0 parents  commit 3011550

File tree

8 files changed

+116
-0
lines changed

8 files changed

+116
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__pycache__
2+
.idea

Pipfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[dev-packages]
7+
8+
[packages]
9+
pygame = "*"
10+
11+
[requires]
12+
python_version = "3.7"

Pipfile.lock

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TicTacToe/__init__.py

Whitespace-only changes.

TicTacToe/resources/O.png

1.56 KB
Loading

TicTacToe/resources/X.png

776 Bytes
Loading

TicTacToe/resources/line.png

283 Bytes
Loading

TicTacToe/tictactoe.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import pygame
2+
from os import path
3+
from TicTacToe import Grid
4+
5+
6+
class Game:
7+
def __init__(self, *assetPath):
8+
self.clock = pygame.time.Clock()
9+
self.running = True
10+
11+
self.assets = {}
12+
self.loadAssets(*assetPath)
13+
14+
self.WINDOW_WIDTH = 400
15+
self.WINDOW_HEIGHT = 400
16+
self.window = pygame.display.set_mode((self.WINDOW_WIDTH, self.WINDOW_HEIGHT))
17+
18+
pygame.init()
19+
20+
while self.running:
21+
self.clock.tick(100)
22+
self.handleEvents()
23+
self.redraw()
24+
25+
def redraw(self):
26+
pygame.draw.rect(self.window, (255, 255, 255), (50, 75, 300, 300))
27+
self.window.blit(self.assets['VLine'], (50 - 5 + 100, 75))
28+
self.window.blit(self.assets['VLine'], (50 - 5 + 200, 75))
29+
self.window.blit(self.assets['HLine'], (50, 75 + 100))
30+
self.window.blit(self.assets['HLine'], (50, 75 + 200))
31+
self.window.blit(self.assets['O'], (50, 80))
32+
self.window.blit(self.assets['O'], (50 + 1 * 100, 80 + 1 * 100))
33+
self.window.blit(self.assets['X'], (50 + 1 * 100, 80 + 2 * 100))
34+
pygame.display.update()
35+
36+
def handleEvents(self):
37+
for event in pygame.event.get():
38+
if event.type == pygame.QUIT: self.running = False
39+
40+
def loadAssets(self, *assetsPath):
41+
42+
self.assets['VLine'] = pygame.image.load(path.join(*assetsPath, 'line.png'))
43+
self.assets['HLine'] = pygame.transform.rotate(self.assets['VLine'], 90)
44+
self.assets['X'] = pygame.image.load(path.join(*assetsPath, 'X.png'))
45+
self.assets['O'] = pygame.image.load(path.join(*assetsPath, 'O.png'))
46+
47+
48+
if __name__ == '__main__':
49+
Game('resources')

0 commit comments

Comments
 (0)