--set the path to find the image to use to display behind the health text health_i = LoadImage("scriptbank\\images\\hud\\health_bg.png") --set the path to the image to use behind the gun & ammo count ammo_i = LoadImage("scriptbank\\images\\hud\\ammo_bg.png") --set the path to the image to use behind the lives counter lives_i = LoadImage("scriptbank\\images\\hud\\lives_bg.png") --note values are % of screen so 50 is middle of the screen health_posx = 40 --x position of the health hud health_posy = 1 --y position of the health hud health_sizex = 19 --x size of health hud health_sizey = 14 --y size of the health hud --set values again for the ammo counter ammo_posx = 4 ammo_posy = 89 ammo_sizex = 14 ammo_sizey = 9 --set values again for the lives count lives_posx = 84 lives_posy = 89 lives_sizex = 9 lives_sizey = 9 --colour of the text in RGB format (0,0,0 = black and 255,255,255 = white) health_red = 0 health_blue = 0 health_green = 0 --colour for ammo text ammo_red = 0 ammo_green = 0 ammo_blue = 0 --colour for lives text lives_red = 0 lives_green = 0 lives_blue = 0 --the size of the text (1 = small, 5 = big) text_size = 5 --note the text position is currently automatically placed in the center of the image --set to 1 if you want the max_PlayerHealth to increase when players current health goes above it (not a good idea if you are using a temporary health increase effect in your level) dynamic_max_health = 1 max_PlayerHealth = nil health_sprite = nil ammo_sprite = nil lives_sprite = nil player_dead = 0 function custom_hud_init(e) HideHuds() Hide(e) CollisionOff(e) end function custom_hud_main(e) --create and size sprites if health_sprite == nil and health_i ~= nil then health_sprite = CreateSprite(health_i) SetSpriteSize(health_sprite,health_sizex,health_sizey) else if ammo_sprite == nil and ammo_i ~= nil then ammo_sprite = CreateSprite(ammo_i) SetSpriteSize(ammo_sprite,ammo_sizex,ammo_sizey) else if lives_sprite == nil and lives_i ~= nil then lives_sprite = CreateSprite(lives_i) SetSpriteSize(lives_sprite,lives_sizex,lives_sizey) else --handles player max health if max_PlayerHealth == nil then max_PlayerHealth = g_PlayerHealth else --checks if we want to increase the players max health if dynamic_max_health == 1 then if g_PlayerHealth > max_PlayerHealth then max_PlayerHealth = g_PlayerHealth end end --check if player died and restore his health to max health if g_PlayerHealth < 1 then player_dead = 1 elseif player_dead == 1 then SetPlayerHealth(max_PlayerHealth) player_dead = 0 end --show the health hud SetSpritePosition ( health_sprite, health_posx , health_posy ) PasteSprite ( health_sprite ) TextCenterOnXColor(health_posx+(health_sizex/2),health_posy+(health_sizey/(text_size-1)),text_size,g_PlayerHealth.." / "..max_PlayerHealth,health_red,health_green,health_blue) SetSpritePosition ( health_sprite, -9999, -9999 ) --show the ammo hud SetSpritePosition ( ammo_sprite, ammo_posx , ammo_posy ) PasteSprite ( ammo_sprite ) TextCenterOnXColor(ammo_posx+(ammo_sizex/2),ammo_posy+(ammo_sizey/(text_size-1)),text_size,g_PlayerGunAmmoCount.." / "..g_PlayerGunClipCount,ammo_red,ammo_green,ammo_blue) SetSpritePosition ( ammo_sprite, -9999, -9999 ) --show the lives hud SetSpritePosition ( lives_sprite, lives_posx , lives_posy ) PasteSprite ( lives_sprite ) TextCenterOnXColor(lives_posx+(lives_sizex/2),lives_posy+(lives_sizey/(text_size-1)),text_size,g_PlayerLives,lives_red,lives_green,lives_blue) SetSpritePosition ( lives_sprite, -9999, -9999 ) end --max_PlayerHealth set end --lives_sprite created end --ammo_sprite created end --health_sprite created end --main function custom_hud_exit(e) end