bullet help

Blitz3D Forums/Blitz3D Beginners Area/bullet help

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

alright I need some more help, when I try to switch my guns everything works out fine but when I try to shoot them seperate, nothing comes out of the shotgun but both bullets come out of the pistol

AppTitle "Attack of the Evil Smileys"
Graphics 800,600,0,2
SetBuffer BackBuffer()

;load images

character = LoadImage("Images\killer.png")
MaskImage character,255,0,255

smiley = LoadAnimImage("Images\smiley.png",38,36,0,2)
MaskImage smiley,255,0,255

healthpack = LoadImage("Images\healthbar.png")

ishotgun = LoadImage("Images\ishotgun.png")
MaskImage ishotgun,255,255,255

ipistol = LoadImage("Images\ipistol.png")
MaskImage ipistol,255,255,255

ibullet = LoadImage("Images\ibullet.png")
MaskImage ibullet,255,255,255

isbullet = LoadImage("Images\isbullet.bmp")
MaskImage isbullet,255,255,255

Type player
	Field x,y
	Field health
	Field image
	Field lives
	Field score
End Type

Type enemy
	Field x,y
	Field health
	Field image
	Field frame
End Type

Type health_pack
	Field x,y
End Type

Type shotgun
	Field x,y
	Field ammo
End Type

Type pistol
	Field x,y
	Field ammo
End Type

Type bullet
	Field x,y
End Type

player.player = New player
enemy.enemy = New enemy
health_pack.health_pack = New health_pack
shotgun.shotgun = New shotgun
pistol.pistol = New pistol


player\x = 400
player\y = 500
player\health = 100
player\lives = 3
player\score = 0

enemy\x = 100
enemy\y = 500
enemy\health = 100

health_pack\x = 500
health_pack\y = 500

shotgun\ammo = 25
pistol\ammo = 30


; if player is facing left or right
direction = 1
;Holding Gun?
hshotgun = 0
hpistol = 0
hm4a1 = 0
eshotgun = 0
epistol = 0
em4a1 = 0



While Not KeyHit(1)


	
;move player
If KeyDown(203)
player\x = player\x - 2
direction = 0
EndIf
If KeyDown(205)
player\x = player\x + 2
direction = 1
EndIf





;update colliding thanks to shane from blitzcoder
For h.health_pack = Each health_pack
  If ImagesCollide(character,player\x,player\y,0,healthpack,h\x,h\y,0) Then
    player\health = player\health + 20
    Delete h

    If player\health >= 150
      player\health = 150
    EndIf
  EndIf
Next




;update characters

	If ImagesCollide(character,player\x,player\y,0,smiley,enemy\x,enemy\y,0) And enemy\frame <>1
	player\health = player\health - 10
	enemy\frame = enemy\frame + 1
EndIf







;update ghetto hud

Locate 0,20 Print "lives: " + player\lives
Locate 0,40 Print "Score: " + player\score
Locate 0,0 Print "health: " + player\health





;draw the characters
DrawImage(character,player\x,player\y)

For h.health_pack = Each health_pack
DrawImage(healthpack,h\x,h\y)
Next

DrawImage(smiley,enemy\x,enemy\y,enemy\frame)

If KeyHit(2)
hshotgun = 1
hpistol = 0
EndIf

If KeyHit(3)
hpistol = 1
hshotgun = 0
EndIf

If hshotgun = 1
shotgun\x = player\x + 5
shotgun\y = player\y + 25
DrawImage(ishotgun,shotgun\x,shotgun\y)
Locate 500,10 Print "Ammo: " + shotgun\ammo
EndIf

If hpistol = 1 
pistol\x = player\x + 35
pistol\y = player\y + 6
DrawImage(ipistol,pistol\x,pistol\y)
Locate 500,10 Print "Ammo: " + pistol\ammo
EndIf




If KeyHit(57) And hpistol = 1 And pistol\ammo > 0 
b.bullet = New bullet

b\x = pistol\x

b\y = pistol\y

pistol\ammo = pistol\ammo - 1

If pistol\ammo <= 0
pistol\ammo = 0
EndIf
EndIf
For b.bullet = Each bullet
  b\x = b\x + 6
  DrawImage(ibullet,b\x,b\y)
Next

If KeyHit(57) And hshotgun = 1 And shotgun\ammo > 0
s.bullet = New bullet

s\x = shotgun\x
s\y = shotgun\y

shotgun\ammo = shotgun\ammo - 1


If shotgun\ammo <= 0
shotgun\ammo = 0
EndIf
EndIf
For s.bullet = Each bullet
  s\x = s\x + 8
  DrawImage(isbullet,s\x,s\y)
Next


Flip
Cls
Wend
End