Ok First I want to apologize for the length of all this.
What i have here is the same code, in one the skysphere is disabled and in the second it is not.
The first one works, except I really want the skysphere to denote how far my player can see. In the second, my player is up way over the world, outside of the dungeon.
I hope someone can look at this and tell me why, its just driving me crazy! Also, I'm new to DBPro, so any other suggestions would be helpful! thank you!
First code, no skysphere
Rem Project: Karthan's World
Rem Created: 4/13/04 10:14:21 PM
Rem ***** Main Source File *****
rem This is a project begining, a concept demo
Randomize timer()
sync on
sync rate 60
set display mode 800,600,32
set camera range 1, 6000
hide mouse
Backdrop on
color backdrop rgb(50,50,50)
autocam off
` 1 2
` 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 THIS IS THE MAP
Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2` 1 0 = open room
Data 2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2` 2 1 = Wall
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 3 2 = do not draw
Data 2,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,1,2` 4
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 5
Data 2,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,1,1,2` 6
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 7
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 8
Data 2,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,1,2` 9
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2`10
Data 2,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,1,1,2` 1
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 2
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 4
Data 2,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,1,2` 5
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 6
Data 2,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,1,1,2` 7
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 8
Data 2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2` 9
Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2`20
dim map(21, 21)` This is how the computer views the map
mapx = 20 `The map is from 1 to mapx in length
mapy = 20 `the map is from 1 to mapy in height(minimap) or depth(screen)
speed = 20
`Mx and my is the players starting position on the minimap
mx = 5
my = 5
Height = 5
`This reads the map into the system
for y = 1 to mapy
for x = 1 to mapx
read map(x,y)
next x
next y
`Playerobject
make object sphere 1,100
collbox(1)
`This creates the walls floor and ceiling objects
load image "lead.bmp", 1
load image "cave01.bmp", 2
load image "Ground.bmp", 3
make object sphere 2,-1200
color object 2, rgb(50,50,50)
for a = 1 to 289
make object cube 50+a, 200 `Walls (51 - 306)
make object cube 339+a, 200 `Floor (307 - 563)
make object cube 629+a, 200 `Ceiling (564 - 820)
texture object 50+a, 1
texture object 339+a, 2
texture object 629+a, 3
hide object 50+a
hide object 339+a
hide object 629+a
Collbox(50+a)
Collbox(339+a)
Collbox(629+a)
next a
`This sets the player position in the world, in relation to the mini map
position object 1,mx*200,Height,my*200
position camera mx*200,Height,my*200
`These variables will track the camera's position
cx = int(camera position x()/200)
cz = int(camera position z()/200)
Do`Begin of loop
`Updating CX and CZ
cx = int(object position x(1)/200)-5
cz = int(object position z(1)/200)-5
`This is the object number in use. It is increased as we check 8 left, 8 right, 8 forward,
bla = 0 `and 8 backward
`Begin checking the mini map for objects
for a = 1 to 289
hide object (50+a)
hide object (339+a)
hide object (629+a)
next a
for z = my-8 to my+8
for x = mx-8 to mx+8
bla = bla +1
`Cposx and Cposy are the cursor where the computer checks for structure.
cposx = cx+x`be less than 1 or greater than the map
cposz = cz+z
if cposx <= 1 then cposx = 1
if cposx >= mapx then cposx = mapx
if cposz <= 1 then cposz = 1
if cposz >= mapy then cposz = mapy
`Remember map(x,y)? if it = 1 then thats a wall.
if map(cposx,cposz) = 1
show object bla+50
position object bla+50, cposx*200,0,cposz*200
endif
`Remember map(x,y)? if it = 0 then thats an open room.
if map(cposx, cposz) = 0
show object bla+339
position object bla+339, cposx*200,-200,cposz*200
show object bla+629
position object bla+629, cposx*200,200,cposz*200
endif
`Ends the Minimap check
next x
next z
`Camera controls
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
CameraAngleY# = WrapValue(CameraAngleY#+MousemoveX()*0.2)
CameraAngleX# = WrapValue(CameraAngleX#+MousemoveY()*0.2)
rotate object 1, Camera Angle X(), Camera Angle Y(), 0
if scancode()=17 then move object 1, 20
if scancode()=31 then move object 1, -20
if scancode() = 30 then move object left 1, 20`turn object left 1, 90: move object 1, 20: turn object right 1,90
if scancode() = 32 then move object right 1, 20`turn object right 1, 90: move object 1, 20: turn object left 1,90
Yrotate camera CurveAngle(CameraAngleY#,OldCamAngleY#,24)
Xrotate camera CurveAngle(CameraAngleX#,OldCamAngleX#,24)
`***********************This section is error trapping****************************
for y = 1 to mapy
for x = 1 to mapx
if (x <> cx) or (y <> cz)then text x*10,y*10,str$(map(x,y))
if (x = cx) and (y = cz)then text x*10,y*10," "
next x
next y
text cx*10, cz*10, "*"
text 50, 210, str$(cx)`(camera position x())
text 50, 220, str$(cz)`(camera position z())
text 50, 250, str$(object angle z(1))`(camera position x())
text 50, 260, str$(camera angle z())`(camera position z())
`**********************************************************************************
`Updating the screen
position object 1, object position x(1), Height, object position z(1)
SlideColl(1)`<---RPGamer's Sliding collision function
position camera object position x(1), object position y(1), object position z(1)
`This is the Troublesome SKYSPHERE
` position object 2,object position x(1), Height, object position z(1)
sync
Loop`End of loop
Function CollBox(ob#)`this is RPGamer's function for the collision box
obsx#= Object Size X(ob#): Rem Find the object size X
obsy#= Object Size Y(ob#): Rem Find the object size Y
obsz#= Object Size Z(ob#): Rem Find the object size Z
Make object Collision Box ob#,0-(obsx#/2),0-(obsy#/2),0-(obsz#/2),(obsx#/2),(obsy#/2),(obsz#/2),0
endfunction
`This is RPGamer's Sliding collision function
Function SlideColl(pn#) : Rem pn# is PLAYER NUMBER
obx#= Object position x(pn#) : Rem Get the objects X position
oby#= Object position y(pn#) : Rem Get the objects Y position
obz#= Object position z(pn#) : Rem Get the objects Z position
If object collision(pn#,0)>0 and object collision (pn#,2) <> 2: Rem here you may put NOT any objects you dont want collision with
dec obx#,get object collision x()
dec oby#,get object collision y()
dec obz#,get object collision z()
position object pn#,obx#,oby#,obz#
endif
endfunction
Second Code, with the Skysphere.
Rem Project: Karthan's World
Rem Created: 4/13/04 10:14:21 PM
Rem ***** Main Source File *****
rem This is a project begining, a concept demo
Randomize timer()
sync on
sync rate 60
set display mode 800,600,32
set camera range 1, 6000
hide mouse
Backdrop on
color backdrop rgb(50,50,50)
autocam off
` 1 2
` 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 THIS IS THE MAP
Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2` 1 0 = open room
Data 2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2` 2 1 = Wall
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 3 2 = do not draw
Data 2,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,1,2` 4
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 5
Data 2,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,1,1,2` 6
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 7
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 8
Data 2,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,1,2` 9
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2`10
Data 2,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,1,1,2` 1
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 2
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 4
Data 2,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,1,2` 5
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 6
Data 2,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,1,1,2` 7
Data 2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2` 8
Data 2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2` 9
Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2`20
dim map(21, 21)` This is how the computer views the map
mapx = 20 `The map is from 1 to mapx in length
mapy = 20 `the map is from 1 to mapy in height(minimap) or depth(screen)
speed = 20
`Mx and my is the players starting position on the minimap
mx = 5
my = 5
Height = 5
`This reads the map into the system
for y = 1 to mapy
for x = 1 to mapx
read map(x,y)
next x
next y
`Playerobject
make object sphere 1,100
collbox(1)
`This creates the walls floor and ceiling objects
load image "lead.bmp", 1
load image "cave01.bmp", 2
load image "Ground.bmp", 3
make object sphere 2,-1200
color object 2, rgb(50,50,50)
for a = 1 to 289
make object cube 50+a, 200 `Walls (51 - 306)
make object cube 339+a, 200 `Floor (307 - 563)
make object cube 629+a, 200 `Ceiling (564 - 820)
texture object 50+a, 1
texture object 339+a, 2
texture object 629+a, 3
hide object 50+a
hide object 339+a
hide object 629+a
Collbox(50+a)
Collbox(339+a)
Collbox(629+a)
next a
`This sets the player position in the world, in relation to the mini map
position object 1,mx*200,Height,my*200
position camera mx*200,Height,my*200
`These variables will track the camera's position
cx = int(camera position x()/200)
cz = int(camera position z()/200)
Do`Begin of loop
`Updating CX and CZ
cx = int(object position x(1)/200)-5
cz = int(object position z(1)/200)-5
`This is the object number in use. It is increased as we check 8 left, 8 right, 8 forward,
bla = 0 `and 8 backward
`Begin checking the mini map for objects
for a = 1 to 289
hide object (50+a)
hide object (339+a)
hide object (629+a)
next a
for z = my-8 to my+8
for x = mx-8 to mx+8
bla = bla +1
`Cposx and Cposy are the cursor where the computer checks for structure.
cposx = cx+x`be less than 1 or greater than the map
cposz = cz+z
if cposx <= 1 then cposx = 1
if cposx >= mapx then cposx = mapx
if cposz <= 1 then cposz = 1
if cposz >= mapy then cposz = mapy
`Remember map(x,y)? if it = 1 then thats a wall.
if map(cposx,cposz) = 1
show object bla+50
position object bla+50, cposx*200,0,cposz*200
endif
`Remember map(x,y)? if it = 0 then thats an open room.
if map(cposx, cposz) = 0
show object bla+339
position object bla+339, cposx*200,-200,cposz*200
show object bla+629
position object bla+629, cposx*200,200,cposz*200
endif
`Ends the Minimap check
next x
next z
`Camera controls
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
CameraAngleY# = WrapValue(CameraAngleY#+MousemoveX()*0.2)
CameraAngleX# = WrapValue(CameraAngleX#+MousemoveY()*0.2)
rotate object 1, Camera Angle X(), Camera Angle Y(), 0
if scancode()=17 then move object 1, 20
if scancode()=31 then move object 1, -20
if scancode() = 30 then move object left 1, 20`turn object left 1, 90: move object 1, 20: turn object right 1,90
if scancode() = 32 then move object right 1, 20`turn object right 1, 90: move object 1, 20: turn object left 1,90
Yrotate camera CurveAngle(CameraAngleY#,OldCamAngleY#,24)
Xrotate camera CurveAngle(CameraAngleX#,OldCamAngleX#,24)
`***********************This section is error trapping****************************
for y = 1 to mapy
for x = 1 to mapx
if (x <> cx) or (y <> cz)then text x*10,y*10,str$(map(x,y))
if (x = cx) and (y = cz)then text x*10,y*10," "
next x
next y
text cx*10, cz*10, "*"
text 50, 210, str$(cx)`(camera position x())
text 50, 220, str$(cz)`(camera position z())
text 50, 250, str$(object angle z(1))`(camera position x())
text 50, 260, str$(camera angle z())`(camera position z())
`**********************************************************************************
`Updating the screen
position object 1, object position x(1), Height, object position z(1)
SlideColl(1)`<---RPGamer's Sliding collision function
position camera object position x(1), object position y(1), object position z(1)
`This is the Troublesome SKYSPHERE
position object 2,object position x(1), Height, object position z(1)
sync
Loop`End of loop
Function CollBox(ob#)`this is RPGamer's function for the collision box
obsx#= Object Size X(ob#): Rem Find the object size X
obsy#= Object Size Y(ob#): Rem Find the object size Y
obsz#= Object Size Z(ob#): Rem Find the object size Z
Make object Collision Box ob#,0-(obsx#/2),0-(obsy#/2),0-(obsz#/2),(obsx#/2),(obsy#/2),(obsz#/2),0
endfunction
`This is RPGamer's Sliding collision function
Function SlideColl(pn#) : Rem pn# is PLAYER NUMBER
obx#= Object position x(pn#) : Rem Get the objects X position
oby#= Object position y(pn#) : Rem Get the objects Y position
obz#= Object position z(pn#) : Rem Get the objects Z position
If object collision(pn#,0)>0 and object collision (pn#,2) <> 2: Rem here you may put NOT any objects you dont want collision with
dec obx#,get object collision x()
dec oby#,get object collision y()
dec obz#,get object collision z()
position object pn#,obx#,oby#,obz#
endif
endfunction
Think Gad fro Spill Chock!