Fangames > Programming Questions
Invincibility Frames
HAEGOE:
first, here 'mod' means 'modulo operation' or 'remainder'.
so, if you say IFrame mod 4 < 2, it means if you divide 4 into the value 'IFrame' and you get a remainder less than 2.
and since the IFrame is dropping every frame, the remainder of the calculation will also be changed.
as the IFrame goes down, the remainder(IFrame mod 4) will take a cycle of 3->2->1->0->3->2->1->0->3->.. and so on.
now, when remainder is 1 or 0, then the IFrame mod 4 < 2 will be true, which means visible = 0 and boss will be invisible.
and when remainder is 2 or 3, then it will be false, visible = 1 and boss will be visible.
same goes with mod (interval X2) <(interval).
As the IFrame drops, IFrame mod (interval X2), or remainder will take a cycle from interval X2-1 to zero, then back to interval X2-1.
and if the remainder is smaller than interval, then the code will be true, and I believe you'll get the picture.
Of course, interval X2 means twice the interval. By setting it that way, half the remainder will be same or higher than the interval(which means false), and the other half will be lower than that(true), so that you can control the number of frames of invisibility toggle.
hope this is simple enough.. I'm not good at explaining things :atkCry:
LoneTree_tv:
Alright, thanks. I understood most of it, except for the interval and interval X2 stuff.
No need to explain. But if someone does know how to explain it to an absolute beginner like me, please do.
In the case that I do use the interval code, and just copy paste it,
what do I need to change to make the interval longer or shorter, and how many frames longer will it make it?
HAEGOE:
uhh.. you see, that's where the interval and interval X2 comes in.
for example, if you want to set interval as 5 frame, do this :
if IFrame>0 and IFrame mod 10 < 5 {
//the former is to make sure invisibility toggling works only when invincible, and the latter is for setting toggle interval
visible = 0;
}else{//when the boss is not invincible or when toggled from invisible to visible
visible = 1;
}
basically the same, but there interval is 5 and interval X2 is 10.
LoneTree_tv:
So interval isn't a constant or any thing, it'd just the number of frames that it takes before toggling?
Oops.
I thought it was some sort of built in function to gm.
Also, if I wanted the boss to stay visible twice as long as it stays invisible, I could put something like
mod 8 < 3
right?
finally, to clear up some confusion, MY idea wag up at the top of the thread that I said worked was in a form of an alarm. It didn't flash at every frame. I put alarm [11]=20 at the end of it.
sorry if my grammar or something sucks, I wrote this all on my phone :P
LoneTree_tv:
One more thing, hopefully the last,
How do you make a health bar appear?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version