Posted: 23rd Nov 2006 07:16
ok, im still new at this but i tried the code you gave me and it worked but i tried to put it into the game i am currently making and it did not work
here is what i have:
sync on
sync rate 30
` load images
load image "metal_crackle.bmp",1
load image "GRASS09.BMP",2
load image "plate_rusted.bmp",3
load image "power_modual.bmp",4
load image "catwalks.bmp",5
load image "metal.jpg",6
` setup
autocam off : sync rate 60
hide mouse : sync on
` Make a pedestal steps
make object box 1,1000,10,1000
position object 1,1500,-55,500
texture object 1,2
make object box 2,1000,10,1000
position object 2,500,-55,500
texture object 2,1
scroll object texture 2,-10.0,-10.0
` top floor
make object box 3,1000,10,900
position object 3,500,100,550
texture object 3,1
scale object texture 3,-5.0,-5.0
` stairs
make object box 4,100,10,100
position object 4,50,100,50
texture object 4,5
make object box 5,100,10,100
position object 5,150,80,50
texture object 5,5
make object box 17,100,10,100
position object 17,250,60,50
texture object 17,5
make object collision box 17,-50,-5,-50,50,5,50,0
make object box 18,100,10,100
position object 18,350,40,50
texture object 18,5
make object collision box 18,-50,-5,-50,50,5,50,0
make object box 19,100,10,100
position object 19,450,20,50
texture object 19,5
make object collision box 19,-50,-5,-50,50,5,50,0
make object box 20,100,10,100
position object 20,550,0,50
texture object 20,5
make object collision box 20,-50,-5,-50,50,5,50,0
make object box 21,100,10,100
position object 21,650,-20,50
texture object 21,5
make object collision box 21,-50,-5,-50,50,5,50,0
make object box 22,100,10,100
position object 22,750,-40,50
texture object 22,5
make object collision box 22,-50,-5,-50,50,5,50,0
` make windows
make object box 6,12,50,50
position object 6,1000,200,250
` Make three walls to create one with an opening for a door
make object box 7,13,500,500
position object 7,1000,200,250
texture object 7,3
make object collision box 7,-5,-250,-250,5,250,250,0
scale object texture 7,-3.0,-1.0
make object box 8,13,360,110
position object 8,1000,270,550
texture object 8,3
make object collision box 8,-10,-180,-55,10,180,55,0
make object box 9,13,500,400
position object 9,1000,200,800
texture object 9,3
make object collision box 9,-10,-250,-200,10,250,200,0
scale object texture 9,-3.0,-1.0
`Make edging for door
make object box 28,13,150,13
position object 28,1000,23,506
texture object 28,6
make object collision box 28,-7.5,-75,-7.5,7.5,75,7.5,0
make object box 29,13,150,13
position object 29,1000,23,593
texture object 29,6
make object collision box 29,-7.5,-75,-7.5,7.5,75,7.5,0
make object box 30,13,13,75
position object 30,1000,89,550
texture object 30,6
make object collision box 30,-7.5,-7.5,-37.5,7.5,7.5,37.5,0
` make more walls
make object box 10,1000,500,13
position object 10,500,200,1000
texture object 10,3
make object collision box 10,-500,-250,-10,500,250,10,0
scale object texture 10,-3.0,-1.0
make object box 12,1000,500,13
position object 12,500,200,0
texture object 12,3
make object collision box 12,-500,-250,-10,500,250,10,0
scale object texture 12,-3.0,-1.0
make object box 13,13,500,1000
position object 13,0,200,500
texture object 13,3
make object collision box 13,-10,-250,-500,10,250,500,0
scale object texture 13,-3.0,-1.0
make object box 14,1000,1000,13
position object 14,500,450,500
xrotate object 14,90
texture object 14,3
scale object texture 14,-3.0,-1.0
` make floor
make object box 15,990,10,990
position object 15,500,-55,500
texture object 15,1
scroll object texture 15,-10.0,-10.0
make object collision box 15,-485,-5,-485,485,5,485,0
` make outside
make object box 16,1000,10,1000
position object 16,1500,-55,500
texture object 16,2
` Make mor floors
make object box 23,1000,10,1000
position object 23,2500,-55,50
texture object 23,2
make object collision box 23,-500,-5,-500,500,5,500,0
make object box 24,1000,10,1000
position object 24,2500,-55,1050
texture object 24,2
make object collision box 24,-500,-5,-500,500,5,500,0
make object box 25,1000,10,1000
position object 25,1500,-55,1500
texture object 25,2
make object collision box 25,-500,-5,-500,500,5,500,0
make object box 26,1000,500,10
position object 26,1500,200,2000
texture object 26,3
make object collision box 26,-500,-250,-5,500,250,5,0
` Make Moveable box
make object box 27,100,100,50
position object 27,300,158,300
texture object 27,4
make object collision box 27,-50,-50,-25,50,50,25,0
` Make a player object
` load player
load object "idle.x",11
load object "walk.x",11
scale object 11,25,100,25
texture object 11,1
load object "walk.x",11
append object animation "D:\Program Files\Dark Basic Software\Dark Basic\media\models\animated\samurai","D:\Program Files\Dark Basic Software\Dark Basic\media\models\animated\samurai.idle.x",11,100
append object animation "D:\Program Files\Dark Basic Software\Dark Basic\media\models\animated\samurai","D:\Program Files\Dark Basic Software\Dark Basic\media\models\animated\samurai.walk.x",11,10
loop object 11,0,100 : set object speed 11,10
position object 11,150,200,100
make object collision box 11,-5,-2,-5,5,2,5,0
` Make the pedastal use non-rotated box collision
make object collision box 1,-500,-5,-500,500,5,500,0
make object collision box 3,-500,-5,-450,500,5,450,0
make object collision box 2,-500,-5,-500,500,5,500,0
make object collision box 4,-50,-5,-50,50,5,50,0
make object collision box 5,-50,-5,-50,50,5,50,0
` initiate calues
jump#=2
playergrav#=2.0
angle#=0
time#=0
time2#=0
` main loop
do
set text to bold
set cursor 317,50
PRINT "+"
` increment/decrement timers
time#=time#+1
if mouseclick()=0 then timer#=0
` store old positions
oldposx#=object position x(11)
oldposy#=object position y(11)
oldposz#=object position z(11)
` control player object
if keystate(42)=1 then strafe#=1 else strafe#=0
if keystate(32)=1 and strafe#=0 then yrotate object 11,wrapvalue(object angle y(11)+3)
if keystate(30)=1 and strafe#=0 then yrotate object 11,wrapvalue(object angle y(11)-3)
if strafe#=1 then yrotate object 11,cya#
if keystate(32)=1 and strafe#=1
posx#=posx#+cos(cya#/-1)
posz#=posz#+sin(cya#/-1)
position object 11,posx#,posy#,posz#
endif
if keystate(30)=1 and strafe#=1
posx#=posx#-cos(cya#/-1)
posz#=posz#-sin(cya#/-1)
position object 11,posx#,posy#,posz#
endif
if keystate(17)=1 then move object 11,-1.2 : stage=1
if keystate(31)=1 then move object 11,1.2 : stage=1
if mouseclick()=1 and jump#=2 and timer#=0
time2#=time#
playergrav#=2
jump#=jump#-1
jump2#=1
timer#=1
endif
if mouseclick()=0 then jump2#=0
if jump2#=1 and mouseclick()=1 and time#>time2#+25 then playergrav#=-.5
if mouseclick()=1 and jump#=1 and time#>time2#+20 and jump2#=0
time2#=time#
playergrav#=1.0
jump#=jump#-1
jump2#=1
timer#=1
endif
` Store Object angle Y in aY#
AngleY# = object angle Y(11)
If Upkey()=1 then Move object 11,-1 : stage=1
If Leftkey()=1 then Yrotate object 11,Wrapvalue(AngleY#-5)
If Rightkey()=1 then Yrotate object 11,Wrapvalue(AngleY#+5)
if downkey()=1 then move object 11,1 : stage=1
` if character action changes
IF stage=oldstage
IF stage=0
set object frame 11,0.0
loop object 11,4,25
set object speed 11,10
ENDIF
IF stage=1
set object frame 11,0.0
loop object 11,0,10
set object speed 11,10
ENDIF
oldstage=stage
ENDIF
` Get current object position
posx#=object position x(11)
posy#=object position y(11)
posz#=object position z(11)
` increase gravity
playergrav#=playergrav#-0.08
posy#=posy#+playergrav#
` handle sliding collision for ratchet object with other objects
position object 11,posx#,posy#,posz#
if object collision(11,0)>0
objnum#=object collision(11,0)
dec posx#,get object collision x()
dec posz#,get object collision z()
if posy#-5>object position y(objnum#)
dec posy#,get object collision y()
playergrav#=0
jump#=2
jump2#=0
endif
if posy#-5<object position y(objnum#)-(object size y(objnum#)/2.0)
playergrav#=-0.1
dec posy#,get object collision y()
endif
endif
` set a size for the player object (temp)
s#=object size y(11)/2.0
` check for static collisions x&z
if get static collision hit(oldposx#-s#,oldposy#-s#,oldposz#-s#,oldposx#+s#,oldposy#+s#,oldposz#+s#,posx#-s#,posy#-s#,posz#-s#,posx#+s#,posy#+s#,posz#+s#)=1
dec posx#,get static collision x()
dec posz#,get static collision z()
endif
` check for static collisions down
if get static collision hit(oldposx#-s#,oldposy#-s#,oldposz#-s#,oldposx#+s#,oldposy#+s#,oldposz#+s#,posx#-s#+2,posy#-s#,posz#-s#+2,posx#+s#-2,posy#,posz#+s#-2)=1
dec posy#,get static collision y()
playergrav#=0
jump#=2
jump2#=0
endif
` check for static collisions up
if get static collision hit(oldposx#-s#,oldposy#,oldposz#-s#+1,oldposx#+s#,oldposy#+s#,oldposz#+s#,posx#-s#+2,posy#,posz#-s#+2,posx#+s#-2,posy#+s#,posz#+s#-2)=1
posy#=posy#+get static collision y()
playergrav#=-2
endif
` Update with new object position
position object 11,posx#,posy#,posz#
remstart
rem Control Camera
cya#=wrapvalue(cya#+(mousemovex()/3.0))
cxa#=cxa#+(mousemovey()/3.0)
if cxa#<-45.0 then cxa#=-45.0
if cxa#>45.0 then cxa#=45.0
cx#=newxvalue(x#,cya#,sin(cxa#)*10)
cz#=newzvalue(z#,cya#,sin(cxa#)*10)
rotate camera wrapvalue(cxa#),cya#,0
remend
` control camera
cya#=wrapvalue(cya#-(mousemovex()/5.0))
angle#=wrapvalue(angle#-(mousemovey()/3.0))
if angle#>180 then angle#=0
if angle#>80 and angle#<180 then angle#=80
camdist#=cos(angle#)*180
camhigh#=posy#+100+sin(angle#)*90
camfade#=3.5
point camera posx#,posy#+5,posz#
set camera to follow posx#,posy#+5,posz#,cya#,camdist#,camhigh#,camfade#,1
` Handle sliding collision for player object with other objects
position object 11,posx#,posy#,posz#
if object collision(11,27)>0
posx#=object position x(27)
posy#=object position y(27)
posz#=object position z(27)
if posx#>posx#+25
position object 27,posx#+1,posy#,posz#
endif
if posx#<boxx#-25
position object 27,posx#-1,posy#,posz#
endif
if posz#>posz#+25
position object 27,posx#,posy#,posz#+1
endif
if posz#<posz#-25
position object 27,posx#,posy#,posz#-1
endif
endif
if object collision(11,0)>0
dec posx#,get object collision x()
dec posy#,get object collision y()
dec posz#,get object collision z()
playergrav#=0.0
endif
` Ensure camera stays out of static collision boxes
if get static collision hit(oldposx#-s#,oldposy#-s#,oldposz#-s#,oldposx#+s#,oldposy#+s#,oldposz#+s#,posx#-s#,posy#-s#,posz#-s#,posx#+s#,posy#+s#,posz#+s#)=1
dec posx#,get static collision x()
dec posy#,get static collision y()
dec posz#,get static collision z()
if get static collision y()<>0.0 then playergrav#=0.0
endif
` Update with new object position
position object 11,posx#,posy#,posz#
` update screen
sync
` end loop
loop
for t=1 to 26
make static object t
objx#=object position x(t)
objy#=object position y(t)
objz#=object position z(t)
objsx#=object size x(t)/2.0
objsy#=object size y(t)/2.0
objsz#=object size z(t)/2.0
make static collision box objx#-objsx#,objy#-objsy#,objz#-objsz#,objx#+objsx#,objy#+objsy#,objz#+objsz#
delete object t
next t
is there anything i have done wrong or placed in the wrong place? And if so, what