It's because even though the sprite is deleted the weapon selected is still 1 and the sprite is recreated on the last x and y it was so another collision detection is triggered over and over again. You can reset all the variables for the ball before you leave the IF/ENDIF of the collision detection. I also moved the crosshair outside of the weapon selection area (it wouldn't show up after the weapon was deselected).
`Started: 6/16/09 4:54 PM
`This is the two player duel mode.
`Temporary Variables (to be deleted with progress)
tempVars:
set display mode 800,600,32
sync on
sync rate 60
hide mouse
character$ = "Stick Dude"
stadium$ = "aboveGround"
`_________________________________________________
`This routine loads all images
loadImg:
`Stadium Images
load image "1.png",1
`Character Images
load image "2.png",2 : `Temporary Only
`Weapon Images (All Temporary for Now)
load image "3.png",3
load image "4.png",4
load image "5.png",5
load image "6.png",6
load image "7.png",7
load image "8.png",8
load image "9.png",9
`_____________________________
`This routine loads player settings
playerSettings:
p1health# = 100
p2health# = 100
p1x = 100
p1y = 265
p2x = 600
p2y = 265
p1weapon1$ = "beachball"
p1weapon2$ = "bucket"
p1weapon3$ = "handle"
p2weapon1$ = "nunchucks"
p2weapon2$ = "mines"
p2weapon3$ = "watergun"
p1floatation$ = "bazooka"
p2floatation$ = "tugboatfloat"
`__________________________________
`This routine loads weapons settings
weaponSettings:
beachballdamage#=15
beachballexplosiondamage#=20
bucketdamage#=10
handledamage#=0
minesdamage#=15
nunchucksdamage#=15
watergun#=15
weaponSelected1#=0
weaponSelected2#=0
ballx# = p1x+50
bally# = p1y
newx# = ballx#
newy# = bally#
`___________________________________
Game:
do
beachballactive=0
cls
paste image 1,0,0
set cursor 0,0
print "Player 1: "+str$(p1health#)
print "Player 2: "+str$(p2health#)
sprite 2,p1x,p1y,2
sprite 3,p2x,p2y,2
` Show crosshair
sprite 50,mousex(),mousey(),9
`Controls for Player 1
if inkey$()="w" then p1y=p1y-1
if inkey$()="s" then p1y=p1y+1
if inkey$()="a" then p1x=p1x-1
if inkey$()="d" then p1x=p1x+1
if inkey$()="1" then weaponSelected1#=1
if inkey$()="2" then weaponSelected1#=2
if inkey$()="3" then weaponSelected1#=3
`_____________________
`Controls for Player 2
if upkey()=1 then p2y=p2y-1
if downkey()=1 then p2y=p2y+1
if leftkey()=1 then p2x=p2x-1
if rightkey()=1 then p2x=p2x+1
if inkey$()="b" then weaponSelected2#=1
if inkey$()="n" then weaponSelected2#=2
if inkey$()="m" then weaponSelected2#=3
`____________________
`Player 1's Halfway Point
if p1x>315
p1x=p1x-1
endif
`_______________________
`Player 2's Halfway Point
if p2x<375
p2x=p2x+1
endif
`_______________________
`Player 1's Corner
if p1x<35
p1x=p1x+1
endif
`________________
`Player 2's Corner
if p2x>665
p2x=p2x-1
endif
`________________
`Center Boundaries
if p1y<200
p1y=p1y+1
endif
if p2y<200
p2y=p2y+1
endif
if p1y>365
p1y=p1y-1
endif
if p2y>365
p2y=p2y-1
endif
`_________________
if weaponSelected1#=1
if p1weapon1$="beachball"
sprite 4,ballx#,bally#,3
if mouseclick()=1
newx# = mousex()
newy# = mousey()
targethit = 0 :`flag to minimize checks
endif
if targethit = 0
ballx# = curvevalue(newx#,ballx#,20)
bally# = curvevalue(newy#,bally#,20)
if abs(ballx#-newx#) < 1
if abs(bally#-newy#) < 1 then targethit=1
endif
endif
` Check sprite collision
if sprite collision(4,3)
explosion=rnd(1)
if explosion=0
p2health#=p2health#-beachballdamage#
delete sprite 4
endif
if explosion=1
p2health#=p2health#-20
delete sprite 4
endif
` Reset ball location
ballx# = p1x+50
bally# = p1y
` Reset mouse target
newx# = ballx#
newy# = bally#
` De-select weapon
weaponSelected1#=0
endif
endif
endif
sync
loop
