well , ive been studying , and i finally made a program that i think is kinda good , but I have a problem , I want it to have a secondary weapon and what happens is that I cant get it to work!! )+== any help please???
everything works like I want it to , but the weapons dont work)+ ive been trying very hard by the way ....just so u dont think im some noobie idiot looking for help . +) well thx !
Graphics 600,800,0,2
Const LEFTKEY = 203 , RIGHTKEY = 205, SPACEBAR = 57 , ENTER = 156, DEL = 211
Global counter = 0
Type luis
Field x,y
Field image
Field dirx
Field diry
End Type
Type ship
Field x,y
Field image
Field life
End Type
Type bullets
Field x,y
Field image
End Type
Type pb
Field x,y
End Type
Type bullets2
Field x,y
End Type
Global change = 0
Global pinguilife = 100
Global a = LoadImage("stars.bmp")
Global bullet2image = LoadImage("bullet2.jpg")
Global pbimage = LoadImage("playerbullet.bmp")
Global explosion = LoadSound("tan.wav")
Global scream2 = LoadSound("scream2.wav")
Global player.luis = New luis
Global ship.ship = New ship
player\image = LoadImage ("pingui.bmp")
ship\image = LoadImage("felicidad.bmp")
Global bulletimage = LoadImage ("image1.jpg")
MaskImage (bulletimage,0,0,0)
Global jaja = LoadSound("jaja.wav")
ScaleImage ship\image,.1,.1
player\x = 100
player\y = 100
player\dirx = Rnd(-1,1)
player\diry = Rnd(-1,1)
If player\dirx = 0
player\dirx = Rnd(-1,1)
EndIf
If player\diry = 0
player\diry = Rnd(-1,1)
EndIf
ScaleImage player\image,.1,.1
ship\x = 150
ship\y = 380
scrolly = 0
;main loop
;main loop
While Not KeyDown(1)
Cls
TileImage a,0,scrolly
scrolly = scrolly + 1
If scrolly >= ImageHeight(a)
scrolly = 0
EndIf
player\x = player\x + player\dirx
player\y = player\y + player\diry
DrawImage player\image,player\x,player\y
DrawImage ship\image,ship\x,ship\y
testpingui()
testbullets()
testkeys()
lifes()
pinguibullet()
secondaryweap()
pinguilife()
Delay 15
Flip
Wend
Function testpingui()
If player\x < 0 Or player\x > 300 - ImageWidth(player\image)
player\dirx = -player\dirx
EndIf
If player\y < 0 Or player\y > 400 - ImageHeight(player\image)
player\diry = -player\diry
EndIf
End Function
Function testkeys()
If KeyDown(LEFTKEY)
ship\x = ship\x - 3
EndIf
If KeyDown(RIGHTKEY)
ship\x = ship\x + 3
EndIf
If KeyHit(SPACEBAR)
If change = 0
bullet.bullets = New bullets
bullet\x = ship\x
bullet\y = ship\y
EndIf
If change = 1
bullet2.bullets2 = New bullets2
bullet2\x = ship\x
bullet2\y = ship\y
EndIf
EndIf
End Function
Function testbullets()
;
If change = 1
;
For bullet.bullets = Each bullets
bullet\y = bullet\y - 5
DrawImage bulletimage,bullet\x,bullet\y
;
If ImagesOverlap(bulletimage,bullet\x,bullet\y,player\image,player\x,player\y)
PlaySound scream2
pinguilife = pinguilife - 2
;
EndIf
If bullet\y < 0
Delete bullet
;
EndIf
;
Next
;
EndIf
;
If change = 0
;
For bullet2.bullets2 = Each bullets2
bullet2\y = bullet2\y - 3
DrawImage bullet2image , bullet2\x,bullet2\y
If ImagesCollide(bullet2image,bullet2\x,bullet2\y,0,player\image,player\x,player\y,0)
PlaySound Tan
pinguilife = pinguilife - 3
EndIf
;
;
Next
EndIf
End Function
Function pinguibullet()
For pbs.pb = Each pb
pbs\x = player\x + ImageWidth((player\image)/2)
pbs\y = player\y
pbs\y = pbs\y + 5
If pbs\y > GraphicsHeight
Delete pbs
Else DrawImage pbimage,pbs\x,pbs\y
EndIf
If ImagesCollide (pbimage,pbs\x,pbs\y,0,ship\image,ship\x,ship\y,0)
lifes = lifes - 1
PlaySound jaja
EndIf
Next
End Function
Function pinguilife()
If pinguilife < 0
Cls
Delay 2000
ClsColor 255,0,0
Cls
Delay 100
Text 200,100,"YOU WON!!!"
Delay 3000
End
End If
End Function
Function lifes()
lifes = 3
If lifes < 1
End
EndIf
End Function
Function secondaryweap()
If KeyHit(ENTER)
change = change + 1
EndIf
If change > 1 Or change < 0
Text 200,200,"What?"
change = 0
EndIf
If KeyHit(DEL)
change = change - 1
EndIf
End Function
everything works like I want it to , but the weapons dont work)+ ive been trying very hard by the way ....just so u dont think im some noobie idiot looking for help . +) well thx !
Graphics 600,800,0,2
Const LEFTKEY = 203 , RIGHTKEY = 205, SPACEBAR = 57 , ENTER = 156, DEL = 211
Global counter = 0
Type luis
Field x,y
Field image
Field dirx
Field diry
End Type
Type ship
Field x,y
Field image
Field life
End Type
Type bullets
Field x,y
Field image
End Type
Type pb
Field x,y
End Type
Type bullets2
Field x,y
End Type
Global change = 0
Global pinguilife = 100
Global a = LoadImage("stars.bmp")
Global bullet2image = LoadImage("bullet2.jpg")
Global pbimage = LoadImage("playerbullet.bmp")
Global explosion = LoadSound("tan.wav")
Global scream2 = LoadSound("scream2.wav")
Global player.luis = New luis
Global ship.ship = New ship
player\image = LoadImage ("pingui.bmp")
ship\image = LoadImage("felicidad.bmp")
Global bulletimage = LoadImage ("image1.jpg")
MaskImage (bulletimage,0,0,0)
Global jaja = LoadSound("jaja.wav")
ScaleImage ship\image,.1,.1
player\x = 100
player\y = 100
player\dirx = Rnd(-1,1)
player\diry = Rnd(-1,1)
If player\dirx = 0
player\dirx = Rnd(-1,1)
EndIf
If player\diry = 0
player\diry = Rnd(-1,1)
EndIf
ScaleImage player\image,.1,.1
ship\x = 150
ship\y = 380
scrolly = 0
;main loop
;main loop
While Not KeyDown(1)
Cls
TileImage a,0,scrolly
scrolly = scrolly + 1
If scrolly >= ImageHeight(a)
scrolly = 0
EndIf
player\x = player\x + player\dirx
player\y = player\y + player\diry
DrawImage player\image,player\x,player\y
DrawImage ship\image,ship\x,ship\y
testpingui()
testbullets()
testkeys()
lifes()
pinguibullet()
secondaryweap()
pinguilife()
Delay 15
Flip
Wend
Function testpingui()
If player\x < 0 Or player\x > 300 - ImageWidth(player\image)
player\dirx = -player\dirx
EndIf
If player\y < 0 Or player\y > 400 - ImageHeight(player\image)
player\diry = -player\diry
EndIf
End Function
Function testkeys()
If KeyDown(LEFTKEY)
ship\x = ship\x - 3
EndIf
If KeyDown(RIGHTKEY)
ship\x = ship\x + 3
EndIf
If KeyHit(SPACEBAR)
If change = 0
bullet.bullets = New bullets
bullet\x = ship\x
bullet\y = ship\y
EndIf
If change = 1
bullet2.bullets2 = New bullets2
bullet2\x = ship\x
bullet2\y = ship\y
EndIf
EndIf
End Function
Function testbullets()
;
If change = 1
;
For bullet.bullets = Each bullets
bullet\y = bullet\y - 5
DrawImage bulletimage,bullet\x,bullet\y
;
If ImagesOverlap(bulletimage,bullet\x,bullet\y,player\image,player\x,player\y)
PlaySound scream2
pinguilife = pinguilife - 2
;
EndIf
If bullet\y < 0
Delete bullet
;
EndIf
;
Next
;
EndIf
;
If change = 0
;
For bullet2.bullets2 = Each bullets2
bullet2\y = bullet2\y - 3
DrawImage bullet2image , bullet2\x,bullet2\y
If ImagesCollide(bullet2image,bullet2\x,bullet2\y,0,player\image,player\x,player\y,0)
PlaySound Tan
pinguilife = pinguilife - 3
EndIf
;
;
Next
EndIf
End Function
Function pinguibullet()
For pbs.pb = Each pb
pbs\x = player\x + ImageWidth((player\image)/2)
pbs\y = player\y
pbs\y = pbs\y + 5
If pbs\y > GraphicsHeight
Delete pbs
Else DrawImage pbimage,pbs\x,pbs\y
EndIf
If ImagesCollide (pbimage,pbs\x,pbs\y,0,ship\image,ship\x,ship\y,0)
lifes = lifes - 1
PlaySound jaja
EndIf
Next
End Function
Function pinguilife()
If pinguilife < 0
Cls
Delay 2000
ClsColor 255,0,0
Cls
Delay 100
Text 200,100,"YOU WON!!!"
Delay 3000
End
End If
End Function
Function lifes()
lifes = 3
If lifes < 1
End
EndIf
End Function
Function secondaryweap()
If KeyHit(ENTER)
change = change + 1
EndIf
If change > 1 Or change < 0
Text 200,200,"What?"
change = 0
EndIf
If KeyHit(DEL)
change = change - 1
EndIf
End Function