Another Custom HUD Question

Status
Not open for further replies.

WellDoneSnake

Yoko Shimomura
EDIT: I decided to move on from this idea for the time being, mainly due to the graphics and onscreen effects I'm working with not really fitting the style of the levels I'm making.

If any of you still have some advice to the old post hidden in the spoiler below, then feel free to respond.

So...
It's been a long time since I touched anything lua related.

Lately I've been trying to create a custom stage title HUD.

The aim was to make my custom stage title appear instead of the original srb2 stage titles, while also making sure that they slide on and off the screen when you just start a level.

I attempted this using my old "starpost-item-giving" lua file as a template.

The problem that I had bumped into however, was that I couldn't figure out how to make the custom stage title slide off the screen.

Imagine this but instead of fading out, the title and its background would keep moving to the right, until it is no longer on screen.

Here's the current code I have for this:
Code:
local fonttimer = 0
local fontbacktimer = 0
local frontxpos = 70
local backxpos = 50

//Timer for stage title HUD in the front
local function startFontTimer()
	for player in players.iterate
		if player.fonttimer != nil and player.fonttimer > 0
			player.fonttimer = $1 - 1
			if player.fonttimer < TICRATE
				player.frontxpos = $1 + 1
				if player.frontxpos > 200
					player.fonttimer = 0
				end
			end
		end
	end
end

//Timer for stage title background HUD in the back
local function startFontBacktimer()
	for player in players.iterate
		if player.fontbacktimer != nil and player.fontbacktimer > 0
			player.fontbacktimer = $1 - 1
			if player.fontbacktimer < TICRATE 
				player.backxpos = $1 + 1
				if player.backxpos > 200
					player.fontbacktimer = 0
				end
			end
		end
	end
end

local function LevelSpawn(player)
	player.fonttimer = 2*TICRATE
	player.fontappear = "TESTFNT" //Name of stage title front image
	player.frontxpos = 0
	player.fontbacktimer = 2*TICRATE
	player.fontbackappear = "DBLOCK" //Name of stage title background image
	player.backxpos = 0
end

local function fonty(v, stplyr)
	if stplyr.fonttimer != nil and stplyr.fonttimer > 0
		local fontpatch = (v.cachePatch(stplyr.fontappear))
			v.draw(frontxpos, 82, fontpatch)
	end
end

local function funty(v, stplyr)
	if stplyr.fontbacktimer != nil and stplyr.fontbacktimer > 0
		local fontbackpatch = (v.cachePatch(stplyr.fontbackappear))
			v.draw(backxpos, 80, fontbackpatch)
	end
end
hud.add(funty) //Place before "fonty" so that the background isn't seen in front of the stage title
hud.add(fonty)
hud.disable("stagetitle")
addHook ("ThinkFrame", startFontTimer)
addHook ("ThinkFrame", startFontBacktimer)
addHook ("PlayerSpawn", LevelSpawn)

I'm pretty much lost here on how to mix the timer scripting with a script for sliding the HUD.
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top