CP - Alien Breed Remake - 3

Miscellaneous Forums/Blitz Showcase/CP - Alien Breed Remake - 3

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.

Made a couple of changes to the collection of items and added health when collected:

Player.bb - Player_UpdateAll:
	; collect objects
	If gettile(pl\x,pl\y,2)>0

		;Determine what the player has collected
		; Don't add ammo to the collected list
		
		objcollect = gettile(pl\x,pl\y,2)
		collectable = True
					
		Select objcollect
			Case 1	;Ammo
				givePlayerAmmo(pl,15)
                                playoneshot(clip_pickup,pl\x,pl\y) ;Change once we get a proper sfx
				collectable = False
				
			Case 2	;Health
				Player_GiveHealth(pl,15)
				playoneshot(health_pickup,pl\x,pl\y)
				
			Case 3,4,5,6
				playoneshot(key_pickup,pl\x,pl\y)
				
			Case 9
				collectable = False
				
		End Select

		puttile(pl\x,pl\y,2,0)
		
		If collectable	
			p.pickedup = New pickedup
			p\player = pl\id ; allowing for multiple players
			p\obj = objcollect				
			
		EndIf
		
	EndIf


and add this function to Player.bb
Function Player_GiveHealth(p.player, h#)
	p\health = p\health + h
	If p\health > 100 Then
		p\health = 100
			
	End If

End Function


Also change the firing check after get input to stop firing animation from processing when you have no ammo:
	If Firing=True And (pl\clip>=0 And pl\ammo>0) Then
		If MilliSecs()>Pl\IsFiringTimer
			Pl\IsFiringTimer=MilliSecs()+25
			pl\IsFiring = Not pl\IsFiring
		EndIf
	Else
		Pl\IsFiring=False
	EndIf


We also need a couple of sounds:
* clicking when player out of ammo
* re-load sound when player collects ammo