Oh, sorry you don't like the new hud, guys. Bit miffed about that, but hey ho, you don't like it, you don't like it. Fair enough. Here's the old weapons.bb code to revert to the previous hud followed by the hud.bb and old (changed) hud.png to put in gfx\hud
as well as the old hud.bb
And the old Hud image with the lives bit taken out.
www.3030deathwar.co.uk/downloads/ab/hud.png
Global bulletgfx = LoadAnimImage("gfx\weapons\bullets.png",8,8,0,4) MaskImage bulletgfx,255,0,255 Type weapon Field id Field name$ Field maxClip,damage# Field ammo_in_a_clip Field bulletSpeed# Field fireRate ; in ms (passed to player when they get given the weapon) Field fireSoundChannel,fireSound Field outOfAmmoSoundChannel,outOfSound Field reloadSoundChannel,reloadSound Field muzzleFlashImage Field btype Field hud_image End Type Function setupWeapons(modifier#=1.0) ; create the weapons we want in the game ;createWeapon.weapon... ; default gun [weaponBroadhurst] pistol ; rating = crappy ; speed = instant ; damage = bad, so bad ; number of bullets = 1 ; max clips = 5 ; bullets in a clip = 10 ; default gun [weaponDalton] machine gun ; rating = kinda crappy ; speed = medium ; damage = very bad ; number of bullets = 1 ; max clips = 5 ; bullets in a clip = 30 ; default gun [weaponRobinson] shotgun ; rating = alright ; speed = slow ; damage = medium ; number of bullets = 4 ; max clips = 5 ; bullets in a clip = 4 ; default gun [weaponRyxx] flamethrower ; rating = pretty cool ; speed = very slow ; damage = medium/high ; number of bullets = N/A ; max clips = 1 ; bullets in a clip = 100 ; default gun [weaponStyrling] plasma light ; rating = dudish, slow though ; speed = very fast ; damage = high ; number of bullets = 1 ; max clips = 3 ; bullets in a clip = 5 ; default gun [weaponImpact] laser ; rating = er... dunno really ; speed = very fast ; damage = high ; number of bullets = 1 ; max clips = 3 ; bullets in a clip = 15 ; ...(id,name$, dmg#, maxclp,aiac,rate, speed#, bullettype, image$,s1$="",s2$="",s3$="") createWeapon(1,weaponBroadhurst, 1.0*modifier, 5, 10, 200, 10.0, 2, 21, "sfx\mgun.mp3", "", "sfx\pistolreload1.mp3") createWeapon(2,weaponDalton, 0.7*modifier, 5, 30, 80, 8.0, 1, 22, "", "", "") createWeapon(3,weaponRobinson, 0.5*modifier, 10, 4, 290, 10.0, 0, 23, "", "", "") createWeapon(4,weaponRyxx, 0.4*modifier, 1, 100, 140, 3.0, -1, 24, "", "", "") createWeapon(5,weaponStyrling, 7.0*modifier, 3, 5, 1000, 15.0, 3, 25, "", "", "") createWeapon(6,weaponImpact, 6.5*modifier, 3, 15, 220, 3.0, 3, 26, "", "", "") End Function ; create a weapon instance. We only need one. It's more of a prototype. Function createWeapon.weapon(id,name$,damage#,maxc,aiac,rate,speed#,bullettype,imageframe,s1$="",s2$="",s3$="") w.weapon=New weapon w\id=id w\name=name w\damage=damage w\maxClip=maxc w\hud_image=imageframe w\ammo_in_a_clip=aiac w\fireRate=rate w\bulletSpeed=speed w\btype = bullettype If s1<>"" w\fireSound=LoadSound(s1) ; USE: w\fireSoundChannel=PlaySound(w\fireSound) EndIf If s2<>"" w\outOfSound=LoadSound(s2) EndIf If s3<>"" w\reloadSound=LoadSound(s3) SoundVolume w\reloadsound,10.0 EndIf Return w End Function Function reloadPlayer(p.player) If p = Null Then Return If p\weaponClip[p\weapon\id]=0 Then Return p\weaponClip[p\weapon\id]=p\weaponClip[p\weapon\id]-1 p\weaponAmmo[p\weapon\id]=p\weapon\ammo_in_a_clip ; player reload sound p\weapon\reloadSoundChannel=PlaySound(p\weapon\reloadSound) End Function Function givePlayerAmmo(p.player,amount=15) If p = Null Then Return If p\weapon=Null Then Return If p\weaponAmmo[p\weapon\id]+amount >= p\weapon\ammo_in_a_clip p\weaponClip[p\weapon\id] = p\weaponClip[p\weapon\id]+1 ; if we've picked up a clip and we have no ammo, then load it automatically. If p\weaponClip[p\weapon\id]=1 And p\weaponAmmo[p\weapon\id]=0 Then reloadPlayer(p) EndIf ; we can't have more clips than the weapon can allow. If p\weapon\maxClip <>-1 ; if the maxClip is -1 then you can hold an infinite number of clips If p\weaponClip[p\weapon\id] > p\weapon\maxClip Then p\weaponClip[p\weapon\id]=p\weapon\maxClip EndIf Else p\weaponAmmo[p\weapon\id] = p\weaponAmmo[p\weapon\id] + amount EndIf End Function Function getWeaponFromName.weapon(name$) name=Lower(name) For w.weapon=Each weapon If Lower(w\name)=name Then Return w Next End Function Function giveWeaponToPlayer(p.player,w.weapon) If p = Null Then Return If w = Null Then Return p\weapon=w p\fireRate=p\weapon\fireRate p\tempFR = MilliSecs() If p\ownedWeapons[w\id]<>Null ; already got it. Add one ammo. Else ; give this weapon to the player p\ownedWeapons[w\id]=w p\weaponAmmo[w\id]=w\ammo_in_a_clip EndIf End Function Function EquipWeapon(id,w.weapon) If w = Null Then Return If id=1 Then p.player=First player Else p.player=Last player ok=False For i=1 To 6 If p\ownedWeapons[i]=w Then ok=True Next If ok=False Then Return ; make a sound If p\weapon<>w ; so we only play the sound once. We're using keydown p\weapon=w p\weapon\reloadSoundChannel=PlaySound(p\weapon\reloadSound) p\fireRate=p\weapon\fireRate p\tempFR = MilliSecs() Else p\weapon=w p\fireRate=p\weapon\fireRate p\tempFR = MilliSecs() EndIf End Function Function deleteWeapons() For i.weapon=Each weapon If i\fireSound<>0 Then FreeSound(i\fireSound) If i\outOfSound<>0 Then FreeSound(i\outOfSound) Delete i Next End Function ; the force is here because if you use ; keydown() when shooting it will wait for the ; fireRate to time out. But if you use Keyhit() ; you'll want to override the fireRate timeout. Function fireWeapon(p.player,angle,force=0) If p = Null Then Return If p\weapon = Null Then Return ; fire rate check If ((MilliSecs()-p\tempFR) > p\fireRate) Or force p\tempFR=MilliSecs() If p\weaponAmmo[p\weapon\id] > 0 shoot(p,angle) If p\weapon\name<>weaponRyxx shakeScreen(1,1,100) EndIf EndIf EndIf End Function ; -------------------------------- Type bullet Field x#,y# Field vx#,vy# Field owner.player Field life,damage# Field btype,special Field scenary ;scenary bullets can hurt both bad guys and players End Type Function shoot(p.player,angle) Local offset#=26.0 speed#=p\weapon\bulletSpeed ;Check player can fire If p\Clip > 0 Or p\ammo > 0 Then Select p\weapon\id Case 6: ; laser b.bullet =New bullet b\owner = p b\btype = p\weapon\btype b\damage=p\weapon\damage b\life=-99 ; live until you hit a wall ang#=angle b\x=p\x+Sin(ang)*offset b\y=p\y-Cos(ang)*offset b\vx=Sin(ang)*speed b\vy=-Cos(ang)*speed b\special=True ; laser! Case 5: ; something? b.bullet =New bullet b\owner = p b\btype = p\weapon\btype b\damage=p\weapon\damage ang#=angle b\life=-99 ; live until you hit a wall b\x=p\x+Sin(ang)*offset b\y=p\y-Cos(ang)*offset b\vx=Sin(ang)*speed b\vy=-Cos(ang)*speed flames#=3.0 createparticle(b\x,b\y,Sin(ang-45)*flames,-Cos(ang-45)*flames,20,0,6,large_blast_image,16) createparticle(b\x,b\y,Sin(ang+45)*flames,-Cos(ang+45)*flames,20,0,6,large_blast_image,16) createparticle(b\x,b\y,Sin(ang+90)*flames/2,-Cos(ang+90)*flames/2,20,0,6,small_blast_image,16) createparticle(b\x,b\y,Sin(ang-90)*flames/2,-Cos(ang-90)*flames/2,20,0,6,large_blast_image,16) Case 3: ; shotgun? For i=1 To 3 b.bullet =New bullet b\owner = p b\life=-99 ; live until you hit a wall b\btype = p\weapon\btype b\damage=p\weapon\damage ang#=angle+Rnd(-3,3) speed=speed+Rnd(-0.1,0.1) b\x=p\x+Sin(ang)*offset b\y=p\y-Cos(ang)*offset b\vx=Sin(ang)*speed b\vy=-Cos(ang)*speed Next Case 2: ; plasma gun b.bullet =New bullet b\owner = p b\life=50 b\btype = p\weapon\btype b\damage=p\weapon\damage ang#=angle b\x=p\x+Sin(ang)*offset b\y=p\y-Cos(ang)*offset b\vx=Sin(ang)*speed b\vy=-Cos(ang)*speed flames#=3.0 createparticle(b\x,b\y,Sin(ang-45)*flames,-Cos(ang-45)*flames,20,0,6,large_blast_image,16) createparticle(b\x,b\y,Sin(ang+45)*flames,-Cos(ang+45)*flames,20,0,6,large_blast_image,16) Case 4: ;flamethrower For i=1 To Rand(4,6) b.bullet =New bullet b\owner = p b\life=50 b\btype = p\weapon\btype b\damage=p\weapon\damage ang#=angle+Rnd(-3,3) b\x=p\x+Sin(ang)*offset b\y=p\y-Cos(ang)*offset b\vx=Sin(ang)*speed b\vy=-Cos(ang)*speed ex#=Rnd(-0.4,0.4) ey#=Rnd(-0.4,0.4) If Rand(1,2)=1 createparticle(b\x,b\y,(b\vx*4)+ex,(b\vy*4)+ey,80,0,6,large_blast_image,16) Else createparticle(b\x,b\y,(b\vx*3)+ex*2,(b\vy*3)+ey*2,40,0,9,small_blast_image,16) EndIf Next Default: b.bullet =New bullet b\owner = p b\life=-99 ; live until you hit a wall b\btype = p\weapon\btype b\damage=p\weapon\damage ang#=angle b\x=p\x+Sin(ang)*offset b\y=p\y-Cos(ang)*offset b\vx=Sin(ang)*speed b\vy=-Cos(ang)*speed ; create bullet shell flying out. out#=Rnd(2,5) ang=ang+Rand(-7,3) createparticle(p\x+Sin(ang)*(offset*0.6),p\y-Cos(ang)*(offset*0.6),Sin(ang+90)*out,-Cos(ang+90)*out,Rand(20,50),3,3,bulletgfx,1) End Select ;Update counter for player status p\shots = p\shots + 1 ; create muzzle flash If use_sound p\weapon\fireSoundChannel=PlaySound(p\weapon\fireSound) EndIf ;Update clip and ammo count If Not unlimited_ammo Then p\weaponAmmo[p\weapon\id]= p\weaponAmmo[p\weapon\id] - 1 If p\weaponAmmo[p\weapon\id] = 0 Then reloadPlayer(p) ; reload the player's weapon. EndIf Else ;TODO: no fire - empty click sound p\weapon\outOfAmmoSoundChannel=PlaySound(p\weapon\outOfSound) EndIf End Function Function foebullet(x#,y#,angle,btype) b.bullet =New bullet b\scenary = 1 b\life=100 b\btype = btype b\damage=5 b\x=x b\y=y speed=3 b\vx=Sin(angle)*speed b\vy=-Cos(angle)*speed End Function Function explode(x#,y#) ang=Rand(0,359) For n=1 To 20 b.bullet =New bullet b\scenary = 1 b\life=20 b\btype = 2 b\damage=5 b\x=x b\y=y speed#=Rnd(1,3) b\vx=Sin(ang)*speed b\vy=-Cos(ang)*speed ex#=Sin(a) ey#=Cos(a) If Rand(1,2)=1 createparticle(b\x,b\y,(b\vx)*3,(b\vy)*speed,80,0,6,large_blast_image,16) Else createparticle(b\x,b\y,(b\vx)*3,(b\vy)*speed,40,0,9,small_blast_image,16) EndIf ang=ang+Rand(20,80) Next End Function Function handleBullets() For b.bullet=Each bullet ; each bullet has a damage from its parent weapon; ; use b\damage when hitting aliens and stuff. ok=True bx=b\x by=b\y If bx < 32 Then ok=False If by < 32 Then ok=False If bx > 7552 Then ok=False If by > 7552 Then ok=False If b\life<0 Then ok=False If b\life=-99 Then ok=True If ok=True result=gettile(b\x,b\y,LayerCollision) Select Result Case czStatic,czVisStatic ;bullet hit wall ok = False Case czDynamic,czVisDynamic ;bullet hit destructible collision zone ok = False DamageTile(b\x,b\y,1);change to weapon damage so that different weapons will damage faster or slower? End Select For al.alien = Each alien If ImagesCollide(bulletgfx,b\x,b\y,1, aliengfx(al\image),al\x-al\offset,al\y-al\offset,al\dir) ;circlesoverlap(al\x,al\y,al\radius,bx+16,by+16,3) killed = alien_hit(al,b\damage) If killed = True And b\scenary<>1 Then ;Update counter for player status b\owner\kills = b\owner\ammo + 1 End If ok=False ;bullet hit alien EndIf Next ; scenary bullets (explosions, cannons, aliens shooting) can hurt the player If b\scenary = 1 For pl.player = Each player If circlesoverlap(b\x-4,b\y-4,4,pl\x-32,pl\y-32,playerradius) Player_affectHealth(pl,b\damage) ok=False ;bullet hit player EndIf Next EndIf EndIf If b\life<>-99 Then b\life=b\life-1 b\x=(b\x+b\vx) b\y=(b\y+b\vy) If ok=False Then kill_bullet(b) Next End Function Function kill_bullet(b.bullet) ; different blast based on the bullet type If b\btype=0 Then blastHere(Rand(1,2),b\x-16,b\y-16,0.3) If b\btype=1 Then blastHere(Rand(1,2),b\x-16,b\y-16,0.3) If b\btype=2 Then blastHere(Rand(1,2),b\x-16,b\y-16,0.3) If b\btype=3 Then blastHere(Rand(1,2),b\x-16,b\y-16,0.3) Delete b.bullet End Function Function drawBullets() For b.bullet=Each bullet bx=b\x-GOffsetX by=b\y-GOffsetY If b\special=0 If b\btype<>-1 Then DrawImage bulletgfx,bx-3,by-3,b\btype Else ; draw a red laser line i.bullet=Before b If i<>Null bx2=i\x-GOffsetX by2=i\y-GOffsetY ; only draw on screen If bx2 < GraphicsWidth() And bx2 > 0 If by2 < GraphicsHeight() And by2 > 0 Color 255-Rand(5,20),0,0 Line bx2,by2,bx,by EndIf EndIf EndIf EndIf Next End Function
as well as the old hud.bb
; simple hud Global hud_block,hud_background,lives_block Function setupHUD() hud_background=LoadImage("gfx\hud\hud.png") ; create block images on the fly hud_block=CreateImage(4,16) SetBuffer ImageBuffer(hud_block) Color 96,24,0 : Rect 0,0,4,2 : Rect 0,14,4,2 Color 144,40,0: Rect 0,2,4,2 : Rect 0,12,4,2 Color 180,84,0: Rect 0,4,4,2 : Rect 0,10,4,2 Color 216,140,0:Rect 0,6,4,4 SetBuffer BackBuffer() ; this'll have a green hue lives_block=CreateImage(4,16) SetBuffer ImageBuffer(lives_block) Color 0,96,24 : Rect 0,0,4,2 : Rect 0,14,4,2 Color 0,144,40: Rect 0,2,4,2 : Rect 0,12,4,2 Color 0,180,84: Rect 0,4,4,2 : Rect 0,10,4,2 Color 0,216,140:Rect 0,6,4,4 SetBuffer BackBuffer() End Function Function drawHUD() vy=GraphicsHeight()-40 ; no transparency DrawBlock hud_background,0,vy ; draw player lives, ammo and health For p.player=Each player ; draw a black background. Color 150,150,150 Rect 0,(GraphicsHeight()-ImageHeight(hud_background))-33,GraphicsWidth(),33,1 Color 0,0,0 Rect 0,(GraphicsHeight()-ImageHeight(hud_background))-33,GraphicsWidth(),1,1 y=(GraphicsHeight()-ImageHeight(hud_background))-32 If p=First player gx=2 Else gx=GraphicsWidth()-34 EndIf For u=0 To 5 If p\ownedWeapons[u+1]<>Null If p=First player ; check to see whether this is the selected weapon If p\ownedWeapons[u+1]=p\weapon Color 180,180,180 Rect gx+(u*33),y,32,32,1 EndIf DrawImage objects,gx+(u*33),y,p\ownedWeapons[u+1]\hud_image Else ; check to see whether this is the selected weapon If p\ownedWeapons[u+1]=p\weapon Color 180,180,180 Rect gx-(u*33),y,32,32,1 EndIf DrawImage objects,gx-(u*33),y,p\ownedWeapons[u+1]\hud_image EndIf EndIf Next ; health If p=First player Then x=62 Else x=382 y=2 For i=1 To p\health Step 3 DrawBlock hud_block,x+((i/3)*4),vy+y Next ; clips If p=First player Then x=62 Else x=382 y=24 For i=1 To p\Clip DrawBlock hud_block,(x+(i*5)),vy+y Next If p\Clip > 5 Color 255,255,255 ; indicate we've got more than 5 clips with a plus '+' If p = First player Then Text 50,vy+16,"+" Else Text 211,vy+16,"+" EndIf ; ammo If p=First player Then x=114 Else x=432 y=24 ammo=p\ammo clipSize=p\weapon\ammo_in_a_clip width#=(65/6) k#=(width/clipSize)*ammo For i=1 To k DrawBlock hud_block,x+(i*6),vy+y Next ; keys y=18 j1=0 : j2=0 ; count variables For pu.pickedup = Each pickedup ok=True Select Objectdef(pu\obj)\image Case 2,3,4,5: frame=Objectdef(pu\obj)\image Default: ok=False End Select ; if ok=false then we're attempting to draw ; a pickedup object that isn't a key. ; we only want to draw objects that are given ; the ok by the above select. If ok If pu\player=1 j1=j1+1 Viewport 250,vy+y,55,20 DrawImage Objects,(240+(10*j1)),vy+y,frame Viewport 0,0,GraphicsWidth(),GraphicsHeight() EndIf If pu\player=2 j2=j2+1 Viewport 570,vy+y,55,20 DrawImage Objects,560+(10*j2),vy+y,frame Viewport 0,0,GraphicsWidth(),GraphicsHeight() EndIf EndIf Next ; draw credits If p=First player Then x=254 Else x=575 y=6 btext x,vy+y,p\credits Next End Function
And the old Hud image with the lives bit taken out.
www.3030deathwar.co.uk/downloads/ab/hud.png