Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Second Level Help!

Author
Message
InFamous
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 19th Apr 2012 17:40
I need help on creating a second level.I looked at other post and some don't work one is by B1lle.Heres my code.
Rem Project: LTypeDemo
Rem Created: 07/08/2002 05:57:18
rem Tested for: U6.0
_load_level(numlevel 1)


cls 0
load bitmap "U:\Game\Splash Screen.JPG"
ink rgb(0,0,0),0 : set text font "arial" : set text size 14 : set text to bold : set text transparent
center text 320,420,"Developed by The Regulators"
center text 320,434,"Copyright (c) 2004 Ingenious Student Labs"
Sync


rem Init for best performance
sync on : sync rate 60 : backdrop off : hide mouse
if check display mode(1024,768,32)=1 then set display mode 1024,768,32

rem Loading screen
load bitmap "U:\Game\Splash Screen.JPG",1
copy bitmap 1,0,0,680,520,0,0,0,screen width(),screen height()
sync : delete bitmap 1

rem Setup strapline
gosub _create_strap

rem Load sky
set camera range 1,10000
load object "U:\Game\ds.x",1
set object texture 1,2,1
set object light 1,0

rem Load ship
load object "U:\Game\ship.X",101
scale object 101,50,50,50
xrotate object 101,270
fix object pivot 101
rotate object 101,0,0,0
set object specular 101,0
color object 101,RGB(255,255,255)

rem Create landscape
load image "U:\Game\Floor 3.bmp",1
make matrix 1,3000,1500,15,15
prepare matrix texture 1,1,1,1
position matrix 1,-750,-300,0
gosub _newmatrix

rem Ship exhaust
load image "\\vhsstu-docs\home$\150920\Game\Plasma.bmp",11
load image "\\vhsstu-docs\home$\150920\Game\Plasma.bmp",12
load image "media\gfx\debris.bmp",13
make particles 1,11,20,35.0
position particles 1,0,0,500
rotate particles 1,0,0,90
set particle velocity 1,10.0
set particle life 1,5

rem Debris cloud
make particles 21,13,10,200.0
position particles 21,0,0,500
set particle velocity 21,40.0
set particle emissions 21,0
set particle speed 21,0.03
rotate particles 21,90,0,0
set particle life 21,10
hide particles 21

rem Load scuds and rockets
for sc=1 to 9
objid=200+sc
rem scud
load object "U:\Game\Fire.x",objid
scale object objid,1000,1000,1000
position object objid,sc*50,-100,500
set object speed objid,100
set object light objid,0
yrotate object objid,70
hide limb objid,11
play object objid
hide object objid
rem missile
load object "U:\Game\Scud.x",100+objid
scale object 100+objid,500,500,500
set object light 100+objid,0
hide object 100+objid
xrotate object 100+objid,90
fix object pivot 100+objid
rem particle for missile
make particles 1+sc,12,10,30.0
set particle life 1+sc,10
hide particles 1+sc
next sc

