I need my character to be able to stand on objects 2-29 but if a block is missing or deleted fall down into the missing slot, or if the character isn't standing on a block (2-29 atm) then fall. I can't seem to figure out what I need to do. Below is my entire code.
Rem Project: ***
Rem Created: ********
Rem ***** Main Source File *****
`Basic setup.
set display mode 1024,600,32
sync on
sync rate 0
set text font "Verdana"
set text size 30
set global collision on
`Level to load
levelname$ = "Test03"
prefix$ = "media\levels\"+levelname$+"\"
`Load images and textures..
load image "media\textures\game_texture.jpg",1
load image prefix$+"Environment.jpg",2
load image "media\textures\key.png",3
if file exist(prefix$+"music.mp3") = 1
musicon = 1
load music prefix$+"music.mp3",1
else
musicon = 0
endif
`Setup environment.
obj = 1
make object sphere 1,-1000
texture object 1,2
obj = obj + 1
if musicon = 1 then loop music 1
`Find the largest object.
open to read 1,prefix$+"LargestObject.txt"
read string 1,lobj$
largestobj = val(lobj$) `Store it in this variable.
close file 1
`Add and delete the cubes on the screen to make up the level.
for a = 2 to largestobj
`Add the cubes
if file exist(prefix$+"Add"+str$(a)+".txt") = 1
open to read 1,prefix$+"Add"+str$(a)+".txt"
read string 1,objnum$
read string 1,xpos$
read string 1,ypos$
objnum = val(objnum$)
xpos = val(xpos$)
ypos = val(ypos$)
close file 1
make object cube objnum,10
scale object objnum,20,20,20
texture object objnum,1
position object objnum,xpos-2,ypos,object position z(objnum) `The x seems to screw up by 2. Therefore, I subtract two to get the correct position.
obj = obj + 1
endif
`Delete cubes.
if file exist(prefix$+"Delete"+str$(a)+".txt") = 1
delete object a
obj = obj - 1
endif
next a
`Load the player file.
open to read 1,prefix$+"StartingPoint.txt"
read string 1,pobj$
read string 1,px$
read string 1,py$
`Create all player variables.
global pobj
global px
global py
global name$
global tries
global energy
pobj = val(pobj$)
px = val(px$)
py = val(py$)
name$ = "Jordan"
tries = 3
energy = 100
close file 1
`Create the player.
load object "media\player\Male Crew.x",pobj
scale object pobj,3,3,3
xrotate object pobj,270
fix object pivot pobj
rotate object pobj,0,180-90,0
position object pobj,px,py,object position z(pobj)
obj = obj + 1
`Position camera correctly.
position camera camera position x(),camera position y()-15,camera position z()+95
`Load the key file.
open to read 1,prefix$+"EndLevel.txt"
read string 1,kobj$
read string 1,kx$
read string 1,ky$
kobj = val(kobj$)
kx = val(kx$)
ky = val(ky$)
close file 1
`Create the key.
make object plain kobj,10,10
scale object kobj,15,15,15
texture object kobj,3
set image colorkey 0,0,0
set object transparency kobj,4
position object kobj,kx,ky,object position z(kobj)
obj = obj + 2
`Create the collision spheres for the player.
MidColSphere = obj `This detects if the player is hitting anything with his torso. It will also detect pushing as well.
make object sphere MidColSphere,3
scale object MidColSphere,18,18,18
position object MidColSphere,px,py+1.5,object position z(pobj)
obj = obj + 1
BotColSphere = obj `This detects if the player is on the platform, if he isn't, he will fall to his doom.
make object sphere BotColSphere,3
scale object BotColSphere,18,18,18
position object BotColSphere,px,py+0.2,object position z(pobj)
`Position camera correctly.
position camera camera position x(),camera position y(),camera position z()-10
do
gosub _hud
if rightkey() = 1
move object pobj,0.004
move object right MidColSphere,0.004 `Always make sure the collision spheres move WITH the player!!
move object right BotColSphere,0.004 `Always make sure the collision spheres move WITH the player!!
endif
if leftkey() = 1
move object pobj,-0.004
move object left MidColSphere,0.004 `Always make sure the collision spheres move WITH the player!!
move object left BotColSphere,0.004 `Always make sure the collision spheres move WITH the player!!
endif
for b = 29 to pobj - 1
collision = Object Collision(MidColSphere,b)
if collision > 0
move object right b,0.004
endif
next b
for c = 2 to 29
if object exist(c) = 1
gravity = object collision(BotColSphere,c)
if gravity > 0
text 0,50,"Gravity!"
endif
endif
next c
sync
loop
_hud:
text 0,0,"FPS: "+str$(screen fps())
return
Function FreeObject()
For I = 1 to 65536
`Find a free object and return its handle
If Object Exist(I) = 0 Then ExitFunction i
Next I
EndFunction 0
That doesn't work the way I intended though. How should I do this?
Thanks!

Zeus