Sorry, i must have done something wrong.
Rem Run Function
Do
Game(1)
Loop
Rem ------->>>> MAIN GAME <<<<-------
Rem ---------------------------------
FUNCTION Game(level)
filename$="Map test g"
style=0
Info=0
AUTOCAM OFF
sync on
squaresize=10
Dim square((650/squaresize),(490/squaresize))
Dim MonsterRON(100)
Dim MonsterDir(100)
Dim MONSoundRON(100)
Dim SkipMonster(100)
Dim DestX(100)
Dim DestZ(100)
Dim InfoString$(50)
Dim CoinRON(200)
Dim Skipcoin(200)
Dim MineAmmoRON(200)
Dim SkipMineAmmo(200)
Dim SkipMine(200)
Dim MineRON(200)
Rem Load Map
OPEN TO Read 1, ("map\"+Filename$+".map")
for by=0 to (480/squaresize)
for bx=0 to (640/squaresize)
Read BYTE 1, square(bx,by)
next bx
next by
Read BYTE 1, style
CLOSE FILE 1
Rem Settings
sync rate 30
a=10
slowingspeed=0.08
B=0
timeA=timer()+100
Monsters=0
Acceleration#=0.05
MonsterSpeed#=1
backdrop on
color backdrop rgb(0,0,0)
Rem Load Media
load image "Weird01.bmp",1
load image "You Died.bmp",2
load image "You Won.bmp",3
load image "Ammo Box Texture.bmp",5
load image "Mine Texture.bmp",6
load image "Fire.bmp",7
load image "Robot Skin.bmp",8
load image "Electronic A.bmp",9
load image "backdrop a.bmp",10
load image "Game Bar 3.bmp",11
Load Sound "Pop.wav",2
Load sound "hallelujah.wav",3
Load sound "JokeDrum.wav",4
Load sound "ShoopCheer2.wav",5
Load sound "50coins.wav",6
Load sound "Reload.wav",7
Load sound "Explode.wav",8
Load 3dsound "elechum.wav",9
If style=2
color backdrop rgb(100,100,200)
rem texture backdrop 4
endif
Rem Objects
Load object "coin1.3ds",7
Load object "Robot a2.3ds",8
Texture object 8,8
MAKE MESH FROM OBJECT 1, 7
MAKE MESH FROM OBJECT 2, 8
Rem Dieing & Winning
make object plain 3,6.4,4.8
position object 3,0,0,4
texture object 3,2
ghost object on 3
lock object on 3
make object plain 5,6.4,4.8
position object 5,0,0,4.01
texture object 5,2
ghost object on 5
lock object on 5
hide object 3
hide object 5
make object plain 4,6.4,4.8
position object 4,0,0,4
texture object 4,3
ghost object on 4
lock object on 4
hide object 4
make object plain 6,6.4,4.8
position object 6,0,0,4
texture object 6,3
ghost object on 6
lock object on 6
hide object 6
Rem Explosion
Make Object Sphere 9,10
Texture Object 9,7
ghost object on 9
hide object 9
Rem music
If style>0
set camera range 1,60
Rem fog on : fog color rgb(0,0,200) : fog distance 60
endif
If style=1
Load sound "computerprocess2.wav",1
set sound volume 1,90
Load Music "SPACE_01.MID",1
Loop music 1
else
Load Music "Safri_01.mid",1
Loop music 1
endif
Rem setup camera
position camera 90,0,90
point camera 0,0,0
Rem Make Map (BY=BZ)
for by=0 to (480/squaresize)
for bx=0 to (640/squaresize)
if square(bx,by)>0 then a=a+1
objects=a
if square(bx,by)=3 then position camera (bx*squaresize),0,(by*squaresize)
If square(bx,by)=4 : Load object "cup.3ds",a : position object a,(bx*10),-2,(by*10) : Scale Object a,5,5,5 : Endif
If square(bx,by)=6 : make object box a,5,3,3 : position object a,(bx*10),-2,(by*10) : Scale Object a,60,60,60 : texture object a,5
mineammo=mineammo+1 : d=d+1 : mineammoRON(d)=A
Endif
Rem Style 1 (Matrix)
If style=1
If square(bx,by)=6 then ghost object on a
If square(bx,by)=5 : MAKE OBJECT a, 1,1 : Color object a,rgb(200,200,0) : ghost object on a : position object a,(bx*10),-2,(by*10) : Scale Object a,5,5,5
Coins=Coins+1 : C=C+1 : CoinRON(C)=A : Endif
if square(bx,by)=2 : MAKE OBJECT a, 2,1 : Scale Object a,35,35,35 : Color object a,rgb(0,200,0)
ghost object on a : position object a,(bx*10),-3,(by*10) : turn object left a,180 : FIX OBJECT PIVOT a : Monsters=Monsters+1 : B=B+1 : MonsterRON(B)=A : endif
if square(bx,by)=1 : make object cube a,10 : position object a,(bx*10),0,(by*10) : Texture object a,9 : Ghost object on a : endif
else
Rem Style 0 (Weird)
if style=0
If square(bx,by)=5 : MAKE OBJECT a, 1,1 : position object a,(bx*10),-2,(by*10) : Scale Object a,5,5,5 : Color Object a, rgb(255,255,0) : Coins=Coins+1 : C=C+1 : CoinRON(C)=A : Endif
if square(bx,by)=1 : make object cube a,10 : position object a,(bx*10),0,(by*10) : Texture object a,1 : endif
if square(bx,by)=2 : MAKE OBJECT a,2,8 : Scale Object a,35,35,35 : position object a,(bx*10),-3,(by*10) : turn object left a,180 : FIX OBJECT PIVOT a
Texture Object a,8 : Monsters=Monsters+1 : B=B+1 : MonsterRON(B)=A : endif
endif
Rem Style 2 (New)
If style=2
If square(bx,by)=5 : MAKE OBJECT a, 1,1 : position object a,(bx*10),-2,(by*10) : Ghost Object on a: Scale Object a,5,5,5 : Color Object a, rgb(255,255,0) : Coins=Coins+1 : C=C+1 : CoinRON(C)=A : Endif
if square(bx,by)=1 : make object cube a,10 : Ghost Object On a : position object a,(bx*10),0,(by*10) : Texture object a,1 : endif
if square(bx,by)=2 : MAKE OBJECT a, 2,1 : Scale Object a,35,35,35 : Ghost object on a
position object a,(bx*10),-3,(by*10) : turn object left a,180 : FIX OBJECT PIVOT a
Color object a,RGB(0,0,255) : Monsters=Monsters+1 : B=B+1 : MonsterRON(B)=A : endif
endif
endif
next bx
next by
Rem Roof
Make object box 1,1000,1,1000
position object 1,300,-5,300
Texture object 1,1
scale object texture 1,100,100
Make object box 2,1000,1,1000
position object 2,300,5,300
Texture object 2,1
scale object texture 2,100,100
rem if style=2 : ghost object on 1 : ghost object on 2 : endif
rem position camera 90,0,90
Rem Setup Monster Sound
sound=20
For b=1 to monsters
CLONE SOUND sound, 9
loop sound sound
MONSoundRON(b)=sound
sound=sound+1
next b
If style=1 then Hide mouse
Rem Loop
Do
Rem 3d Sound
POSITION LISTENER camera position X(), camera position y(), camera position z()
ROTATE LISTENER camera angle X(), camera angle y(), camera angle z()
If style=1 and timer()>(time+2000)
If sound playing(1)=0
if rnd(6)=1 then play sound 1
time=timer()
endif
Endif
Rem Cursor
If style=1 : ink rgb(0,200,0),0 : Line Mousex(),0,Mousex(),479 : Line 0,Mousey(),639,Mousey() : Endif
Rem Explosion
If Explosion=1
If escale#>99
escale#=0.01
Explosion=0
Hide Object 9
endif
If timer()>etime
etime=(Timer()+50)
Escale#=Escale#+10
Scale Object 9,Escale#,Escale#,Escale#
endif
endif
rem If style=2 : scroll backdrop backscr,0 : backscr=backscr+1 : Endif
Gosub Control_Monsters
Rem Gosub Spin_Coins
If timer()>timeA
timeA=timer()+100
GoSub CheckHits
Endif
Rem Info
If info=1
set cursor 0,0
Print "Your Position: ",(cx/squaresize),",",(cz/squaresize)
Print "Monster 1: "
Print "Monster Position: ",int(Object Position X(MonsterRON(1))+5)/squaresize,",",int(Object Position Z(MonsterRON(1))+5)/squaresize
Print "Monster Direction: ",MonsterDir(1)
Print "Monster Destination: ",DestX(1),",",DestZ(1)
Print "Monster 3d: "
Print "Position X: ",Object Position X(MonsterRON(1))
Print "Position Z: ",Object Position Z(MonsterRON(1))
Print "Dest X: ",(DestX(1)*squaresize)
Print "Dest Z: ",(DestZ(1)*squaresize)
endif
Rem Input
if upkey()=1 then speed#=speed#+Acceleration#
if Downkey()=1 then speed#=speed#-Acceleration#
if Mouseclick()=1 then speed#=speed#+Acceleration#
if Mouseclick()=2 then speed#=speed#-Acceleration#
if upkey()=0 and downkey()=0 and speed#>0 and mouseclick()=0 then speed#=speed#-slowingspeed
if upkey()=0 and downkey()=0 and speed#<0 and mouseclick()=0 then speed#=speed#+slowingspeed
if upkey()=0 and downkey()=0 and mouseclick()=0 then speed#=0
if speed#>1.2 then speed#=1.2
if speed#<-0.7 then speed#=-0.7
Turn camera left (((640/2)-MouseX() )/80)
Rem >>> Collisions <<<
cx=(NEWXVALUE(Camera position x(), CAMERA ANGLE X(), Speed#)+5 )
cz=(NEWZVALUE(Camera position z(), CAMERA ANGLE z(), Speed#)+5 )
if speed#>0 then cx=(NEWXVALUE(Camera position x(), CAMERA ANGLE X(), (Speed#+2))+5 )
if speed#<0 then cx=(NEWXVALUE(Camera position x(), CAMERA ANGLE X(), (Speed#-2))+5 )
if speed#>0 then cz=(NEWZVALUE(Camera position z(), CAMERA ANGLE z(), (Speed#+2))+5 )
if speed#<0 then cz=(NEWZVALUE(Camera position z(), CAMERA ANGLE z(), (Speed#-2))+5 )
if square((cx/squaresize),(cz/squaresize))=1
Print "Inside block!"
rem if speed#>0 then speed#=-1
rem if speed#<0 then speed#=1
If whit=0 then speed#=speed#*-2
whit=1
else
whit=0
if square((cx/squaresize),(cz/squaresize))=4 then goto win
Rem Coins
if square((cx/squaresize),(cz/squaresize))=5
play sound 6
Yourcoins=Yourcoins+1
square((cx/squaresize),(cz/squaresize))=0
for c=1 to coins
if skipcoin(c)=0
if Int(object position x(CoinRON(C))+5)/10=cx/squaresize and Int(object position z(CoinRON(C))+5)/10=cz/squaresize
delete object CoinRON(C)
skipcoin(c)=1
exit
endif
Endif
next c
endif
Rem Mine Ammo
if square((cx/squaresize),(cz/squaresize))=6
play sound 7
yourmineammo=yourmineammo+1
square((cx/squaresize),(cz/squaresize))=0
for c=1 to MineAmmo
if skipMineAmmo(c)=0
if Int(object position x(MineAmmoRON(C))+5)/10=cx/squaresize and Int(object position z(MineAmmoRON(C))+5)/10=cz/squaresize
delete object MineAmmoRON(C)
skipMineAmmo(c)=1
exit
endif
endif
next c
endif
Rem Place Mines
If spacekey()=1 and Releasesp=0 and yourmineammo>0
gosub placemine
Releasesp=1
yourmineammo=yourmineammo-1
endif
If spacekey()=0 then Releasesp=0
endif
Move camera speed#
Paste Image 11,0,0,1
ink RGB(46,45,84),0
if style=1 then ink rgb(0,200,0),0
Set text font "Photoshop Small"
Set Text Size 11
Center Text 105,8,"Gold: "+STR$(Yourcoins)
Center Text 523,8,"Mine Ammo: "+STR$(YourMineammo)
Sync
Loop
Rem Control Monsters
Rem <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
REM CODE SECTION UNDER CONSTRUCTION PLEASE BE PATIENT
Rem <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Control_Monsters:
For b=1 to Monsters
If SkipMonster(b)=0
Rem 3d Sound
POSITION SOUND MONSoundRON(b), Object Position X(MonsterRON(b)), 0, Object Position Z(MonsterRON(b))
Rem Check if the need for a New Direction needs to be Examined: NewDir = (0/1)
NewDir = 0
If MonsterDir(b) = 0 then NewDir = 1
If Object Position X(MonsterRON(b)) = (DestX(b)*squaresize)
If Object Position Z(MonsterRON(b)) = (DestZ(b)*squaresize)
NewDir = 1
Endif
Endif
Rem Examine the need for a Change Direction if NewDir is set to 1
If NewDir = 1
Rem Reset/Re-create Blocked Array
Dim Blocked(4)
Rem Find Monster 2D Square Co-ordinates: Mx,Mz
MX = int(Object Position X(MonsterRON(b))+5)/squaresize
MZ = int(Object Position Z(MonsterRON(b))+5)/squaresize
Rem Check Surrounding 2D Squares for Blocks in the order: Up,Right,Down,Left
If Square(Mx,Mz-1) = 1 then Blocked(1) = 1
If Square(Mx+1,Mz) = 1 then Blocked(2) = 1
If Square(Mx,Mz+1) = 1 then Blocked(3) = 1
If Square(Mx-1,Mz) = 1 then Blocked(4) = 1
Rem Decide if Current Direction needs Changing
If Blocked(MonsterDir(b)) = 1 or MonsterDir(b) = 0
Rem Choose a Random Direction that is Allowed
Do
MonsterDir(b) = rnd(3)+1
If Blocked(MonsterDir(b)) = 0 then exit
Loop
Endif
Rem Set Default Destination to Current Position
DestX(b) = Mx : DestZ(b) = Mz
Rem Define 2D Desitnation based upon Direction
If MonsterDir(b) = 1 then DestZ(b) = Mz-1
If MonsterDir(b) = 2 then DestX(b) = Mx+1
If MonsterDir(b) = 3 then DestZ(b) = Mz+1
If MonsterDir(b) = 4 then DestX(b) = Mx-1
Rem Point Monster towards 3D Direction
Point Object MonsterRON(b),(DestX(b)*squaresize),-3,(DestZ(b)*squaresize)
Endif
Rem Move Monsters
Move Object MonsterRON(b),1
If Square(Mx,Mz)=10 then gosub Detonate_Mine
Endif
Next b
Return
Rem 2d to 3d Convertor
convert_2d_to_3d:
outx=(inx*Squaresize)-5
Return
Rem Detonate Mine
Detonate_Mine:
Escale#=0.1
Scale Object 9,Escale#,Escale#,Escale#
Show Object 9
Delete object monsterRON(b)
Play sound 8
Explosion=1
SkipMonster(b)=1
for c=1 to Mines
if SkipMine(c)=0
if Int(object position x(MineRON(C))+5)/10=mx and Int(object position z(MineRON(C))+5)/10=mz
Position Object 9, Object position x(MineRON(C)), -1, Object position z(MineRON(C))
delete object MineRON(C)
SkipMine(c)=1
endif
endif
Next c
return
Rem Check For Monster Attack
CheckHits:
For b=1 to monsters
If skipmonster(b)=0
MX = int(Object Position X(MonsterRON(b))+5)/squaresize
MZ = int(Object Position Z(MonsterRON(b))+5)/squaresize
If Cx/squaresize=mx and Cz/squaresize=mz then goto die
endif
next b
Return
Rem Spin Coins
Spin_Coins:
For c=1 to coins
If OBJECT IN SCREEN(coinRON(c))=1 then Turn object left coinRON(c),3
Next c
Return
Rem Place Mine
Placemine:
objects=objects+1
Mines=Mines+1
a=objects
MineRON(Mines)=a
make object sphere a,1
Texture object a,6
position object a,(Int(cx/squaresize))*10,0,(Int(cz/squaresize))*10
Square((cx/squaresize),(cz/squaresize))=10
Return
Rem Winning
win:
Show Object 4
Show Object 6
Play Sound 3
Play Sound 5
level=level+1
time=timer()
do
Sync
If spacekey()=1 and timer()>time+1000 then goto finish
loop
Rem Dieing
die:
Show Object 3
Show Object 5
Play Sound 2
time=timer()
do
sync
If spacekey()=1 and timer()>time+1000
finish=1
goto finish
endif
loop
Finish:
EndFunction level
http://www.quickerwit.com/que/JsGallery/Games.htm