Hi all.
I have a new problem with my game. Ive tried to introduce several weapons (two at the moment). But if player one switch to weapon two, and fire, one very strange thing happens. Suddenly player two cant hit player one with the first weapon (the same thing happens if player two uses teh second weapon). I havent made so the second weapons bullets move yet, so I dont know if its just the first weapon. This is the function that moves the bullets and checks if the hit something:
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,10
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,-10
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(2300+variable)
rem If it does, and it is \"lower\" 10 on the y-axis
if sprite y(2300+variable)
delete sprite weaponArray(1,variable).objectRipper
weaponArray(1,variable).objectRipper=0
else
move sprite weaponArray(1,variable).objectRipper,20
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(2500+variable)
rem If so, and the sprite is \"higher\" then 100 steps from the bottom of the screen
if sprite y(2500+variable)
delete sprite weaponArray(2,variable).objectRipper
weaponArray(2,variable).objectRipper=0
else
move sprite weaponArray(2,variable).objectRipper,-20
endif
endif
next variable
endfunction
, and here is the rest of the source:
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 : MakeBlockImage()
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 the_ai
destX as integer
state as integer
mode as string
defulty as string
factorRandom as integer
factorFollow as integer
factorHide as integer
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
dim aiArray(2) as the_ai
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=GetFreeImage() : CreateRipperImage()
weaponArray(1,1).imageBullet=GetFreeImage() : CreateBulletImage()
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
for n=1 to 100
weaponArray(1,n).objectRipper=2300+n
weaponArray(2,n).objectRipper=2500+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 The ai
for n=1 to 2
aiArray(n).mode=\"Off\"
aiArray(n).defulty=\"Easy\"
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 The backdrop
if image exist(5)=0
Stars()
else
paste image 5,0,0
endif
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 Effect
select switch
case 0 : KeyControl(1,4) : endcase
case 1
select NewGame()
rem Points
case 101
MakeBlocks(1)
MakeShips()
hide mouse
menu=0
objects(1).speed=settings.newSpeed
objects(2).speed=settings.newSpeed
for n=1 to 2
aiArray(n).factorRandom=rnd(300)
aiArray(n).factorFollow=rnd(75)
aiArray(n).factorHide=rnd(300)
next n
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,1004) : 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
if button(40+text width(\"Singleplayer\"),100,1003,\"AI player one: \"+aiArray(1).mode)=1003
if aiArray(1).mode=\"Off\"
aiArray(1).mode=\"On\"
else
aiArray(1).mode=\"Off\"
endif
wait 50
endif
if button(40+text width(\"Singleplayer\"),115,1004,\"AI player two: \"+aiArray(2).mode)=1004
if aiArray(2).mode=\"Off\"
aiArray(2).mode=\"On\"
else
aiArray(2).mode=\"Off\"
endif
endif
Option()
return
rem The game: Movement and other visual stuff
gameVisual:
rem The backdrop
if image exist(5)=0
Stars()
else
paste image 5,0,0
endif
if aiArray(1).mode=\"Off\" then MovementPlayerOne()
if aiArray(2).mode=\"Off\" then MovementPlayerTwo()
AI()
MoveBlocks()
UpdateBlocks()
return
rem Sounds, bullets and other things that has to do with the battle
gameBattle:
ChangeWeapons()
if keystate(54)=1 and aiArray(1).mode=\"Off\" then WeaponsPlayerOne()
if keystate(42)=1 and aiArray(2).mode=\"Off\" then 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
return
function Option()
if selOption<>0
t=timer()
repeat
until timer()-t=50
if selOption=1
rem Input: Maxpoints
set cursor 10,screen height()-20
input \"Input max points: \",maxPoints
rem Max point limits
if maxPoints>99999 then maxPoints=99999
if maxPoints<1 then maxPoints=1
endif
if selOption=2
rem Input: Player speed
set cursor 10,screen height()-20
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 AI()
for n=1 to 2
if aiArray(n).mode=\"On\"
behave=rnd(10000)
if behave<100+aiArray(n).factorRandom
aiArray(n).state=0
aiArray(n).destX=sprite x(objects(n).objectNr)
endif
if behave>1000 and behave<1100+aiArray(n).factorFollow then aiArray(n).state=1
if behave>2700 and behave<2800+aiArray(n).factorHide then aiArray(n).state=2
var=rnd(100)
if n=1 and var<50 and aiArray(1).state=aiArray(2).state then aiArray(1).state=0
if n=1 and var>=50 and aiArray(1).state=aiArray(2).state then aiArray(1).state=2
if n=2 and var<50 and aiArray(1).state=aiArray(2).state then aiArray(1).state=0
if n=2 and var>=50 and aiArray(1).state=aiArray(2).state then aiArray(1).state=2
rem Set the destanation
select aiArray(n).state
rem Random movement
case 0
if aiArray(n).destX=sprite x(objects(n).objectNr) then aiArray(n).destX=rnd(screen width())
endcase
rem Follow the player other
case 1
if n=1 then aiArray(n).destX=sprite x(objects(2).objectNr)
if n=2 then aiArray(n).destX=sprite x(objects(1).objectNr)
endcase
rem Hide behind one of the two blocks
case 2 : aiArray(n).destX=sprite x(objects(n+2).objectNr)+50 : endcase
endselect
rem The movement bounderies
if aiArray(n).destX<10 then aiArray(n).destX=10
if aiArray(n).destX>screen width()-57 then aiArray(n).destX=screen width()-57
rem Fire the weapon
if n=1 and sprite x(objects(1).objectNr)>sprite x(objects(2).objectNr)-10 and sprite x(objects(1).objectNr)<sprite x(objects(2).objectNr)+10
if CollisionCheck(1)=0 then WeaponsPlayerOne()
endif
if n=2 and sprite x(objects(2).objectNr)>sprite x(objects(1).objectNr)-10 and sprite x(objects(2).objectNr)<sprite x(objects(1).objectNr)+10
if CollisionCheck(2)=0 then WeaponsPlayerTwo()
endif
rem Move the AI controlled ship
rem Move left
if sprite x(objects(n).objectNr)>aiArray(n).destX
rotate sprite objects(n).objectNr,-90
move sprite objects(n).objectNr,objects(n).speed
rotate sprite objects(n).objectNr,sprite angle(objects(n).objectNr)+90
endif
rem Move right
if sprite x(objects(n).objectNr)<aiArray(n).destX
rotate sprite objects(n).objectNr,90
move sprite objects(n).objectNr,objects(n).speed
rotate sprite objects(n).objectNr,sprite angle(objects(n).objectNr)-90
endif
endif
next n
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
function MakeBlockImage()
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
endfunction
rem Make the blocks
function MakeBlocks(speed)
ink rgb(255,255,255),0
rem The position of teh sprites
objects(4).x=10
objects(4).y=60
objects(3).x=screen width()-120
objects(3).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 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,10
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,-10
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(2300+variable)
rem If it does, and it is \"lower\" 10 on the y-axis
if sprite y(2300+variable)
delete sprite weaponArray(1,variable).objectRipper
weaponArray(1,variable).objectRipper=0
else
move sprite weaponArray(1,variable).objectRipper,20
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(2500+variable)
rem If so, and the sprite is \"higher\" then 100 steps from the bottom of the screen
if sprite y(2500+variable)
delete sprite weaponArray(2,variable).objectRipper
weaponArray(2,variable).objectRipper=0
else
move sprite weaponArray(2,variable).objectRipper,-20
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 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 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(1).objectNr),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
function GetFreeImage()
rem Repeat the following code until a new, free image is found
repeat
inc image,1
until image exist(image)=0
inc image,1
repeat
inc image,1
until image exist(image)=0
endfunction image
function ReturnToMain()
rem Delete ALL the sprites
for n=1 to 100000
if sprite exist(n) then delete sprite n
next n
rem Show the mouse
show mouse
menu=1
rem Set the standard weapon as the starting one
weaponUsage(1).weaponName=\"Cannon\"
weaponUsage(2).weaponName=\"Cannon\"
endfunction
function CollisionCheck(player)
rem Create the sprite
sprite 25000,sprite x(objects(player).objectNr)+23.5,sprite y(objects(player).objectNr),weaponArray(1,1).imageBullet
rem Determine the sprite direction
if player=1 then direction=1
if player=2 then direction=-1
rem Move and check the collision
for n=1 to screen height()
move sprite 25000,direction
if sprite collision(25000,3)=1 or sprite collision(25000,4)=1
returnvalue=1
else
returnvalue=0
endif
next n
rem Delete the sprite
delete sprite 25000
endfunction returnvalue
. Do you see whats wrong?