To recover your old ProBoards account, you need to request password recovery on this forum using your display name (the one that is shown on your posts). You will then get an email, be sure to check your junk email folders. The email we have set up may have issues temporarily, we are working on changing it. If you have issues, please try again in a few hours.
Join the IRC at #frutiger-aero-archive on LiberaChat for any account-related inquiries.

If you have registered after the 7th of November or have never posted, you need to re-register.

creepy 3d maze made in python!

The place to share your creative projects or what you are working on.
Post Reply
User avatar
sk8erboi1oh1 (Radiation-s)
Member
Member
Posts: 96
Joined: Sat Jul 19, 2025 6:23 am
Latest Status: I am radiation-s in minecraft. the evil resident of THE heroin tunnel.
Web Site: sk8erboi1oh1 blog
Aesthetic: Frutiger Aqua/Terminal style
Os: Window 10
Music: jumpstyle, nightcore, eurovision
Contact:

creepy 3d maze made in python!

Post by sk8erboi1oh1 (Radiation-s) »

import tkinter as tk

import math



# Maze (1 = wall, 0 = empty)

maze = [

[1,1,1,1,1,1,1,1],

[1,0,0,0,0,0,0,1],

[1,0,1,1,0,1,0,1],

[1,0,0,1,0,0,0,1],

[1,1,0,0,0,1,0,1],

[1,0,0,1,0,0,0,1],

[1,0,0,0,0,1,0,1],

[1,1,1,1,1,1,1,1]

]



TILE = 64

player_x, player_y = 100, 100

player_angle = 0



WIDTH, HEIGHT = 800, 600



root = tk.Tk()

root.title("Pseudo-3D Maze (Tkinter)")

canvas = tk.Canvas(root, width=WIDTH, height=HEIGHT, bg="black")

canvas.pack()



def cast_rays():

canvas.delete("all")

num_rays = 120

fov = math.pi / 3

max_depth = 800

delta_angle = fov / num_rays

cur_angle = player_angle - fov / 2



for ray in range(num_rays):

sin_a = math.sin(cur_angle)

cos_a = math.cos(cur_angle)



for depth in range(max_depth):

x = player_x + depth * cos_a

y = player_y + depth * sin_a

i, j = int(x / TILE), int(y / TILE)



if maze[j] == 1:

depth *= math.cos(player_angle - cur_angle) # fix fisheye

proj_height = min(HEIGHT, 50000 / (depth + 0.0001))

shade = int(255 / (1 + depth * depth * 0.0001))

color = f'#{shade:02x}{shade:02x}{shade:02x}'

canvas.create_rectangle(

ray * (WIDTH // num_rays),

HEIGHT//2 - proj_height//2,

(ray+1) * (WIDTH // num_rays),

HEIGHT//2 + proj_height//2,

fill=color, outline=color

)

break

cur_angle += delta_angle



def move_player(dx, dy):

global player_x, player_y

new_x = player_x + dx

new_y = player_y + dy

if maze[int(new_y//TILE)][int(new_x//TILE)] == 0:

player_x, player_y = new_x, new_y



def update():

cast_rays()

root.after(30, update)



def key_press(event):

global player_angle

if event.keysym == "Left":

player_angle -= 0.1

elif event.keysym == "Right":

player_angle += 0.1

elif event.keysym == "Up":

move_player(5*math.cos(player_angle), 5*math.sin(player_angle))

elif event.keysym == "Down":

move_player(-5*math.cos(player_angle), -5*math.sin(player_angle))



root.bind("<KeyPress>", key_press)

update()

root.mainloop()

Im Radiation-s in minecraft. yes i go with alot of names.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest