-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
72 lines (55 loc) · 1.56 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import pygame, sys
from Observer import Observer
from Tile import Tile
from random import randint
pygame.init()
pygame.display.set_caption("RayCasting")
window_size = (1000, 800)
window = pygame.display.set_mode(window_size)
clock = pygame.time.Clock()
fps = 60
WHITE_COLOR = (255, 255, 255)
GRAY_COLOR = (155, 155, 155)
RED_COLOR = (255, 0, 0)
BLACK_COLOR = (0, 0, 0)
def getRandomPosition(i, e):
return randint(i, e)
tiles = []
tiles_length = 10
tile_size = 40
for i in range(20):
for j in range(25):
if 0 < i < 19:
if j < 24:
j = 0
tiles.append(Tile(tile_size * j, tile_size * i, tile_size, RED_COLOR))
observer = Observer(0, 0, 25, WHITE_COLOR)
start = False
running = True
while running:
window.fill(BLACK_COLOR)
mx, my = pygame.mouse.get_pos()
pl, pr = pygame.mouse.get_pressed()[0], pygame.mouse.get_pressed()[2]
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
# Iniciar
if event.key == pygame.K_RETURN:
start = True
# Editar
if event.key == pygame.K_f:
start = False
if start:
observer.set_x(mx)
observer.set_y(my)
observer.update(window, tiles)
observer.draw(window)
else:
if pl:
tiles.append(Tile(mx - tile_size / 2, my - tile_size / 2, tile_size, RED_COLOR))
for tile in tiles:
tile.draw(window)
pygame.display.flip()
clock.tick(fps)