Ok, here is the entire source code (didnt want to post it before since its very long; 885 lines). Do you see whats wrong?
REM Project: Fighters Gold
REM Created: 2006-05-02 11:56:32
REM
REM ***** Main Source File *****
REM
rem The text settings
set text font "arial" : set text size 15
rem Types for the globals and for the array "objects"
type characters
imageNr as float
objectNr as float
x as float
y as float
speed as float
points as float
endtype
type theSettings
newSpeed as float
endtype
rem Defined variables
global menu as float
global sel as float
global NrOfStars as float
global wonderer as float
global maxPoints as float
global selOption as float
global settings as theSettings
rem Sync the program
sync on : sync rate 60
rem Randomize the timer
randomize timer()
rem Turn th backdrop off
backdrop off
rem The colorkey
set image colorkey 0,0,0
rem Dim the array that contains the images
dim objects(4) as characters : for n=1 to 4 : inc objects(n).imageNr,objects(n-1).imageNr+1 : next n
for n=1 to 4
objects(n).objectNr=n
next n
rem Load all images
load image "Media/Ships/Ship player one.bmp",objects(1).imageNr : load image "Media/Ships/Ship player two.bmp",objects(2).imageNr
if file exist("Media/backdrops/backdrop.bmp") then load image "Media/backdrop.bmp",5
rem Variables
maxPoints=10
menu=1
sel=1
rem Types
type ArrayTypes
x as float
y as float
endtype
type WeaponTypes
imageRipper as float
imageBullet as float
imageRocket as float
objectRipper as float
objectBullet as float
objectRocket as float
endtype
type Fire
CantFire as float
time as float
wait0 as float
endtype
type nomad
bullet as float
ripper as float
rocket as float
endtype
type TheWeapons
existRipper as float
ammoRipper as float
existRocket as float
ammoRocket as float
weaponName as string
endtype
rem The rest of the arrays
dim starArray(100) as ArrayTypes
dim weaponState(2) as Fire
dim weaponArray(2,100) as WeaponTypes
dim wonderer(2) as nomad
dim weaponUsage(2) as TheWeapons
rem Value wonderer
wonderer(1).bullet=100
wonderer(2).bullet=100
wonderer(1).ripper=100
wonderer(2).ripper=100
wonderer(1).rocket=100
wonderer(2).rocket=100
rem Value the weapons
weaponArray(1,1).imageRipper=501
weaponArray(1,1).imageBullet=502
rem Value weaponUsage
for n=1 to 2
weaponUsage(n).weaponName="Cannon"
weaponUsage(n).existRipper=1
next n
rem Fill the array "weaponArray"
for n=1 to 100
weaponArray(1,n).objectBullet=300+n
weaponArray(2,n).objectBullet=500+n
next n
rem Put the star positions in the array (starArray)
for n=1 to 100
starArray(n).x=rnd(screen width()-20)+10
starArray(n).y=rnd(screen height()-20)+10
next n
rem Set ship speeds
settings.newSpeed=2
rem The main part of the program
do
rem Clear the screen
cls
rem The game state
if menu=1
gosub main
else
rem In the game itself
gosub gameVisual
gosub gameBattle
rem The game interface
interface()
rem RETURN!!!
gosub gameReturn
endif
rem Update the screen
sync
loop
rem The main menu
main:
rem Output the stars
Stars()
rem The "headline"
set text size 25
text 10,10,"FIGHTERS GOLD"
rem The buttons
set text size 15
if button(10,40,1,"New game")=1 then switch=1
if button(10,57,2,"Options")=2 then switch=2
if button(10,74,3,"Controls")=3 then switch=3
if button(10,91,4,"Exit")=4 then end
rem Apply the arrowkeys to the menu
rem Effect
select switch
case 0 : KeyControl(1,4) : endcase
case 1
select NewGame()
rem Points
case 101
CreateBulletImage()
rem CreateRipperImage()
MakeBlocks(1)
MakeShips()
hide mouse
menu=0
objects(1).speed=settings.newSpeed
objects(2).speed=settings.newSpeed
endcase
rem Adrenalin
case 102
endcase
rem Return to the main menu
case 103 : switch=0 : endcase
endselect
KeyControl(101,103)
endcase
case 2 : gosub options : KeyControl(1001,1002) : endcase
case 3 : Help() : KeyControl(1,4) : endcase
endselect
return
options:
rem Headline
text 40+text width("Singleplayer"),40,"Player options:"
rem Input the max points
if button(40+text width("Singleplayer"),55,1001,"Max points: "+str$(maxPoints))=1001 then selOption=1
rem Input the ship speed
if button(40+text width("Singleplayer"),70,1002,"Ship speed: "+str$(settings.newSpeed))=1002 then selOption=2
Option(15,screen height()-text height("1")-15)
return
rem The game: Movement and other visual stuff
gameVisual:
Stars()
MovementPlayerOne()
MovementPlayerTwo()
MoveBlocks()
UpdateBlocks()
return
rem Sounds, bullets and other things that has to do with the battle
gameBattle:
ChangeWeapons()
WeaponsPlayerOne()
WeaponsPlayerTwo()
MoveBullets()
HitTheBlocks()
Score()
return
rem How to return to main menu
gameReturn:
if keystate(59)=1 or Victory()=1
ReturnToMain()
switch=0
for n=1 to 2
objects(n).speed=settings.newSpeed
objects(n).points=0
next n
endif
SuddenDeath()
return
function Option(x1,y1)
if selOption<>0
t=timer()
repeat
until timer()-t=50
rem Create the box around the input
box x1-10,y1-10,x1+text width("INPUT MAX POINTS : 999999999999")+10,y1+text height("INPUT MAX POINTS : 999999999999")+10
box x1-8,y1-8,x1+text width("INPUT MAX POINTS : 999999999999")+8,y1+text height("INPUT MAX POINTS : 999999999999")+8,rgb(0,0,0),rgb(0,0,0),rgb(0,0,0),rgb(0,0,0)
if selOption=1
rem Create the input: Maxpoints
set cursor x1,y1
input "Input maxpoints: ",maxPoints
rem Max point limits
if maxPoints>99999 then maxPoints=99999
if maxPoints<1 then maxPoints=1
endif
if selOption=2
rem Create the input: Player speed
set cursor x1,y1
input "Input player speed: ",settings.newSpeed
rem Speed limits
if settings.newSpeed>14 then settings.newSpeed=14
if settings.newSpeed<1 then settings.newSpeed=1
endif
selOption=0
endif
endfunction
function SetSpeed()
rem Input the ship speed
if button(40+text width("Singleplayer"),70,1002,"Ship speed: "+str$(maxPoints))=1002
rem Wait 50 miliseconds
t=timer()
repeat
until (timer()-t)=50
rem Create the box around the input
box 90,90,100+text width("Ship speed: 999999")+10,100+text height("Ship speed: 999999")+10
box 92,92,100+text width("Ship speed: 999999")+8,100+text height("Ship speed: 999999")+8,rgb(0,0,0),rgb(0,0,0),rgb(0,0,0),rgb(0,0,0)
endif
endfunction
rem The functions
rem Start a new game
function NewGame()
rem Headline
text 40+text width("Singleplayer"),40,"Choose game type:"
rem Buttons
detectPress=button(40+text width("Singleplayer"),57,101,"Points")
detectPress=button(40+text width("Singleplayer"),74,102,"Adrenalin")
detectPress=button(40+text width("Singleplayer"),91,103,"return to main")
endfunction detectPress
rem The ships
function MakeShips()
rem Set the position of ship one
objects(1).x=screen width()-57
objects(1).y=screen height()-138
rem Create sprite and position it
objects(1).objectNr=1 : sprite objects(1).objectNr,objects(1).x,objects(1).y,objects(1).imageNr
rem Set the position of ship two
objects(2).x=10
objects(2).y=10
rem Create and position the sprite of ship two
objects(2).objectNr=2 : sprite objects(2).objectNr,objects(2).x,objects(2).y,objects(2).imageNr
endfunction
function Victory()
if objects(1).points>=maxPoints and objects(1).points<>objects(2).points or objects(2).points>=maxPoints and objects(2).points<>objects(1).points
rem Clear the screen
cls
rem The text
center text screen width()/2,screen height()/2-15,"Score player one: "+str$(objects(1).points)+" Score player two: "+str$(objects(2).points)
if objects(1).points>objects(2).points then center text screen width()/2,screen height()/2,"Player one is the winner"
if objects(1).points<objects(2).points then center text screen width()/2,screen height()/2,"Player two is the winner"
rem The stars
Stars()
rem The interface... again
interface()
rem Update the csreen
sync
t=timer()
repeat
until (timer()-t)/1000>=5
cls
rem The text
center text screen width()/2,screen height()/2-15,"Score player one: "+str$(objects(1).points)+" Score player two: "+str$(objects(2).points)
if objects(1).points>objects(2).points then center text screen width()/2,screen height()/2,"Player one is the winner"
if objects(1).points<objects(2).points then center text screen width()/2,screen height()/2,"Player two is the winner"
center text screen width()/2,screen height()/2+15,"PRESS ANY KEY TO CONTINUE"
rem The stars
Stars()
rem The interface
interface()
rem Update the screen
sync
rem The timer
t=timer()
repeat
if keystate(42)=0 and keystate(54)=0 and scancode()<>0 then exit
until (timer()-t)/1000>=240
r=1
endif
endfunction r
function SuddenDeath()
rem Sudden death...
if objects(1).points>=maxPoints and objects(1).points=objects(2).points then center text screen width()/2,(screen height()-90)/2,"SUDDEN DEATH"
endfunction
rem The interface
function interface()
rem The Square
ink rgb(100,100,100),0 : box 10,screen height()-90,screen width()-10,screen height()-10
ink rgb(0,0,0),0 : box 13,screen height()-87,screen width()-13,screen height()-13
ink rgb(255,255,255),0
rem The text
text 16,screen height()-84,"Player one:"
text 16,screen height()-69,"Score: "+str$(objects(1).points)
text 16+text width("Score: 99999 "),screen height()-69,"Current weapon: "+weaponUsage(1).weaponName
text 36+text width("Score: 99999 Current weapon: Rockets "),screen height()-69,"Ammo: "
text 16,screen height()-54,"Player two:"
text 16,screen height()-39,"Score: "+str$(objects(2).points)
text 16+text width("Score: 99999 "),screen height()-39,"Current weapon: "+weaponUsage(2).weaponName
text 36+text width("Score: 99999 Current weapon: Rockets "),screen height()-39,"Ammo: "
endfunction
rem The credits
function Help()
text 40+text width("Singleplayer"),40,"Controls player one:"
text 40+text width("singleplayer"),55,"Move left = left key"
text 40+text width("Singleplayer"),70,"Move right = right key"
text 40+text width("Singleplayer"),85,"Fire = left shift"
text 40+text width("Singleplayer"),115,"Controls player two:"
text 40+text width("Singleplayer"),130,"Move left = s"
text 40+text width("Singleplayer"),145,"Move right = d"
text 40+text width("Singleplayer"),160,"Fire = right shift"
text 40+text width("Singleplayer"),190,"Game controls:"
text 40+text width("Singleplayer"),205,"Exit program = esc"
text 40+text width("Singleplayer"),220,"Exit a game = F1"
text 80+text width("Singleplayer")+text width("Move right = right key"),40,"Menu controls:"
text 80+text width("Singleplayer")+text width("Move right = right key"),55,"Up = upkey"
text 80+text width("Singleplayer")+text width("Move right = right key"),70,"Down = downkey"
text 80+text width("Singleplayer")+text width("Move right = right key"),85,"Select option = ENTER (numpad)"
endfunction
rem Movement player one
function MovementPlayerOne()
rem Move left
if leftkey()=1 and sprite x(objects(1).objectNr)>10
rotate sprite objects(1).objectNr,-90
move sprite objects(1).objectNr,objects(1).speed
rotate sprite objects(1).objectNr,sprite angle(objects(1).objectNr)+90
endif
rem Move right
if rightkey()=1 and sprite x(objects(1).objectNr)<screen width()-57
rotate sprite objects(1).objectNr,90
move sprite objects(1).objectNr,objects(1).speed
rotate sprite objects(1).objectNr,sprite angle(objects(1).objectNr)-90
endif
endfunction
rem Movement player two
function MovementPlayerTwo()
rem Move left
if keystate(31)=1 and sprite x(objects(2).objectNr)>10
rotate sprite objects(2).objectNr,-90
move sprite objects(2).objectNr,objects(2).speed
rotate sprite objects(2).objectNr,sprite angle(objects(2).objectNr)+90
endif
rem Move right
if keystate(32)=1 and sprite x(objects(2).objectNr)<screen width()-57
rotate sprite objects(2).objectNr,90
move sprite objects(2).objectNr,objects(2).speed
rotate sprite objects(2).objectNr,sprite angle(objects(2).objectNr)-90
endif
endfunction
rem Button command
function button(x,y,id,string$)
rem Other ways to select the button
if sel=id
rem color the text
ink rgb(255,255,100),0
rem Select the button
if keystate(156)=1 then returnvalue=id
endif
rem Detect if the mouse is on the "button"
if mousex()>=x and mousex()<=x+text width(string$)
if mousey()>=y and mousey()<=y+(text height(string$))
rem If so the text becomes yellow
ink rgb(255,255,0),0
rem If the left mousebutton is clicked, then return the value 1
if mouseclick()=1 then returnvalue=id
endif
endif
rem The text
text x,y,string$
rem Set the color to white
ink rgb(255,255,255),0
endfunction returnvalue
rem Change values on the variable "Sel" (as in "Selection")
function KeyControl(paramiterOne,paramiterTwo)
if upkey()=1 then dec Sel,1
if downkey()=1 then inc Sel,1
if Sel<paramiterOne then Sel=paramiterTwo
if Sel>paramiterTwo then Sel=paramiterOne
wait 65
endfunction
rem Make the blocks
function MakeBlocks(speed)
rem Clear the screen
cls
rem Color and make the box
ink rgb(155,155,155),0
box 10,10,120,60
rem Make the box to an image
get image objects(3).imageNr,10,10,120,60
rem Clear the screen and color back everything
cls
ink rgb(255,255,255),0
rem The position of teh sprites
objects(3).x=10
objects(3).y=60
objects(4).x=screen width()-120
objects(4).y=screen height()-200
rem Make and position the sprites
objects(3).objectNr=3 : sprite objects(3).objectNr,objects(3).x,objects(3).y,objects(3).imageNr
objects(4).objectNr=4 : sprite objects(4).objectNr,objects(4).x,objects(4).y,objects(3).imageNr
rem Set block speed
objects(3).speed=speed
objects(4).speed=speed
endfunction
rem Move the blocks
function MoveBlocks()
rem Move block one
rotate sprite objects(3).objectNr,90
move sprite objects(3).objectNr,objects(3).speed
rotate sprite objects(3).objectNr,sprite angle(objects(3).objectNr)-90
rem Move block two
rotate sprite objects(4).objectNr,90
move sprite objects(4).objectNr,objects(4).speed
rotate sprite objects(4).objectNr,sprite angle(objects(4).objectNr)-90
endfunction
rem Position the blocks
function UpdateBlocks()
rem Update the position of sprite one
if sprite x(objects(3).objectNr)>(screen width()+1)
delete sprite objects(3).objectNr
objects(3).x=-111
sprite objects(3).objectNr,objects(3).x,objects(3).y,objects(3).imageNr
endif
rem Update the position of sprite two
if sprite x(objects(4).objectNr)>(screen width()+1)
delete sprite objects(4).objectNr
objects(4).x=-111
sprite objects(4).objectNr,objects(4).x,objects(4).y,objects(3).imageNr
endif
endfunction
rem The stars
function Stars()
rem The FOR-NEXT loop that puts out the stars again
for n=1 to 100
dot starArray(n).x,starArray(n).y
next n
endfunction
rem Update the stars positions
function MoveStars(movex,movey)
rem FOR-NEXT loop
for n=1 to 100
rem Update x positions
inc starArray(n).x,movex
rem X position limits
if starArray(n).x>screen width() then starArray(n).x=0
if starArray(n).x<0 then starArray(n).x=screen width()
rem Update y positions
inc starArray(n).y,movey
rem Set y limits
if starArray(n).y>screen height() then starArray(n).y=0
if starArray(n).y<0 then starArray(n).y=screen height()
next n
endfunction
rem Return to main
function ReturnToMain()
for n=1 to 4
delete sprite n
next n
show mouse
menu=1
endfunction
rem Create the bullet image
function CreateBulletImage()
rem Clear the screen
cls
rem Make the bullet and color it
ink rgb(255,255,100),0 : circle 100,100,1 : dot 100,100,rgb(255,155,155)
rem Get the image
get image weaponArray(1,1).imageBullet,99,99,102,102
rem Clear the screen
cls
endfunction
rem Create ripper image
function CreateRipperImage()
rem Clear the screen
cls
rem Make and color the box
ink rgb(255,50,50),0 : box 100,100,102,115
rem Get the image
get image weaponArray(1,1).imageRipper,100,100,103,110
rem Clear the screen
cls
endfunction
rem Move the bullets
function MoveBullets()
rem The Cannon
rem The FOR-NEXT loop : Player one
for variable=1 to 100
rem Check if the sprite exist
if sprite exist(300+variable)
rem If so, and the sprite is "lower" 10 on the y-axis
if sprite y(300+variable)<10
delete sprite weaponArray(1,variable).objectBullet
weaponArray(1,variable).objectBullet=0
else
move sprite weaponArray(1,variable).objectBullet,5
endif
endif
next variable
rem The FOR-NEXT loop : Player two
for variable=1 to 100
rem Check if the sprite exist
if sprite exist(500+variable)
rem If so, and the sprite is "higher" then 100 steps from the bottom of the screen
if sprite y(500+variable)>screen height()-100
delete sprite weaponArray(2,variable).objectBullet
weaponArray(2,variable).objectBullet=0
else
move sprite weaponArray(2,variable).objectBullet,-5
endif
endif
next variable
rem The Ripper
rem The FOR-NEXT loop : Player one
for variable=1 to 100
rem Check if the sprite exist
if sprite exist(1500+variable)
rem If it does, and it is "lower" 10 on the y-axis
if sprite y(1500+variable)
delete sprite weaponArray(1,variable).objectRipper
weaponArray(1,variable).objectRipper=0
else
move sprite weaponArray(1,variable).objectRipper,15
endif
endif
next variable
rem The FOR-NEXT loop
for variable=1 to 100
rem Check if the sprite exist
if sprite exist(1700+variable)
rem If so, and the sprite is "higher" then 100 steps from the bottom of the screen
if sprite y(1700+variable)
delete sprite weaponArray(2,variable).objectRipper
weaponArray(2,variable).objectRipper=0
else
move sprite weaponArray(2,variable).objectRipper,-15
endif
endif
next variable
endfunction
rem How to fire and how long the reeloading time is for player one
function WeaponsPlayerOne()
rem Fire the bullet
if keystate(54)=1 and weaponState(1).CantFire=0
weaponState(1).wait0=timer()
weaponState(1).CantFire=1
if weaponUsage(1).weaponName="Cannon"
MakeBulletPlayerOne()
else
if weaponUsage(1).weaponName="Ripper"
MakeRipperPlayerOne()
else
endif
endif
endif
rem Time to next bullet
if weaponState(1).CantFire=1
weaponState(1).time=(timer()-weaponState(1).wait0)/10
if weaponState(1).time>=150 then weaponState(1).CantFire=0
endif
endfunction
rem How to fire and how long the reeloading time is for player two
function WeaponsPlayerTwo()
rem Fire the bullet
if keystate(42)=1 and weaponState(2).CantFire=0
weaponState(2).wait0=timer()
weaponState(2).CantFire=1
if weaponUsage(2).weaponName="Cannon"
MakeBulletPlayerTwo()
else
if weaponUsage(2).weaponName="Ripper"
MakeRipperPlayerTwo()
else
endif
endif
endif
rem Time to next bullet
if weaponState(2).CantFire=1
weaponState(2).time=(timer()-weaponState(2).wait0)/10
if weaponState(2).time>=150 then weaponState(2).CantFire=0
endif
endfunction
function ChangeWeapons()
rem Player one
if keystate(79)=1
weaponUsage(1).weaponName="Cannon"
else
if keystate(80)=1
if weaponUsage(1).existRipper=1 then weaponUsage(1).weaponName="Ripper"
else
if keystate(81)=1
if weaponUsage(1).existRocket=1 then weaponUsage(1).weaponName="Rocket"
endif
endif
endif
rem Player two
if keystate(2)=1
weaponUsage(2).weaponName="Cannon"
else
if keystate(3)=1
if weaponUsage(2).existRipper=1 then weaponUsage(2).weaponName="Ripper"
else
if keystate(4)=1
if weaponUsage(2).existRocket=1 then weaponUsage(2).weaponName="Rocket"
endif
endif
endif
endfunction
function Score()
rem If player two hits player one
if sprite collision(1,0)>=500 and sprite collision(1,0)<=600
delete sprite sprite collision(1,0)
ink rgb(0,0,255),0
circle sprite x(objects(1).objectNr)+23.5,sprite y(objects(1).objectNr)+19,33
ink rgb(255,255,255),0
inc objects(2).points,1
endif
rem If player one hits player two
if sprite collision(2,0)>=300 and sprite collision(2,0)<=400
delete sprite sprite collision(2,0)
ink rgb(0,0,255),0
circle sprite x(objects(2).objectNr)+23.5,sprite y(objects(2).objectNr)+19,33
ink rgb(255,255,255),0
inc objects(1).points,1
endif
endfunction
function HitTheBlocks()
rem Hit one block
if sprite collision(3,0)<>0 then delete sprite sprite collision(3,0)
rem Hit another block
if sprite collision(4,0)<>0 then delete sprite sprite collision(4,0)
endfunction
rem Make the bullets for player one
function MakeBulletPlayerOne()
rem Increase the nr of the sprite that will be created, and set its limit
inc wonderer(1).bullet,1 : if wonderer(1).bullet>100 then wonderer(1).bullet=1
w=wonderer(1).bullet
rem Enter "wonderer" into the array
weaponArray(1,w).objectBullet=300+w
rem Make the sprite
sprite weaponArray(1,w).objectBullet,sprite x(objects(1).objectNr)+23.5,sprite y(objects(1).objectNr),weaponArray(1,1).imageBullet
endfunction
rem Make the bullets for player two
function MakeBulletPlayerTwo()
rem Increase the nr of the sprite that will be created, and set its limit
inc wonderer(2).bullet,1 : if wonderer(2).bullet>100 then wonderer(2).bullet=1
w=wonderer(2).bullet
rem Enter "wonderer" into the array
weaponArray(2,w).objectBullet=500+w
rem Make the sprite
sprite weaponArray(2,w).objectBullet,sprite x(objects(2).objectNr)+23.5,sprite y(objects(2).objectNr)+38,weaponArray(1,1).imageBullet
endfunction
function MakeRipperPlayerOne()
rem Increase the nr of the sprite that will be created, and set its limits
inc wonderer(1).ripper,1 : if wonderer(1).ripper>100 then wonderer(1).ripper=1
w=wonderer(1).ripper
rem Enter "wonderer" into the array
weaponArray(1,w).objectRipper=1500+w
rem Make the sprite
sprite weaponArray(1,w).objectRipper,sprite x(objects(1).objectNr)+23.5,sprite y(objects(2).objectNr)+38,weaponArray(1,1).imageRipper
endfunction
function MakeRipperPlayerTwo()
rem Increase the nr of the sprite that will be created, and set its limits
inc wonderer(2).ripper,1 : if wonderer(2).ripper>100 then wonderer(2).ripper=1
w=wonderer(2).ripper
rem Enter "wonderer" into the array
weaponArray(2,w).objectRipper=1700+w
rem Make the sprite
sprite weaponArray(2,w).objectRipper,sprite x(objects(2).objectNr)+23.5,sprite y(objects(2).objectNr)+38,weaponArray(1,1).imageRipper
endfunction