Bouncy Digits Wanted!
Displaying 1-13 of 13 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
mcgrue

I would really like an atomic library to make the individual letters of a short string in any given font bounce quickly and neatly, in a timed fashion.

You know, much like most modern RPGs do with damage numbers?

...

...not that there's a battle system in need or anything.

...

...so, anyone want to code this up for me?

Posted on 2005-07-03 06:38:03

Ness

I'm on it

/me goes to hack appart the source to 'The Quest For Milk ex+alpha cow tipping edition'.

Edit:
[Link]
There are 2 system.vc's in there. One hogs the cycles while doing the digits, the other pretends to be threaded so you can have up to 100 bouncy strings on screen at once.

Edit 2:
I forgot one line, so the timing will probably be off.

In nicebounce.vc change the function ProcessBouncy() to
void ProcessBouncy(int i)
{
if(timer-pBouncyDigits[i].stamp > pBouncyDigits[i].delay)
{
pBouncyDigits[i].frame++;
//START NEW LINE
pBouncyDigits[i].stamp = timer;
//END NEW LINE
if(pBouncyDigits[i].frame >= NUM_BOUNCY)
KillBouncy(i);
}
}

Posted on 2005-07-03 08:38:34 (last edited on 2005-07-03 13:59:46)

torin

Incidentally, Ness's fake threading is a perfect example of the kind of the thing that scripting system I made (a looong time ago) was intended for.



script[256] wait(int delay) // This was going to be a library function.
{
int stamp = timer;
while (timer - stamp < delay) suspend;
}

script[100] BouncyDigit(int x, int y, string fontname, string text, int delay)
{
int font = LoadFont(fontname);
int frame = 0;

on retrace {
PrintString(x, y-nBouncy[frame], screen, font, text);
}

while(frame < NUM_BOUNCY) {
wait(delay);
frame++;

}
}

script BouncySpawner(int delay)
{
while(1) {
wait(delay);
fork BouncyDigit(Random(0, 320), Random(0, 240), 'fred.png', 'Bounce', Random(2, 4));
}
}

void autoexec()
{
ScriptInit();
BouncySpawner(25);
while(1)
{
//black out the screen
RectFill(0, 0, 320, 240, RGB(0, 0, 0), screen);

render();
ScriptTick();
ScriptRetrace();
showpage();
}
}



I'm pretty sure the above actually would have worked with the system I had (maybe I've got some syntax wrong). Pretty cool, eh?

Of course it's useless to Grue now because I never released it. I wanted to make a good demo and never found time :p. But now I'm working a new version, which should be much faster and nicer (the old one was too slow).

... Anyway, just thought I'd pop my head in and say hi. Carry on.

Posted on 2005-07-03 11:58:17

mcgrue

Well, I've custom crafted a whole render stack engine thingy (with state-driven sprites that gayo helped implement, using the animation lib vec coded waaay back. Reuse of code yay) that I'll be popping the render call into one of the custom stack wrappers for (Callfunc ftw!)

Thanks Ness! I'm in the process of modding it slighty to work in this! A Credit for you!

Posted on 2005-07-03 15:21:45

Gayo

I used an excessively complicated gravity-based bouncy thing for the LBS. It's probably best if it stays where it is.

Posted on 2005-07-03 20:50:31

mcgrue

I am currently debating adding fixed-point precision into this so we can speed the bounce up.

Posted on 2005-07-04 19:35:11

Ness

Well I did some tweaking, by removing frames from InitBouncy() I got it to move a bit faster and keep the same basic effect.


void InitBouncy()
{
nBouncy[0] = 3;
nBouncy[1] = 6;
nBouncy[2] = 9;
nBouncy[3] = 12;
nBouncy[4] = 14;
nBouncy[5] = 15;
nBouncy[6] = 16;
nBouncy[7] = 15;
nBouncy[8] = 15;
nBouncy[9] = 14;
nBouncy[10] = 14;
nBouncy[11] = 12;
nBouncy[12] = 9;
nBouncy[13] = 6;
nBouncy[14] = 3;
nBouncy[15] = 1;
nBouncy[16] = 2;
nBouncy[17] = 3;
nBouncy[18] = 2;
nBouncy[19] = 1;
}


And up at the top of the file
#define NUM_BOUNCY 20


Also lowering the delay (last int passed to CreateBouncy()) has an effect.

Fixed point might be a bit overkill, but then again I've never done FP math in VERGE so I'm probably not the best judge.

Posted on 2005-07-04 20:16:40

Overkill

Fixed point != a bit of me. Yes, yes, I know you were using overkill in its proper context, but... damn, fun ruiner. ;__;

On topic, neat work with the bouncy digits and all. I may have to draw some inspiration from your code.

Posted on 2005-07-05 21:20:02

mcgrue

I couldn't resist and modded the whole lib to be pretty easy to drop into anywhere and use. And I did the fixed pointedness to speed things up.

I'll share the results in a few days.

Posted on 2005-07-05 23:58:20

rpgking

Check out Zeromus' article on the subject:

http://www.verge-rpg.com/~zeromus/bouncy_digits.html

You can easily do an FF4 or FF5 style bounce effect(FF5 style is where each individual digit bounces to form a wavelike bounce effect, whereas FF4 style is just a traditional bounce).

I implemented this in Verge2 and it ran very fast and smoothly. I'm sure it'll run just as well or better in Verge3. He's got all the code there in his article, and there is hardly any code at all(showing how simple and efficient it is).

Posted on 2005-07-06 02:25:15

mcgrue

I actually augmented Ness's lib to do this, btw.

Posted on 2005-07-06 02:37:03

rpgking

Ah, cool. It should be looking really neat then. And here I thought I was the only one who ever read that article(I stumbled upon it one day after getting bored and looking at everyone's personal verge-rpg.com page) ;)

Posted on 2005-07-06 02:41:13

Rysen

Quote:Originally posted by rpgking

Ah, cool. It should be looking really neat then. And here I thought I was the only one who ever read that article(I stumbled upon it one day after getting bored and looking at everyone's personal verge-rpg.com page) ;)


Actually I used that article for the bouncy digits in Amethyst's battle system. ^_^

Posted on 2005-07-06 03:30:20


Displaying 1-13 of 13 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.