/
main.py
67 lines (55 loc) · 1.84 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
import pygame
from math import *
import random
from pygame import locals
import logging
from matrix import *
from camera import *
from test import *
from objects import *
logging.basicConfig(filename='kocka.log',level=logging.DEBUG)
pygame.init()
screenwidth = 600
screenheight = 600
screen = pygame.display.set_mode((screenwidth, screenheight))
kam = camera(0.035) #meter
def display():
diplaying = kam.toDisplay(objects)
for i in range(len(diplaying)):
for line in objects[i].lines:
pygame.draw.line(screen, (0, 20, 100), diplaying[i][line[0]], diplaying[i][line[1]], 2)
#for line in objects[i].lines[:6]:
# for line2 in objects[i].lines[6:]: #display sides
# pygame.draw.polygon(screen, (100, 20, 100), [diplaying[i][line[0]], diplaying[i][line[1]], diplaying[i][line2[0]], diplaying[i][line2[1]]], 0)
def main():
run = True
screen.fill((100,180,180))
t = 0
pygame.mouse.set_pos([300,300])
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
run = False
screen.fill((10,190,200))
mouse_pos = pygame.mouse.get_pos()
kam.rotate(mouse_pos)
pygame.mouse.set_pos([300,300])
pressed_keys = pygame.key.get_pressed()
kam.move(pressed_keys)
#for o in objects:
# o.rotate(0, 0.02)
# o.rotate(1, 0.02)
# o.rotate(2, 0.02)
#if o.points[0].matrix[0][0] < 0:
# o.move(t, 1)
#if pygame.mouse.get_pressed()[0]:
# print("ohh helo")
# newobject.addPoint(kam)
# newobject.addLine()
display()
t += 0.01
pygame.display.flip()
main()