Fangames > Programming Questions
Mid-Boss Avoidance
BaronBlade:
--- Quote from: Kyir on December 23, 2015, 08:30:06 PM ---Persistence is more trouble than it's worth in my opinion. My way has the added benefit of simplifying things if you want attacks to change after the avoidance. There are plenty of options to choose from when it comes to this sort of thing though.
--- End quote ---
Thanks for the tip, Kyir! With your way, though, would I be able to keep the healthbar at a fraction of the total health? I'm really unfamiliar with how healthbars are handled in gamemaker studio.
Aelya:
if it comes down to it, you could always just make your own healthbar object too
Kyir:
--- Quote from: BaronBlade on December 23, 2015, 09:52:39 PM ---
--- Quote from: Kyir on December 23, 2015, 08:30:06 PM ---Persistence is more trouble than it's worth in my opinion. My way has the added benefit of simplifying things if you want attacks to change after the avoidance. There are plenty of options to choose from when it comes to this sort of thing though.
--- End quote ---
Thanks for the tip, Kyir! With your way, though, would I be able to keep the healthbar at a fraction of the total health? I'm really unfamiliar with how healthbars are handled in gamemaker studio.
--- End quote ---
To be honest, I don't have a lot of experience with visible health bars myself. If you want one that persists through the whole fight, one of the other options suggested would probably be more suited to it.
lawatson:
Not trying too hard to stray from the topic and just convey my point on one post, the math behind health bars is easy: You get the x position and the max length of the health bar, and then you divide the max length by the max HP and then multiply that result by the HP you already have. That gets you an interpolated value between the x position and the maximum length which you can use as either the xscale of a 1px long sprite OR just the rightwards coordinate in a rectangle.
tl;dr:
xdist=maxLength/maxHP*HP;
paired with
make_rectangle(x,y,x+xdist,y+anything);
OR
draw_sprite_ext(sprHealthBar,0,x,y,xdist,1,0,c_white,1);
And you can combine this with the code from before to get a working healthbar which is based on a global.HP variable or so-so. I hope you understand.
Derf:
--- Quote from: Kyir on December 23, 2015, 08:30:06 PM ---Persistence is more trouble than it's worth in my opinion. My way has the added benefit of simplifying things if you want attacks to change after the avoidance. There are plenty of options to choose from when it comes to this sort of thing though.
--- End quote ---
I don't understand why you would suggest making two objects when one will suffice. Not to mention you'd also have to create a second separate room to house this object unless you want to code an exception of what to spawn when re-entering the initial room, and by that point you're doing enough coding that you may as well use global variables anyway because they'll take less effort and lines of code. The added benefit you mention is also something that can easily and simply be achieved by either of the other two methods by putting a switch case or if/else statement for the bosses health in the code block where you program its attacks, which is likely something that will already be coded in if it's a functional boss. The problem with this suggestion is it appears initially very simple, and indeed the initial step is more simple than any of the other methods, but it's so inefficient that when it comes to things like handling re-spawning back into the room and having healthbars it's clearly the least efficient of the methods mentioned.
There are situations where you can get away with cowboy coding to create shortcuts in the design process, but when you're creating something as finicky as a three-part boss it's best to just use tried and true methods like global.variables that have literally no downsides and won't create fringe issues which will come back to bite you later on in the process.
--- Quote from: BaronBlade on December 23, 2015, 09:52:39 PM ---
--- Quote from: Kyir on December 23, 2015, 08:30:06 PM ---Persistence is more trouble than it's worth in my opinion. My way has the added benefit of simplifying things if you want attacks to change after the avoidance. There are plenty of options to choose from when it comes to this sort of thing though.
--- End quote ---
Thanks for the tip, Kyir! With your way, though, would I be able to keep the healthbar at a fraction of the total health? I'm really unfamiliar with how healthbars are handled in gamemaker studio.
--- End quote ---
Are you coding the healthbar from scratch or using GMs in built functionality for healthbars? Lawatson's suggestion seems like a good way to go (and you could certainly do it with Kyir's method but it would probably end up being more confusing). It might be worthwhile using global.variables to handle the bosses health and making the heathbar object itself persistent.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version