rem Make explosion objects
load bitmap "U:\Game\explode.jpg",1
xx#=512.0/4.0
yy#=512.0/4.0
for y=0 to 2
for x=0 to 3
get image 501+x+(y*4),(x*xx#),(y*yy#),(x*xx#)+xx#,(y*yy#)+yy#
next x
next y
get image 513,0,0,32,32
get image 514,0,0,32,32
get image 515,0,0,32,32
get image 516,0,0,32,32
for ex=1 to 5
make object plain 500+ex,256,256
position object 500+ex,0,0,500
set object light 500+ex,0
ghost object on 500+ex,2
set object 500+ex,1,1,1
hide object 500+ex
next ex
delete bitmap 1

rem Create laser for ship
load image "\\vhsstu-docs\home$\150920\Game\Gun Shot.jpg",102
for bu=1 to 5
bobj=101+bu
make object plain bobj,256,64
texture object bobj,102
position object bobj,0,0,500
set object light bobj,0
ghost object on bobj,2
hide object bobj
next bu

rem Load gameover image
load image "media\gfx\gameover.bmp",601
load image "media\gfx\bestmiles.bmp",602

rem Load sounds
load sound "U:\Game\jet.wav",1 : loop sound 1 : set sound volume 1,75
load sound "\\vhsstu-docs\home$\150920\Game\Gun.wav",2 : set sound volume 2,75
load sound "\\vhsstu-docs\home$\150920\Game\Explosion.wav",3 : set sound volume 3,75
load sound "U:\Game\Rocket shot.wav",4 : set sound volume 4,75
load sound "U:\Game\Rocket shot.wav",5 : set sound volume 5,75
load sound "U:\Game\Missile.wav",6 : set sound volume 6,75
load sound "U:\Game\gameover.wav",7 : set sound volume 7,75
load sound "\\vhsstu-docs\home$\150920\Game\Space by Francis Pillar.wav",122 : set sound volume 122,100
loop sound 122

rem Setup camera
set camera fov 30
position camera 0,0,-1000
rotate camera 0,0,0
play sound 6

rem Setup arrays and vars
dim exc(10)
bestmiles=1000
gwrapspeed#=0.0
fuel#=100.0
gameover=0

rem Ensure random different
randomize timer()

rem Main loop
do

rem Control scroll speed
if gameover=0
if gwrapspeed#<8.0 then gwrapspeed#=gwrapspeed#+0.1
else
rem game over prompt
position camera camera position x(),camera position y()+3.0,camera position z()
if bestgame=0 then paste image 601,(screen width()-512)/2,(screen height()-256)/2,1
if bestgame=1 then paste image 602,(screen width()-512)/2,(screen height()-256)/2,1
dec gameovercount
rem restart game
if gameovercount<=0
rem reset camera
position camera 0,0,-1000
rem reset ship
rotate object 101,0,0,0
show particles 1
show object 101
sx#=0 : sy#=0
fuel#=100.0
miles#=0.0
loop sound 1
rem reset matrix
gosub _newmatrix
rem reset scuds
for sc=1 to 9 : hide object 200+sc : position object 200+sc,10000,0,0 : next sc
rem reset missiles
for sc=1 to 9 : hide object 300+sc : hide particles 1+sc : next sc
rem reset game
play sound 6
gameover=0
bestgame=0
miles=0
endif
endif

rem Control ship
lift=0 : firegun=0
if gameover=0 and killship=0
if upkey()=1 and sy#<350.0 then iy#=10.0 : lift=1
if fuel#<2.0 then iy#=-1.0
if downkey()=1 then iy#=-10.0 : lift=2
if leftkey()=1 and sx#>-450.0 then ix#=-10.0
if rightkey()=1 and sx#<450.0 then ix#=10.0
if spacekey()=1 then firegun=1
ix#=ix#/1.2 : iy#=iy#/1.2
sx#=sx#+ix# : sy#=sy#+iy#
if Inkey$()="f" then fuel#=100.0
if Inkey$()="a" then miles=miles+250.0
if Inkey$()="s" then gwrapspeed#=100.0
if Inkey$()="d" then gwrapspeed#=0.0
if Inkey$()="m" then xrotate object 101,90
position object 101,sx#,sy#,500
endif

rem Ensure ship cannot enter ground
gh#=get matrix height(1,7+((sx#-200)/200.0),5)-300
if sy#<gh# and gameover=0
rem ship explodes
if abs(sy#-gh#)>30.0
killship=1
else
sy#=gh#
endif
endif

rem Animate ship
if lift=1 then srx#=srx#+0.8
if lift=2 then srx#=srx#-0.8
xrotate object 101,srx#
srx#=srx#/1.05

rem Make particles emerge from ship
position particles 1,sx#-20,sy#+5,500+25

rem Control wrapping sky
yrotate object 1,wrapvalue(object angle y(1)-(gwrapspeed#/16.0))

rem Control tilt of camera
tiltc#=curveangle(iy#*-1.0,tiltc#,20.0)
zrotate camera tiltc#

rem Control ground wrapping
gwrap#=gwrap#+gwrapspeed#
if gwrap#>=400.0
rem shift old ground
gwrap#=gwrap#-400.0
shift matrix left 1 : shift matrix left 1
rem create new ground
mh#=rnd(500)
set matrix height 1,13,0,0
set matrix height 1,14,0,0
for z=1 to 13
h#=mh#*cos((z-7)*20)
set matrix height 1,13,z,h#
set matrix height 1,14,z,h#
if z=5 then platy#=h#
mh#=mh#+(rnd(20)-10)
next z
set matrix height 1,13,14,0
set matrix height 1,14,14,0
update matrix 1
rem if random chance
if rnd(3)=0
rem place scud
for sc=1 to 9
objid=200+sc
if object visible(objid)=0 and object visible(100+objid)=0 then exit
next sc
if sc<=9
position object objid,(3000-750)-500,-300+platy#,500
yrotate object objid,45+rnd(60)
show object objid
endif
endif
endif
position matrix 1,-750-200-gwrap#,-300,0

rem Control scuds
for sc=1 to 9
rem keep with ground
objid=200+sc
position object objid,object position x(objid)-gwrapspeed#,object position y(objid),object position z(objid)
rem if close to X of ship, fire
if abs((sx#+400+rnd(200))-object position x(objid))<200.0 and object playing(objid)=0 and gameover=0
rem fire animation
loop object objid,25,25
set object frame objid,0
endif
if object playing(objid)=1 and object frame(objid)>10 and object visible(objid)=1 and object visible(100+objid)=0
rem position missile
position object 100+objid,object position x(objid)+50,object position y(objid)+10,object position z(objid)
rotate object 100+objid,270,0,60
position particles 1+sc,50,-300,0
show object 100+objid
show particles 1+sc
play sound 4
endif
rem keep missiles with ground too
position object 100+objid,object position x(100+objid)-8.0,object position y(100+objid),object position z(100+objid)
position particles 1+sc,particles position x(1+sc)-8.0,-300,0
position particle emissions 1+sc,object position x(objid)/30.0,(object position y(100+objid)+300)/30.0,object position z(100+objid)/30.0
rem when off screen, reset
if object position x(objid)<-600
hide object objid
stop object objid
set object frame objid,0
endif
rem control missile
if object visible(100+objid)=1
rem move until leave
position object 100+objid,object position x(100+objid)-gwrapspeed#,object position y(100+objid)+4.0,object position z(100+objid)
rem when leave screen
if object position x(100+objid)<-3000 or object position y(100+objid)>2000
hide object 100+objid
hide particles 1+sc
endif
endif
if object visible(100+objid)=1
rem when hit ship
dx#=abs(object position x(100+objid)-sx#)
dy#=abs(object position y(100+objid)-sy#)
if dx#<10 and dy#<50 then killship=1
endif
next sc

rem Fire the ships gun
if guncool>0 then dec guncool
if firegun=1 and guncool=0
for bu=1 to 5
bobj=101+bu
if object visible(bobj)=0 then exit
next bu
if bopbj<=106
position object bobj,sx#,sy#,500+25
show object bobj
guncool=5 : fuel#=fuel#-0.05
play sound 2
endif
endif

rem Handle bullets
for bu=1 to 5
bobj=101+bu
if object visible(bobj)=1
rem move bullet
position object bobj,object position x(bobj)+64,object position y(bobj),object position z(bobj)
if object position x(bobj)>500 then hide object bobj
endif
if object visible(bobj)=1
rem ensure bullet cannot enter ground
gh#=get matrix height(1,7+((object position x(bobj)-200)/200.0),4)-300
if object position y(bobj)<gh# then hide object bobj
rem bullet can destroy scuds
for sc=1 to 9
dx#=abs(object position x(bobj)-object position x(200+sc))
dy#=abs(object position y(bobj)-object position y(200+sc))
if dx#<50 and dy#<50.0 and object visible(200+sc)=1
rem trigger scud explosion
hide object bobj : hide object 200+sc
for ex=2 to 5 : if exc(ex)=0 : exit : endif : next ex
if ex<=5 then exc(ex)=501 : position object 500+ex,object position x(200+sc),object position y(200+sc),500+25 : show object 500+ex
rem gain some fuel
fuel#=fuel#+10.0 : if fuel#>100.0 then fuel#=100.0
rem make a noise
play sound 5
endif
next sc
endif
next bu

rem Trigger ship explosion
if killship=1 and shipexplosion=0
ex=1 : exc(ex)=501 : position object 500+ex,sx#-20,sy#+5,500+25
show object 500+ex
hide particles 1
position particles 21,sx#-20,sy#+5,500+25
set particle emissions 21,20
show particles 21
play sound 3
shipexplosion=1
endif

rem Control explosions
for ex=1 to 5
if exc(ex)>0
exc(ex)=exc(ex)+1
if exc(ex)>515
rem end particle and explosion
set particle emissions 21,0
hide object 500+ex
exc(ex)=0
if ex=1
rem destroy ship
stop sound 1
hide object 101
shipexplosion=0
killship=0
gameover=1 : gameovercount=200
play sound 7
endif
else
rem update explosion
texture object 500+ex,exc(ex)
if ex=1
rem rock ship
rotate object 101,object angle x(101)+10,object angle y(101)+5,object angle z(101)+15
endif
endif
endif
next ex

rem During game
if gameover=0

rem Reduce fuel slowly
fuel#=fuel#-0.05 : if fuel#<0 then fuel#=0.0

rem Gain miles slowly
miles=miles+1 : miles#=miles#+0.01 : if miles#>100.0 then miles#=100.0

endif

rem Show fuel
set cursor 0,0 : print "FUEL"
if fuel#<20 then rr=255 else rr=0
box 32,2,38+((screen width()-16)/100)*fuel#,10,rgb(rr,100,100),rgb(rr,100,100),rgb(rr,255,255),rgb(rr,255,255)

rem Show miles
set cursor 0,13 : print "MILE"
box 32,15,38+((screen width()-16)/100)*miles#,15+8,rgb(0,100,0),rgb(0,100,0),rgb(0,255,0),rgb(0,255,0)
set cursor (38+((screen width()-16)/100)*miles#)+4,13 : print str$(miles)

rem Record and show best miles
set cursor screen width()-110,13 : print "BEST MILES "+str$(bestmiles)
if miles>bestmiles then bestmiles=miles : bestgame=1

rem Move strap line
gosub _control_strap

rem Update screen
sync

rem Endloop
loop

_newmatrix:
tr#=50
for x=0 to 15
set matrix height 1,x,0,0
for z=1 to 14
h#=cos((z-7)*20)*100.0
h#=h#+tr#
if x<13 then h#=250.0
n#=0.25+(rnd(10)*0.75)
n#=n#*cos((z-8)*20)
set matrix height 1,x,z,h#
set matrix normal 1,x,z,n#,n#,n#
next z
set matrix height 1,x,14,0
tr#=tr#+(rnd(50)-25)
next x
update matrix 1
return

rem Demo Subroutines
_create_strap:
load image "\\vhsstu-docs\home$\150920\Game\moon fact 2.bmp",2
Load Image "U:\Game\moon fact 1.bmp",4
load image "media\gfx\strapblank.bmp",3
strapx1=0
strapx2=1024
return

_control_strap:
dec strapx1 : if strapx1<=-1024 then strapx1=strapx2+1023
dec strapx2 : if strapx2<=-1023 then strapx2=strapx1+1024
sprite 1,strapx1,screen height()-63,2
sprite 2,strapx2,screen height()-63,3
set sprite alpha 1,196
set sprite alpha 2,196
set sprite 1,0,1
return
If miles is >200 then gosub _load_level(numlevel 2)


return
_load_level(numlevel 2)


cls 0
load bitmap "U:\Game\Splash Screen.JPG"
ink rgb(0,0,0),0 : set text font "arial" : set text size 14 : set text to bold : set text transparent
center text 320,420,"Developed by The Regulators"
center text 320,434,"Copyright (c) 2004 Ingenious Student Labs"
Sync


rem Init for best performance
sync on : sync rate 60 : backdrop off : hide mouse
if check display mode(1024,768,32)=1 then set display mode 1024,768,32

rem Loading screen
load bitmap "U:\Game\Splash Screen.JPG",1
copy bitmap 1,0,0,680,520,0,0,0,screen width(),screen height()
sync : delete bitmap 1

rem Setup strapline
gosub _create_strap

rem Load sky
set camera range 1,10000
load object "U:\Game\ds.x",1
set object texture 1,2,1
set object light 1,0

rem Load ship
load object "U:\Game\ship.X",101
scale object 101,50,50,50
xrotate object 101,270
fix object pivot 101
rotate object 101,0,0,0
set object specular 101,0
color object 101,RGB(255,255,255)

rem Create landscape
load image "U:\Game\Floor 3.bmp",1
make matrix 1,3000,1500,15,15
prepare matrix texture 1,1,1,1
position matrix 1,-750,-300,0
gosub _newmatrix

rem Ship exhaust
load image "\\vhsstu-docs\home$\150920\Game\Plasma.bmp",11
load image "\\vhsstu-docs\home$\150920\Game\Plasma.bmp",12
load image "media\gfx\debris.bmp",13
make particles 1,11,20,35.0
position particles 1,0,0,500
rotate particles 1,0,0,90
set particle velocity 1,10.0
set particle life 1,5

rem Debris cloud
make particles 21,13,10,200.0
position particles 21,0,0,500
set particle velocity 21,40.0
set particle emissions 21,0
set particle speed 21,0.03
rotate particles 21,90,0,0
set particle life 21,10
hide particles 21

rem Load scuds and rockets
for sc=1 to 9
objid=200+sc
rem scud
load object "U:\Game\Fire.x",objid
scale object objid,1000,1000,1000
position object objid,sc*50,-100,500
set object speed objid,100
set object light objid,0
yrotate object objid,70
hide limb objid,11
play object objid
hide object objid
rem missile
load object "U:\Game\Scud.x",100+objid
scale object 100+objid,500,500,500
set object light 100+objid,0
hide object 100+objid
xrotate object 100+objid,90
fix object pivot 100+objid
rem particle for missile
make particles 1+sc,12,10,30.0
set particle life 1+sc,10
hide particles 1+sc
next sc

rem Make explosion objects
load bitmap "U:\Game\explode.jpg",1
xx#=512.0/4.0
yy#=512.0/4.0
for y=0 to 2
for x=0 to 3
get image 501+x+(y*4),(x*xx#),(y*yy#),(x*xx#)+xx#,(y*yy#)+yy#
next x
next y
get image 513,0,0,32,32
get image 514,0,0,32,32
get image 515,0,0,32,32
get image 516,0,0,32,32
for ex=1 to 5
make object plain 500+ex,256,256
position object 500+ex,0,0,500
set object light 500+ex,0
ghost object on 500+ex,2
set object 500+ex,1,1,1
hide object 500+ex
next ex
delete bitmap 1

rem Create laser for ship
load image "\\vhsstu-docs\home$\150920\Game\Gun Shot.jpg",102
for bu=1 to 5
bobj=101+bu
make object plain bobj,256,64
texture object bobj,102
position object bobj,0,0,500
set object light bobj,0
ghost object on bobj,2
hide object bobj
next bu

rem Load gameover image
load image "media\gfx\gameover.bmp",601
load image "media\gfx\bestmiles.bmp",602

rem Load sounds
load sound "U:\Game\jet.wav",1 : loop sound 1 : set sound volume 1,75
load sound "\\vhsstu-docs\home$\150920\Game\Gun.wav",2 : set sound volume 2,75
load sound "\\vhsstu-docs\home$\150920\Game\Explosion.wav",3 : set sound volume 3,75
load sound "U:\Game\Rocket shot.wav",4 : set sound volume 4,75
load sound "U:\Game\Rocket shot.wav",5 : set sound volume 5,75
load sound "U:\Game\Missile.wav",6 : set sound volume 6,75
load sound "U:\Game\gameover.wav",7 : set sound volume 7,75
load sound "\\vhsstu-docs\home$\150920\Game\Space by Francis Pillar.wav",122 : set sound volume 122,100
loop sound 122

rem Setup camera
set camera fov 30
position camera 0,0,-1000
rotate camera 0,0,0
play sound 6

rem Setup arrays and vars
dim exc(10)
bestmiles=1000
gwrapspeed#=0.0
fuel#=100.0
gameover=0

rem Ensure random different
randomize timer()

rem Main loop
do

rem Control scroll speed
if gameover=0
if gwrapspeed#<8.0 then gwrapspeed#=gwrapspeed#+0.1
else
rem game over prompt
position camera camera position x(),camera position y()+3.0,camera position z()
if bestgame=0 then paste image 601,(screen width()-512)/2,(screen height()-256)/2,1
if bestgame=1 then paste image 602,(screen width()-512)/2,(screen height()-256)/2,1
dec gameovercount
rem restart game
if gameovercount<=0
rem reset camera
position camera 0,0,-1000
rem reset ship
rotate object 101,0,0,0
show particles 1
show object 101
sx#=0 : sy#=0
fuel#=100.0
miles#=0.0
loop sound 1
rem reset matrix
gosub _newmatrix
rem reset scuds
for sc=1 to 9 : hide object 200+sc : position object 200+sc,10000,0,0 : next sc
rem reset missiles
for sc=1 to 9 : hide object 300+sc : hide particles 1+sc : next sc
rem reset game
play sound 6
gameover=0
bestgame=0
miles=0
endif
endif

rem Control ship
lift=0 : firegun=0
if gameover=0 and killship=0
if upkey()=1 and sy#<350.0 then iy#=10.0 : lift=1
if fuel#<2.0 then iy#=-1.0
if downkey()=1 then iy#=-10.0 : lift=2
if leftkey()=1 and sx#>-450.0 then ix#=-10.0
if rightkey()=1 and sx#<450.0 then ix#=10.0
if spacekey()=1 then firegun=1
ix#=ix#/1.2 : iy#=iy#/1.2
sx#=sx#+ix# : sy#=sy#+iy#
if Inkey$()="f" then fuel#=100.0
if Inkey$()="a" then miles=miles+250.0
if Inkey$()="s" then gwrapspeed#=100.0
if Inkey$()="d" then gwrapspeed#=0.0
if Inkey$()="m" then xrotate object 101,90
position object 101,sx#,sy#,500
endif

rem Ensure ship cannot enter ground
gh#=get matrix height(1,7+((sx#-200)/200.0),5)-300
if sy#<gh# and gameover=0
rem ship explodes
if abs(sy#-gh#)>30.0
killship=1
else
sy#=gh#
endif
endif

rem Animate ship
if lift=1 then srx#=srx#+0.8
if lift=2 then srx#=srx#-0.8
xrotate object 101,srx#
srx#=srx#/1.05

rem Make particles emerge from ship
position particles 1,sx#-20,sy#+5,500+25

rem Control wrapping sky
yrotate object 1,wrapvalue(object angle y(1)-(gwrapspeed#/16.0))

rem Control tilt of camera
tiltc#=curveangle(iy#*-1.0,tiltc#,20.0)
zrotate camera tiltc#

rem Control ground wrapping
gwrap#=gwrap#+gwrapspeed#
if gwrap#>=400.0
rem shift old ground
gwrap#=gwrap#-400.0
shift matrix left 1 : shift matrix left 1
rem create new ground
mh#=rnd(500)
set matrix height 1,13,0,0
set matrix height 1,14,0,0
for z=1 to 13
h#=mh#*cos((z-7)*20)
set matrix height 1,13,z,h#
set matrix height 1,14,z,h#
if z=5 then platy#=h#
mh#=mh#+(rnd(20)-10)
next z
set matrix height 1,13,14,0
set matrix height 1,14,14,0
update matrix 1
rem if random chance
if rnd(3)=0
rem place scud
for sc=1 to 9
objid=200+sc
if object visible(objid)=0 and object visible(100+objid)=0 then exit
next sc
if sc<=9
position object objid,(3000-750)-500,-300+platy#,500
yrotate object objid,45+rnd(60)
show object objid
endif
endif
endif
position matrix 1,-750-200-gwrap#,-300,0

rem Control scuds
for sc=1 to 9
rem keep with ground
objid=200+sc
position object objid,object position x(objid)-gwrapspeed#,object position y(objid),object position z(objid)
rem if close to X of ship, fire
if abs((sx#+400+rnd(200))-object position x(objid))<200.0 and object playing(objid)=0 and gameover=0
rem fire animation
loop object objid,25,25
set object frame objid,0
endif
if object playing(objid)=1 and object frame(objid)>10 and object visible(objid)=1 and object visible(100+objid)=0
rem position missile
position object 100+objid,object position x(objid)+50,object position y(objid)+10,object position z(objid)
rotate object 100+objid,270,0,60
position particles 1+sc,50,-300,0
show object 100+objid
show particles 1+sc
play sound 4
endif
rem keep missiles with ground too
position object 100+objid,object position x(100+objid)-8.0,object position y(100+objid),object position z(100+objid)
position particles 1+sc,particles position x(1+sc)-8.0,-300,0
position particle emissions 1+sc,object position x(objid)/30.0,(object position y(100+objid)+300)/30.0,object position z(100+objid)/30.0
rem when off screen, reset
if object position x(objid)<-600
hide object objid
stop object objid
set object frame objid,0
endif
rem control missile
if object visible(100+objid)=1
rem move until leave
position object 100+objid,object position x(100+objid)-gwrapspeed#,object position y(100+objid)+4.0,object position z(100+objid)
rem when leave screen
if object position x(100+objid)<-3000 or object position y(100+objid)>2000
hide object 100+objid
hide particles 1+sc
endif
endif
if object visible(100+objid)=1
rem when hit ship
dx#=abs(object position x(100+objid)-sx#)
dy#=abs(object position y(100+objid)-sy#)
if dx#<10 and dy#<50 then killship=1
endif
next sc

rem Fire the ships gun
if guncool>0 then dec guncool
if firegun=1 and guncool=0
for bu=1 to 5
bobj=101+bu
if object visible(bobj)=0 then exit
next bu
if bopbj<=106
position object bobj,sx#,sy#,500+25
show object bobj
guncool=5 : fuel#=fuel#-0.05
play sound 2
endif
endif

rem Handle bullets
for bu=1 to 5
bobj=101+bu
if object visible(bobj)=1
rem move bullet
position object bobj,object position x(bobj)+64,object position y(bobj),object position z(bobj)
if object position x(bobj)>500 then hide object bobj
endif
if object visible(bobj)=1
rem ensure bullet cannot enter ground
gh#=get matrix height(1,7+((object position x(bobj)-200)/200.0),4)-300
if object position y(bobj)<gh# then hide object bobj
rem bullet can destroy scuds
for sc=1 to 9
dx#=abs(object position x(bobj)-object position x(200+sc))
dy#=abs(object position y(bobj)-object position y(200+sc))
if dx#<50 and dy#<50.0 and object visible(200+sc)=1
rem trigger scud explosion
hide object bobj : hide object 200+sc
for ex=2 to 5 : if exc(ex)=0 : exit : endif : next ex
if ex<=5 then exc(ex)=501 : position object 500+ex,object position x(200+sc),object position y(200+sc),500+25 : show object 500+ex
rem gain some fuel
fuel#=fuel#+10.0 : if fuel#>100.0 then fuel#=100.0
rem make a noise
play sound 5
endif
next sc
endif
next bu

rem Trigger ship explosion
if killship=1 and shipexplosion=0
ex=1 : exc(ex)=501 : position object 500+ex,sx#-20,sy#+5,500+25
show object 500+ex
hide particles 1
position particles 21,sx#-20,sy#+5,500+25
set particle emissions 21,20
show particles 21
play sound 3
shipexplosion=1
endif

rem Control explosions
for ex=1 to 5
if exc(ex)>0
exc(ex)=exc(ex)+1
if exc(ex)>515
rem end particle and explosion
set particle emissions 21,0
hide object 500+ex
exc(ex)=0
if ex=1
rem destroy ship
stop sound 1
hide object 101
shipexplosion=0
killship=0
gameover=1 : gameovercount=200
play sound 7
endif
else
rem update explosion
texture object 500+ex,exc(ex)
if ex=1
rem rock ship
rotate object 101,object angle x(101)+10,object angle y(101)+5,object angle z(101)+15
endif
endif
endif
next ex

rem During game
if gameover=0

rem Reduce fuel slowly
fuel#=fuel#-0.05 : if fuel#<0 then fuel#=0.0

rem Gain miles slowly
miles=miles+1 : miles#=miles#+0.01 : if miles#>100.0 then miles#=100.0

endif

rem Show fuel
set cursor 0,0 : print "FUEL"
if fuel#<20 then rr=255 else rr=0
box 32,2,38+((screen width()-16)/100)*fuel#,10,rgb(rr,100,100),rgb(rr,100,100),rgb(rr,255,255),rgb(rr,255,255)

rem Show miles
set cursor 0,13 : print "MILE"
box 32,15,38+((screen width()-16)/100)*miles#,15+8,rgb(0,100,0),rgb(0,100,0),rgb(0,255,0),rgb(0,255,0)
set cursor (38+((screen width()-16)/100)*miles#)+4,13 : print str$(miles)

rem Record and show best miles
set cursor screen width()-110,13 : print "BEST MILES "+str$(bestmiles)
if miles>bestmiles then bestmiles=miles : bestgame=1

rem Move strap line
gosub _control_strap

rem Update screen
sync

rem Endloop
loop

_newmatrix:
tr#=50
for x=0 to 15
set matrix height 1,x,0,0
for z=1 to 14
h#=cos((z-7)*20)*100.0
h#=h#+tr#
if x<13 then h#=250.0
n#=0.25+(rnd(10)*0.75)
n#=n#*cos((z-8)*20)
set matrix height 1,x,z,h#
set matrix normal 1,x,z,n#,n#,n#
next z
set matrix height 1,x,14,0
tr#=tr#+(rnd(50)-25)
next x
update matrix 1
return

rem Demo Subroutines
_create_strap:
load image "\\vhsstu-docs\home$\150920\Game\moon fact 2.bmp",2
Load Image "U:\Game\moon fact 1.bmp",4
load image "media\gfx\strapblank.bmp",3
strapx1=0
strapx2=1024
return

_control_strap:
dec strapx1 : if strapx1<=-1024 then strapx1=strapx2+1023
dec strapx2 : if strapx2<=-1023 then strapx2=strapx1+1024
sprite 1,strapx1,screen height()-63,2
sprite 2,strapx2,screen height()-63,3
set sprite alpha 1,196
set sprite alpha 2,196
set sprite 1,0,1
return

ZERO
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 21st Apr 2012 20:11
Um, code goes in code snippets:

Click the "Edit" link that appears in the left-hand pane next to your post to edit it.

Posting 100's of km's of code will make people less inclined to respond to your post (because it appears as one big mess this way). Just some advice, not meant in any way disrespectful so plz don't curse me (I have enough bad voodoo on me as it stands).

About making a second level, perhaps it would be best if you started from scratch instead of trying to modify or adapt another program (Correct me if I'm wrong but that looks awfully like one of the demos that come with DBPro).

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 22nd Apr 2012 23:57
First off, what you have listed does not even compile. At least one problem is
. You list it first thing in your code as if it is a function, yet later on you call it as a subroutine. Neither one will work, as your syntax is incorrect.

The demo code already has a level creator in it (see the _newmatrix subroutine). What you could do is set a variable, such as NumLevel, to a value that corresponds with the level you want to create and then gosub the _newmatrix subroutine. Something like this (set NumLevel to a value of 1 or 2 first and then simply
):



With this example, you would always be using matrix 1, you would just reconfigure it to a different shape. You could, of course, delete matrix 1 and plug in another matrix.

So many games to code.......so little time.

InFamous
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 23rd Apr 2012 17:09
Yes it is the demo ,im in video desigh in school and my teacher wants us to use the prototypes.Thats why im not familure with the coding.Second level is one of our grading scales so i need help on the coding...Sorry about puting that into a snippet..LOL.

ZERO
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 24th Apr 2012 01:24
The code appears to be generating new terrain on the fly. Look right after the words
and you will see what I am talking about.

What you need to do is decide how far you want the player to go before a new level is started. You could establish a variable, say MilesToGo. To start, set MilesToGo = 1500 sometime in the code before your main do - loop starts.

Then, within the do - loop, (I would suggest somewhere near where the miles are displayed), check to see if miles >= MilesToGo. If it is, you make some sort of congratulatory statement (graphic, text, whatever you want) to tell the player they have succeeded. Add something to the MilesToGo variable to make it more challenging for the next level, say another 100. You will need to reset Miles to 0 at that point too.

I would suggest while you are displaying the congrats for completing the level that you also tell the player what input is needed to start the next level (i.e. Press return key to begin the next level). You might even want to display how many miles they have to go for the next level.

By the way, I noticed you posted the code (in your first post) twice. I hope it is not like that in the code you are working on.

So many games to code.......so little time.

InFamous
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 26th Apr 2012 17:19
I think i got in part of the coding ,but now coming to new errors what to do in the errors of coulg not close nest.Heres the codeing.



ZERO
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 26th Apr 2012 18:41 Edited at: 26th Apr 2012 18:58
There are a few issues:
You have listed
in the code, and this is not a valid command. The
command should be listed on the line after the line that has the
command on it.

Sorry, I did not explain very well that you no longer need to use a variable for NumLevel. Instead, you are using the variable, MilesToGo, to determine when the end of the level has been reached. Since I don't have the media for this, I cannot actually run the code to see the results. After looking at it more closely, I realized the terrain is continually being regenerated.

Anyway, another error was being caused when you listed
without an
.
Since you don't need the NumLevel variable anymore, delete it altogether.

Additionally, you listed if miles# >= MilesToGo with no endif. An Endif is required unless you use the THEN command in the statement. Some examples of working code to clarify:




NOTE: They have used a float for miles# (hence the # sign after it) instead of miles, which is an integer. You'll need to change them to miles#.

It is good programming practice to indent your code. This helps you find errors such as these and makes it more readable.

This code compiles okay. Check it out.


So many games to code.......so little time.

InFamous
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 26th Apr 2012 22:24
That fixed alot of problems ,but caused a two minor problems.One my jet is now facing the screen instead of facing forward,and now the best miles bar which indicates how far you went...fills up completely and stayes at what is either a 1500 or 150...

ZERO
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 27th Apr 2012 03:40
Quote: "One my jet is now facing the screen instead of facing forward"


I don't think anything I gave you would have caused the ship to be rotated 90 degrees. There are different filenames used for the ship. Are they the same model with a different name or are they different models? Anyway, you can fix this by changing the Y axis rotation.

The pertinent code in your most recent snippet looks like this:



Change the
to
and it should work.


Quote: "now the best miles bar which indicates how far you went...fills up completely and stayes at what is either a 1500 or 150..."


Bear in mind that I cannot actually run this program, so I am only doing what makes sense to me. I think the problem is this line:


try replacing it with this:


In the original code they were using miles (integer) and miles# (float). That seemed unnecessary. I made all of them a float and it likely affected this. If you are running at 60 FPS (or somewhere thereabouts), you would in theory go about 30 miles per second. A 1500 mile flight should take about 50 seconds to complete. Seems like a reasonable time frame for a level.

The miles# info is displayed on screen using this code:



This could be better coded by using the following code in it's place:



So many games to code.......so little time.

InFamous
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 27th Apr 2012 16:55
That fixed everything so now where does my coding for second level go or how do i use the first matrix game uses already....(The miles to go when it reaches 1500...it resets to zero but game does not restart....)

ZERO
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 29th Apr 2012 22:55 Edited at: 29th Apr 2012 22:57
In your main do - loop, there is an if / endif that tests the value of the gameover variable. If it is 0, the wrapspeed# value is increased if it is less than 8.0. If gameover does not equal 0, then there are several instructions that are executed. This should give you a clue as to what is needed if you reach the end of a level. Again, I cannot run this, but it seems like you could put this code in place and it will work:


You already should have
in place, just add the extra code in there.

Also, at no extra charge, I am throwing in a function that will congratulate the player upon reaching the end of a level. It is nothing fancy, but should give you something to build upon.


So many games to code.......so little time.

InFamous
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 30th Apr 2012 16:51
It now says hit a function declaration mid program...I also want to put my code into an executable for you,but i think you use the attachment anyway ill try it...

ZERO

Attachments

Login to view attachments
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 30th Apr 2012 21:53
Quote: "It now says hit a function declaration mid program"


Where did you place the Celebrate() function that I gave you? It should be placed at the end of the code. Always have an END statement right after the main do-loop and place functions after that.

Quote: "I also want to put my code into an executable for you,but i think you use the attachment anyway ill try it..."


You posted the .dbpro file, which will not run without the .dba file. An .exe with the fair amount of media that you have listed will probably be a pretty large file. Also, you will have to set up the editor to include the media in the .exe (depends on the editor as to how you do that).

I could probably rem out most of the media or create placeholders in order to run the program.

So many games to code.......so little time.

InFamous
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 2nd May 2012 17:04
SO SECOND LEVEL CODING WILL BE PUT WHERE.OR SHOULD I USE MATRIX BECAUSE I TRIED USING SAME MATRIX BUT IT SAYS THAT ALOT OF THE OBJECTS ALREADY EXIST...I WOULD LIKE TO MAKE A NEW MATRIX BUT WOULDNT THAT MESS UP THE REST OF MY CODING....ALSO I WANT TO PUT A SKYSPHERE SO MY IMAGES ARNT TILED IN BACKGROUND SO WOULD I DELETE BACKGROUND MAKE SPHERE PUT NEGATIVE INTEGERS AND PLACE IMAGE ON SPHERE?

ZERO
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 2nd May 2012 17:31
There really is little to do to create additional levels, as the terrain is generated on the fly. I gave you the code that should set up additional levels as needed (see the snippet where miles# > MilesToGo). You could put in more scuds if you wanted. You have a fixed number of nine. You could create as many as you want and hide the extra ones until they are needed. You could use a variable to control how many scuds are on each level.

Regarding the skysphere, they are typically used when you are moving around in an environment. Since you are moving in only one direction I would suggest texturing the backdrop or perhaps placing a plane behind the matrix and texturing it. You could then scroll the backdrop (using scroll backdrop) or a plane (using scroll object texture) to give the appearance of movement.

So many games to code.......so little time.

InFamous
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 4th May 2012 17:43
Okay got it now i want to add soliders but i think i forgot to use an END or Endif cause now it says command out of place at line 478.When deleted it say stuff about the celebration function and when thats removed could not close nest is created.Why?


ZERO
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 4th May 2012 17:57
You forgot to close the for / next loop when creating the soldiers. See here:


Sometimes DBP does not place the cursor on the line that actually caused the error, so you have to look above that until you locate the error.

So many games to code.......so little time.

InFamous
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 7th May 2012 17:48
Now it says object number already exsist at line 93.I dont understand why but i think its this
for it is the only line before 93 about solider or the object number,but removing it and other lines of code assosiated with it creates a mess of problems.

ZERO
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 7th May 2012 19:12 Edited at: 7th May 2012 19:15
You likely have created a scud using that object number - see this code
a few lines up. So, to fix the immediate problem, change this


to this



Be sure to change all of the references to the soliders' objects from 200 to 209.

I prefer to create object numbers in order as I go, that way I don't duplicate them. Additionally, if I want to delete all of the objects before I exit the game it is easy to do. I would suggest you revise your code accordingly. Anyway, after this code (near the start of your program)


add the following code:


Some will code this as
, I like writing them separately.

When you create an object, here is an example of how to do it:



another way you can do it:




You must always increment the NextObject variable, otherwise you will get the same error.

I hope this is helpful.

So many games to code.......so little time.

InFamous
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 8th May 2012 17:08
Oh so since the scud is generating 9 the number of objects number it uses goes from 200-209.thats why useing the object number 200 for my soliders.Thanks.

ZERO

Login to post a reply

Server time is: 2024-11-22 00:19:21
Your offset time is: 2024-11-22 00:19:21