I am experimenting with making my own 3D graphics using only the 2D commands in DBC. I've already learned loads and hope you enjoy this game I made with it.
Catch the cubes as they fall by moving your square into the cube's shadow (using the arrow keys). Catch 3 in a row and you are "ON FIRE" your square will grow and make it easier.
Earn a BONUS 10pts for precision catches.
Use SHIFT and CONTROL to change the perspective, very cool
I've added a Time_Limit variable at the top, if you want play without a timer set this to 0.
`--------------------------------
`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
Endif
Else
Col = rgb(255,0,0) : `miss
Pts = 0
Endif
`Display cube as white until low, then as precision color
if Cy# < Wy1-5
ink rgb(255,255,255),0
else
ink col,0
endif
`* FG Square
`Fore Bottom Horizontal
line (Cx+(Vx#*Cz)),(Cy#-(Vy#*Cz)), (Cx+(Vx#*Cz))+Cvx,(Cy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z)
`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!