-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
63 lines (50 loc) · 1.43 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
# Author: Porter Zach
# Python 3.9
import numpy as np
import render
from objects import Sphere, Rectangle
import time
ramp = r"$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^`'."[::-1] # no space
width = 120
height = 60
max_dist = 15
camera = np.array([0, 0, 1])
# objects = [
# { 'center': np.array([-0.2, 0, -2]), 'radius': 0.7 },
# { 'center': np.array([0.2, -0.5, -1]), 'radius': 0.6 },
# { 'center': np.array([-0.8, 0, 0]), 'radius': 0.2 }
# ]
objs = [
# Sphere(np.array([-0.2, 0, -2]), 0.7),
Sphere(np.array([0, .5, -2]), 0.6),
Rectangle(np.array([-5, -2, -7]), np.array([-4, 5, -3])),
Rectangle(np.array([4, -2, -7]), np.array([5, 5, -3]))
]
light = { 'position': np.array([2, 4, 4]) }
render.render(width, height, max_dist, camera, light, objs, ramp)
obj = objs[0]
controllable = False
max_right = 3
max_left = -3
speed = .5
dir = 1
while True:
if controllable:
inp = input()
if inp == "a":
obj.move(x = -1)
if inp == "d":
obj.move(x = 1)
if inp == "q":
obj.move(y = -1)
if inp == "e":
obj.move(y = 1)
if inp == "s":
obj.move(z = -1)
if inp == "w":
obj.move(z = 1)
else:
obj.move(x = speed * dir)
if not (max_left < obj.getCenter()[0] < max_right):
dir *= -1
render.render(width, height, max_dist, camera, light, objs, ramp)