@Latch
Quote: "Your approach may be limiting - by that I mean if you look at 3d in 2d as lines, you may run into trouble. If you think of 3d in 2d as 3d points (vertices) translated to 2d, then you're more on the road to how 3d is actually rendered on 2d screens."
This is exactly what I thought as soon as I'd finished it lol.
Your explanation of the Z deformation helps a lot
The original purpose of creating this was for a game I'm making called DARK KNIGHTS (see community project thread), the purpose was to make a 3D world for sprites so they can have 3D collisions.
If I can factor in the Z-scaling that will be enough for the game, but I also want to take this idea further.
Here is a game I made with the 2D 3D world, I entered it in the DBC challenge (its much better now though)
2D CUBE CATCHER!
use the arrow keys to catch the cubes.
10pt bonus for precision
use SHIFT and CONTROL to change perspective! very cool
set Time_Limit = 0 if you don't want a timer.
`--------------------------------
`2D CUBE CATCHER!
`--------------------------------
`by OBese87
`--------------------------------
`DO YOU WANT A TIME LIMIT?
Time_Limit = 1
`--------------------------------
` SETUP
`--------------------------------
randomize timer()
hide mouse
`world Boundaries
Wx1 = 15 : Wx2 = 320
Wy1 = 200 : Wy2 = 30
Wz1 = 0 : Wz2 = 160
`perspective
Vx# = 0.5 : Vy# = 1-Vx#
`Cube position
Cx = rnd(Wx2-Wx1)+Wx1
Cy# = Wy2
Cz = rnd(Wz2-Wx1)+Wx1
Cs# = 1
`Cube volume
Cvx = 10
Cvy = 10
Cvz = 10
`player plain
Px = Wx1
Py = Wy1
Pz = Wz1
`plain volume
Pvx = 0
Pvz = 0
sTime# = timer() : `start time
`--------------------------------
` MAIN LOOP
`--------------------------------
sync on
DO
cls
gosub Axis
gosub Cube_Shadow
gosub Player
gosub Cube
gosub control
gosub cube_fall
gosub bind
gosub HUD
sync
LOOP
`--------------------------------
` GOSUBS
`--------------------------------
axis:
`x-line
ink rgb(255,0,0),0
line 15,200,320,200
`y-line
ink rgb(0,255,0),0
line 15,200,15,20
`z-line (X+Y/2)
ink rgb(0,0,255),0
line 15,200,15+(145*Vx#),200-(145*Vy#)
RETURN
`------
Cube_Shadow:
`* cube shadow
ink rgb(100,100,100),0
`FG Horizontal
line (Cx+(Vx#*Cz)),(Py-(Vy#*Cz)), (Cx+(Vx#*Cz))+Cvx,(Py-(Vy#*Cz))
`BG Horizontal
line (Cx+(Vx#*Cz))+(Vx#*Cvz),(Py-(Vy#*Cz))-(Vy#*Cvz), (Cx+(Vx#*Cz))+Cvx+(Vx#*Cvz),(Py-(Vy#*Cz))-(Vy#*Cvz)
`LB
line (Cx+(Vx#*Cz)),(Py-(Vy#*Cz)), (Cx+(Vx#*Cz))+(Vx#*Cvz),(Py-(Vy#*Cz))-(Vy#*Cvz)
`RB
line (Cx+(Vx#*Cz))+Cvx,(Py-(Vy#*Cz)), (Cx+(Vx#*Cz))+Cvx+(Vx#*Cvz),(Py-(Vy#*Cz))-(Vy#*Cvz)
RETURN
`------
Player:
if onfire = 0 then ink rgb(0,0,255),0
if onfire = 1 then ink rgb(255,0,0),0
`FG Horizontal
line (Px+(Vx#*Pz)),(Py-(Vy#*Pz)), (Px+(Vx#*Pz))+Pvx,(Py-(Vy#*Pz))
`BG Horizontal
line (Px+(Vx#*Pz))+(Vx#*Pvz),(Py-(Vy#*Pz))-(Vy#*Pvz), (Px+(Vx#*Pz))+Pvx+(Vx#*Pvz),(Py-(Vy#*Pz))-(Vy#*Pvz)
`LB
line (Px+(Vx#*Pz)),(Py-(Vy#*Pz)), (Px+(Vx#*Pz))+(Vx#*Pvz),(Py-(Vy#*Pz))-(Vy#*Pvz)
`RB
line (Px+(Vx#*Pz))+Pvx,(Py-(Vy#*Pz)), (Px+(Vx#*Pz))+Pvx+(Vx#*Pvz),(Py-(Vy#*Pz))-(Vy#*Pvz)
RETURN
`------
Cube:
`Colour the cube to plain position
DifX = ABS( (Px+(pvx/2)) - (Cx+(Cvx/2)) )
DifZ = ABS( (Pz+(pvz/2)) - (Cz+(Cvz/2)) )
`Get cube Color
If DifX < Pvx and DifZ < Pvz
If DifX <= 1 and DifZ <= 1
Col = rgb(255,255,0) : `precision bonus!
Pts = 10
Else
Col = rgb(0,255,0) : `score
Pts = 1
End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(Vy#*Cz)), (Cx+(Vx#*Cz))+(Vx#*Cvz),(Cy#-(Vy#*Cz))-(Vy#*Cvz)
`RB
line (Cx+(Vx#*Cz))+Cvx,(Cy#-(Vy#*Cz)), (Cx+(Vx#*Cz))+Cvx+(Vx#*Cvz),(Cy#-(Vy#*Cz))-(Vy#*Cvz)
`LT
line (Cx+(Vx#*Cz)),(Cy#-(Vy#*Cz))-Cvy, (Cx+(Vx#*Cz))+(Vx#*Cvz),(Cy#-(Vy#*Cz))-Cvy-(Vy#*Cvz)
`RT
line (Cx+(Vx#*Cz))+Cvx,(Cy#-(Vy#*Cz))-Cvy, (Cx+(Vx#*Cz))+Cvx+(Vx#*Cvz),(Cy#-(Vy#*Cz))-Cvy-(Vy#*Cvz)
RETURN
`------
control:
if rightkey() = 1 then inc Px,2
if leftkey() = 1 then dec Px,2
if upkey() = 1 then inc Pz,1
if downkey() = 1 then dec Pz,1
`Change perspective
if Shiftkey() = 1 then inc Vx#,0.1
if Controlkey() = 1 then dec Vx#,0.1
if Vx# < 0.0 then Vx# = 0.0
if Vx# > 1.0 then Vx# = 1.0
Vy# = 1-Vx#
RETURN
`------
cube_fall:
inc Cy#,Cs#
if Cy# >= Wy1
If Pts > 0
inc Pscore,Pts
inc roll,1
if roll = 3 then onfire = 1
else
roll = 0
onfire = 0
endif
Cx = rnd(Wx2-Wx1)+Wx1
Cy# = Wy2
Cz = rnd(Wz2-Wx1)+Wx1
Cvx = rnd(10)+5 : Cvy = rnd(10)+5 : Cvz = rnd(10)+5
Cs# = rnd(15)
Cs# = (Cs# /10)+0.5
else
if onfire = 0
`resize box to cube size
if (Pvx-Cvx) <> 0 then dec Pvx,(Pvx-Cvx)/ABS(Pvx-Cvx)
if (Pvz-Cvz) <> 0 then dec Pvz,(Pvz-Cvz)/ABS(Pvz-Cvz)
else
Pvx = 30 : Pvz = 30 : `Big square for on fire
endif
endif
RETURN
`------
bind:
if Cx < Wx1 then Cx = Wx1
if Cx > Wx2 then Cx = Wx2
if Cy# > Wy1 then Cy# = Wy1
if Cy# < Wy2 then Cy# = Wy2
if Cz < Wz1 then Cz = Wz1
if Cz > Wz2 then Cz = Wz2
if Px < Wx1 then Px = Wx1
if Px > Wx2 then Px = Wx2
if Pz < Wz1 then Pz = Wz1
if Pz > Wz2 then Pz = Wz2
RETURN
`------
HUD:
set cursor 20,320
print "Score: "; Pscore
if onfire = 1 then print "YOU'RE ON FIRE!!!"
rem print "Cube Speed: "; Cs#
`Time Limit
if Time_Limit = 1
rTime# = 60-(Timer()-sTime#)/1000
print "Time Remaining: "; rTime#
if rTime# <= 0
cls
center text 320,240,"You scored " + str$(Pscore) + "pts!"
wait key
sync
end
endif
endif
RETURN
I am king of the noobs!