Okay so here was my attempt at a turn system,
`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
stadium$ = "aboveGround"
`_________________________________________________
`This routine loads all images
loadImg:
`Stadium Images
load image "media\stadiums\"+stadium$+"\tempbg01.png",1
`Character Images
load image "media\characters\Johnny\p1johnnyoverview.png",2
load image "media\characters\Johnny\p1johnnythrow1.png",14
load image "media\characters\Johnny\p1johnnythrow2.png",15
load image "media\characters\Johnny\p1johnnythrow3.png",16
load image "media\characters\Johnny\p2johnnyoverview.png",17
load image "media\characters\Johnny\p1johnnywatergun.png",18
load image "media\characters\Johnny\johnnyhandleup.png",19
load image "media\characters\Johnny\johnnyhandledown.png",20
`_______________________
`Weapon Images (Some Temporary for Now)
load image "media\weapons\beachball0.png",3
load image "media\weapons\p1johnnybucket1.png",4
load image "media\weapons\handle.png",5
load image "media\weapons\mines.png",6
load image "media\weapons\nunchucks.png",7
load image "media\weapons\waterforgun5.png",8
load image "media\weapons\crosshair.png",9
load image "media\weapons\beachballexplosion.png",10
load image "media\weapons\p1johnnybucket2.png",11
load image "media\weapons\p1johnnybucket3.png",12
load image "media\weapons\bucketwater.png",13
load image "media\weapons\fishpeople.png",21
`_____________________________
`This routine loads player settings
playerSettings:
p1health# = 100
p2health# = 100
p1x = 100
p1y = 265
p2x = 600
p2y = 265
p1weapon1$ = "beachball"
p1weapon2$ = "bucket"
p1weapon3$ = "watergun"
p2weapon1$ = "handle"
p2weapon2$ = "nunchucks"
p2weapon3$ = "mines"
p1floatation$ = "bazooka"
p2floatation$ = "tugboatfloat"
turn$="p1"
`__________________________________
`This routine loads weapons settings
weaponSettings:
beachballdamage#=15
beachballexplosiondamage#=20
bucketdamage#=10
handledamage#=0
minesdamage#=15
nunchucksdamage#=15
watergundamage#=15
weaponSelected1#=0
weaponSelected2#=0
ballx# = p1x+50
bally# = p1y
newx# = ballx#
newy# = bally#
bucketx# = p1x+50
buckety# = 188
newbx# = bucketx#
newby# = buckety#
watergunx# = p1x+70
waterguny# = p1y+35
newwx# = watergunx#
newwy# = waterguny#
handlex# = p2x
handley# = p2y-100
newhx# = handlex#
newhy# = handley#
`___________________________________
Game:
do
cls
paste image 1,0,0
set cursor 0,0
sprite 2,p1x,p1y,2
sprite 3,p2x,p2y,17
`Controls for Player 1
if keystate(17)= 1 then p1y=p1y-1
if keystate(31)= 1 then p1y=p1y+1
if keystate(30)= 1 then p1x=p1x-1
if keystate(32)= 1 then p1x=p1x+1
if keystate(2)= 1 and turn$="p1" then weaponSelected1#=1
if keystate(3)= 1 and turn$="p1" then weaponSelected1#=2
if keystate(4)= 1 and turn$="p1" 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 keystate(9)= 1 and turn$="p2" then weaponSelected2#=1
if keystate(10)= 1 and turn$="p2" then weaponSelected2#=2
if keystate(11)= 1 and turn$="p2" 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 turn$="p1"
if weaponSelected1#=1
`Beachball
if p1weapon1$="beachball"
hide mouse
sprite 50,mousex(),mousey(),9
sprite 4,ballx#,bally#,3
sprite 5,p1x,p1y,14
sprite 6,p1x,p1y,15
sprite 7,p1x,p1y,16
hide sprite 4
hide sprite 5
hide sprite 6
hide sprite 7
if mouseclick()=1
newx# = mousex()
newy# = mousey()
targethit = 0 :`flag to minimize checks
hide sprite 2
show sprite 5
wait 200
delete sprite 5
show sprite 6
wait 200
delete sprite 6
show sprite 7
wait 200
delete sprite 7
show sprite 2
endif
if targethit = 0
show sprite 4
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
if sprite collision(4,3)=1
explosion=rnd(4)
if explosion=0 or explosion=4
p2health#=p2health#-beachballdamage#
delete sprite 4
endif
if explosion=1 or explosion=2
p2health#=p2health#-20
delete sprite 4
wait 200
sprite 9,ballx#,bally#,10
delete sprite 4
wait 300
delete sprite 9
endif
` Reset ball location
ballx# = p1x+50
bally# = p1y
` Reset mouse target
newx# = ballx#
newy# = bally#
` De-select weapon
weaponSelected1#=0
turn$="p2"
delete sprite 50
show sprite 2
show mouse
endif
if sprite collision(4,50)=1 and targethit=1
delete sprite 4
` Reset ball location
ballx# = p1x+50
bally# = p1y
` Reset mouse target
newx# = ballx#
newy# = bally#
` De-select weapon
weaponSelected1#=0
turn$="p2"
delete sprite 50
show mouse
endif
endif
endif
`____________________________
if weaponSelected1#=2
`Bucket
if p1weapon2$="bucket"
hide mouse
sprite 50,mousex(),mousey(),9
sprite 5,p1x,p1y,4
sprite 6,p1x,p1y,11
sprite 7,p1x,p1y,12
sprite 8,bucketx#,buckety#,13
hide sprite 5
hide sprite 6
hide sprite 7
hide sprite 8
if mouseclick()=1
newbx# = mousex()
newby# = mousey()
targethit = 0 :`flag to minimize checks
hide sprite 2
show sprite 5
wait 200
delete sprite 5
show sprite 6
wait 200
delete sprite 6
show sprite 7
endif
if targethit = 0
show sprite 8
show sprite 2
bucketx# = curvevalue(newbx#,bucketx#,20)
buckety# = 188 : `curvevalue(newby#,buckety#,20)
if abs(bucketx#-newbx#) < 1 then targethit=1
endif
if sprite collision(8,3)=1
delete sprite 8
p2health#=p2health#-bucketdamage#
` Reset bucket location
bucketx# = p1x+50
buckety# = p1y
` Reset mouse target
newbx# = bucketx#
newby# = buckety#
` De-select weapon
weaponSelected1#=0
delete sprite 50
show mouse
endif
if sprite collision(8,50)=1 and targethit=1
delete sprite 8
` Reset bucket location
bucketx# = p1x+50
buckety# = p1y
` Reset mouse target
newbx# = bucketx#
newby# = buckety#
` De-select weapon
weaponSelected1#=0
turn$="p2"
delete sprite 50
show mouse
endif
endif
`_________________
endif
if weaponSelected1#=3
if p1weapon3$="watergun"
hide mouse
sprite 50,mousex(),mousey(),9
sprite 4,p1x,p1y,18
sprite 5,watergunx#,waterguny#,8
hide sprite 2
show sprite 4
hide sprite 5
if mouseclick()=1
newwx# = mousex()
newwy# = mousey()
targethit = 0 :`flag to minimize checks
endif
if targethit = 0
show sprite 5
watergunx# = curvevalue(newwx#,watergunx#,20)
waterguny# = 300
if abs(watergunx#-newwx#) < 1 then targethit=1
endif
if sprite collision(5,3)=1
delete sprite 4
show sprite 2
delete sprite 5
p2health#=p2health#-watergundamage#
` Reset watergun location
watergunx# = p1x+50
waterguny# = p1y+35
` Reset mouse target
newwx# = watergunx#
newwy# = waterguny#
` De-select weapon
weaponSelected1#=0
turn$="p2"
delete sprite 50
show mouse
endif
if sprite collision(5,50)=1 and targethit=1
delete sprite 4
show sprite 2
delete sprite 5
` Reset watergun location
watergunx# = p1x+50
waterguny# = p1y+35
` Reset mouse target
newwx# = watergunx#
newwy# = waterguny#
` De-select weapon
weaponSelected1#=0
turn$="p2"
delete sprite 50
show mouse
endif
endif
endif
endif
`____________________________
if turn$="p2"
`Begin Player 2
if weaponSelected2#=1
if p2weapon1$="handle"
hide mouse
sprite 50,mousex(),mousey(),9
sprite 4,p2x,p2y,19
sprite 5,p2x,p2y,20
sprite 6,handlex#,handley#,21
dir=0
if sprite mirrored(4)=0 or sprite mirrored(5)=0 or sprite mirrored(6)=0 and dir=0
mirror sprite 4
mirror sprite 5
mirror sprite 6
dir=1
endif
hide sprite 4
hide sprite 5
hide sprite 6
if mouseclick()=1
newhx# = mousex()
randomize# = 1
hide sprite 3
show sprite 4
wait 200
hide sprite 4
show sprite 5
wait 200
hide sprite 5
show sprite 4
wait 200
hide sprite 4
show sprite 5
wait 200
show sprite 4
endif
if randomize# = 1
fishpeople = rnd(10)
if fishpeople>2
targethit=0
fish=1
else
refresh#=1
endif
endif
if targethit = 0 and fish=1
show sprite 3
show sprite 6
delete sprite 4
delete sprite 5
handlex# = curvevalue(newhx#,handlex#,20)
handley# = p2y-100
if abs(handlex#-newhx#) < 1 then targethit=1
endif
if sprite collision(6,50)=1 and targethit=1
delete sprite 6
handlex# = p2x
handley# = p2y-100
newhx# = handlex#
weaponSelected2#=0
turn$="p1"
delete sprite 50
show mouse
endif
if sprite collision(6,2)=1
delete sprite 6
p1health#=p1health#-30
handlex# = p2x
handley# = p2y-100
newhx# = handlex#
weaponSelected2#=0
turn$="p1"
delete sprite 50
show mouse
endif
if refresh#=1
delete sprite 6
handlex# = p2x
handley# = p2y-100
newhx# = handlex#
weaponSelected2#=0
turn$="p1"
delete sprite 50
show mouse
endif
endif
endif
endif
`___________________
did not work. How can I modify this code to make it run more stable and integrate a turn system into it?
Thanks!
Zeus