2d models = 3d models with 0 depth
DBP editor = Yes, look into GUI's
Going off LittleBigPlanet, I quickly put this together, though not that bad for a proof of concept. Anyway, here it is:
// setup types
type Rect3d
l as float
t as float
r as float
b as float
endtype
type Vector3d
x as float
y as float
z as float
endtype
type Camera
pos as Vector3d
ang as Vector3d
endtype
type World
bounds as Rect3d
endtype
type Player
id as integer
image as integer
size as Vector3d
pos as Vector3d
velocity as Vector3d
speed as float
bFloorCollision as boolean
endtype
sync on : sync rate 60
autocam off
// setup camera
global gCamera as Camera
gCamera.pos.x = 0.0
gCamera.pos.y = 0.0
gCamera.pos.z = -92.0 // deflaut depth
gCamera.ang.x = 2.5
position camera gCamera.pos.x, gCamera.pos.y, gCamera.pos.z
rotate camera gCamera.ang.x, gCamera.ang.y, gCamera.ang.z
// setup world limits
global gWorld as World
gWorld.bounds.l = -64.0
gWorld.bounds.t = 256.0
gWorld.bounds.r = 1024.0
gWorld.bounds.b = -256.0
// setup player
global gPlayer as Player
gPlayer.id = 1
gPlayer.image = 1
gPlayer.size.x = 16
gPlayer.size.y = 16
gPlayer.speed = 1.5
global gGravity as float
global gJumpVelocity as float
gGravity = 0.0981 `though it should be 9.81 / FPS, But for this, create a custon gravity
gJumpVelocity = 3.5
// draw player
cls 0
ink rgb(1,1,1),0 : box 0,0,64,64
ink rgb(255,0,0),0 : box 6,6,58,58
ink rgb(1,1,1),0 : box 45,10,58,28
ink rgb(255,255,255),0 : box 46,11,57,27
ink rgb(1,1,1),0 : box 49,14,53,18
ink rgb(1,1,1),0 : box 45,45,64,48
get image 1,0,0,64,64,1
make object plain 1, gPlayer.size.x, gPlayer.size.y
`position object 1, gPlayer.pos.x, gPlayer.pos.y-7, gPlayer.pos.z
set object light 1,0
set alpha mapping on 1,100 // doesn't need it but stuff it
texture object 1,0,1
// setup world
// just remember that the playing world depth is in the range of 0-64
col as dword
col = rgb(rnd(255),rnd(255),rnd(255))
make object box 2,256,32,64
set object diffuse 2,col
set object emissive 2,col
position object 2,0,0,0
col = rgb(rnd(255),rnd(255),rnd(255))
make object box 3,128,32,64
set object diffuse 3,col
set object emissive 3,col
position object 3,224,24,0
col = rgb(rnd(255),rnd(255),rnd(255))
make object box 4,64,12,32
set object diffuse 4,col
set object emissive 4,col
position object 4,320,64,16
col = rgb(rnd(255),rnd(255),rnd(255))
make object box 5,64,12,32
set object diffuse 5,col
set object emissive 5,col
position object 5,320+128,96,16
col = rgb(rnd(255),rnd(255),rnd(255))
make object box 6,256,12,64
set object diffuse 6,col
set object emissive 6,col
position object 6,364,0,0
// you'll end up doing something like this with position nodes
global gPlayerStartPos as Vector3d
gPlayerStartPos.x = 0.0
gPlayerStartPos.y = (gPlayer.size.y*.5)+16.0
gPlayerStartPos.z = 0.0
gPlayer.pos.x = gPlayerStartPos.x
gPlayer.pos.y = gPlayerStartPos.y
gPlayer.pos.z = gPlayerStartPos.z
do
// update player
dirX# = ((rightkey()||keystate(32))-(leftkey()||keystate(30))) * gPlayer.speed
dirZ# = ((upkey()||keystate(17))-(downkey()||keystate(31))) * gPlayer.speed
gPlayer.velocity.x = curvevalue(dirX#,gPlayer.velocity.x,10.0)
gPlayer.velocity.z = curvevalue(dirZ#,gPlayer.velocity.z,10.0)
if gPlayer.bFloorCollision and spacekey()
gPlayer.velocity.y = gJumpVelocity
endif
if not gPlayer.bFloorCollision
gPlayer.velocity.y = gPlayer.velocity.y - gGravity
endif
inc gPlayer.pos.x, gPlayer.velocity.x
inc gPlayer.pos.y, gPlayer.velocity.y
inc gPlayer.pos.z, gPlayer.velocity.z
// check collision
UpdatePlayerCollision(2, 6)
// depth bounds
if gPlayer.pos.z < -16.0 then gPlayer.pos.z = -16.0
if gPlayer.pos.z > 16.0 then gPlayer.pos.z = 16.0
// world bounds (just y for now)
if gPlayer.pos.y < gWorld.bounds.b
gPlayer.pos.x = gPlayerStartPos.x
gPlayer.pos.y = gPlayerStartPos.y
gPlayer.pos.z = gPlayerStartPos.z
gPlayer.velocity.x = 0
gPlayer.velocity.y = 0
gPlayer.velocity.z = 0
endif
position object gPlayer.id, gPlayer.pos.x, gPlayer.pos.y, gPlayer.pos.z
// update camera
gCamera.pos.x = curvevalue(gPlayer.pos.x+24.0,gCamera.pos.x,5.0)
gCamera.pos.y = curvevalue(gPlayer.pos.y+12.0,gCamera.pos.y,25.0)
position camera gCamera.pos.x, gCamera.pos.y, gCamera.pos.z
ink rgb(255,255,255),0
text 0,0,"Press WASD or directions to move"
text 0,12,"Press Space to jump"
sync
loop
// basic collision
// change this to directional (only check collision in the direction your going)
// bounding box collision, four point collision
// include +z collision
function UpdatePlayerCollision(fromObj as integer, toObj as integer)
pX# = gPlayer.pos.x
pY# = gPlayer.pos.y
pZ# = gPlayer.pos.z
hSizeX# = (gPlayer.size.x*.5)
hSizeY# = (gPlayer.size.x*.5)
gPlayer.bFloorCollision = 0
for n = fromObj to toObj
distLeft# = Intersect Object(n,pX#,pY#,pZ#,pX#-hSizeX#,pY#,pZ#)
distRight# = Intersect Object(n,pX#,pY#,pZ#,pX#+hSizeX#,pY#,pZ#)
distUp# = Intersect Object(n,pX#,pY#,pZ#,pX#,pY#+hSizeY#,pZ#)
distDown# = Intersect Object(n,pX#,pY#,pZ#,pX#,pY#-hSizeY#,pZ#)
if (distLeft# > 0)
if distLeft# < abs(hSizeX#)
gPlayer.pos.x = pX#+abs(hSizeX#-distLeft#)
endif
endif
if (distRight# > 0)
if distRight# < abs(hSizeX#)
gPlayer.pos.x = pX#-abs(hSizeX#-distRight#)
endif
endif
if (distUp# > 0)
checkCeiling = 1
if distUp# < abs(hSizeY#)
gPlayer.pos.y = pY#-abs(hSizeY#-distUp#)
endif
endif
if (distDown# > 0)
checkFloor = 1
if distDown# < abs(hSizeY#)
gPlayer.pos.y = pY#+abs(hSizeY#-distDown#)
endif
endif
next n
if checkCeiling
gPlayer.velocity.y = 0.0
endif
if checkFloor
gPlayer.bFloorCollision = 1
gPlayer.velocity.y = 0.0
endif
endfunction
A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.