Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_3D_flat_animation.py
- import math
- from tkinter import *
- fov = 250
- root = Tk()
- ww = 600
- hh = 600
- w = Canvas(root,width=ww,height=hh)
- w.pack()
- class pixel:
- def __init__(self,x,y,z):
- self.x = x
- self.y = y
- self.z = z
- pixels = []
- for x in range(-400,400,25):
- for z in range(-250,250,25):
- pixels.append(pixel(x,40,z))
- size = 1
- def engine():
- w.delete("all")
- for pix in pixels:
- scale = fov/(max(1, fov+pix.z))
- x2d = pix.x * scale + ww / 2
- y2d = pix.y * scale + hh / 2
- w.create_oval(x2d-size,y2d-size,x2d+size,y2d+size)
- pix.z -= 2
- if pix.z < -fov:
- pix.z += 2*fov
- root.after(1,engine)
- engine()
- mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement