Re: RPG-like damage counters
use a hidden counter for a enemy. Then use a string and always change the alterable string to String(counter).
I don't know the exact code for value-->sting, but it's in the expression editor.
Re: RPG-like damage counters
Its actually an often requested feature and I'm sure you could find a tutorial on this somewhere, but I'll tell you my own approach. If you're familiar with the CallBack controls of the text blitter object (I mean *very* familiar) it can do this exact effect, with a lot greater options than anything else.
You should have a large text blitter that overlaps the entire window and does not follow the frame. Somehow, you should instantiate multiple lines of text inside the blitter that would correspond to each object. This could prove very tricky to pull off. One possible way of doing this, if you don't care about the # of active objects, is to just create a new active object as a dummy unit offscreen to record the values of the line of text to be displayed.
So for example:
Code:
+On enemy being hit by sword"
=Create "dummytext" @ (-100,-100)
=Set value text_posx of "dummytext" to X("enemy")
=Set value text_posy of "dummytext" to Y("enemy")
=Set string damage of "dummytext" to str$(damage done by player)
=Set value duration of "dummytext" to 50
=Set value string_length of "dummytext" to len$(damage("dummytext")
Then, you should run very specific controls of the callback on the text blitter. The easiest way to do this is to load up the text of the text blitter with something like 100x repeating "A" characters ("AAAAAAAAAA....."). Doesn't actually matter which character. Remember to enable "On Character Callback".
Create a callback event, which should display the text for the damage. This is where it gets tricky. You need the game to display as many characters in a row for each damage as the length of the string, but the callback goes on a 'per character' basis. Since the order you draw the characters wouldn't matter, an interesting way to do this would be to keep a variable inside each "dummytext" object that keeps track of how many characters are left. On the character callback, you can position the X & Y of the string, as well as the transparency.
An implementation would look like this:
Code:
+Callback: On Begin
=Set flag 1 of "dummytext" to OFF
=Set flag 2 of "dummytext" to OFF
=Set value counter("dummytext") to 0 (zero)
+Callback: On character
=Callback-> Set destination X to -100
(this causes extra numbers to not be displayed)
Code:
+Callback: On character
+Flag 1 of "SomeOtherObjectInTheGame" is OFF
+Flag 2 of "dummytext" is OFF
+Pick a "dummytext" at random
=Set Flag 1 of "dummytext" to ON
=Set Flag 1 of "SomeOtherObjectInTheGame" to ON
(this picks a random dummy text that hasn't yet been drawn to the screen to be the one rendered- this way the game will only being drawing a single dummy at a time. The flags look like this:
Flag 1 of dummytext: "is this object drawing currently?"
Flag 2 of dummytext: "has this object already drawn?"
Flag 1 of someotherobject: "is a dummytext already drawing?")
Code:
+Callback: On Character
+Flag 1 of DummyText is ON
=Callback: Set Destination X to (text_posx(dummytext) + 8 * counter(dummytext))
=Callback: Set Destination Y to (text_posy(dummytext))
=Callback: Set Source X/Y to (stuff, see below)
=Callback: Set Transparency to (whatever, maybe duration * 2)
=Add 1 to value Counter("dummytext")
you need to somehow format the image on your text blitter so that you can easily retrieve the positions of the number images. An easy way to do this would be to put 0/1/2/3/4/5/6/7/8/9 all in one big horizontal strip. Then, you could retrieve the source positions like this:
Source X = val(damage(dummytext)) * 16
Source Y = 0
Code:
+Callback: On Character
+Flag 1 of "Dummytext" is ON
+Counter("dummytext") == string_length("dummytext")
=Set Flag 1 of Dummytext to OFF
=Set Flag 1 of SomeOtherObjectInTheGame to OFF
(this inactivates the dummy text once the full string has been read).
I really ought to have just made an example for you, which I probably could have done even faster than writing this out. But that would have been much to vulgar a display of power, my dear father karras.
Re: RPG-like damage counters
Speaking of vulgar displays of power, look what I cooked up in 5 minutes:
http://sites.google.com/site/claniraq/stuff/Counters.mfa?attredirects=0&d=1
Feel free to use that- it would require lots of editting to look better and work in scrolling applications and so on. There might be a few "off by one" errors, too.
EDIT: Oops I totally attached the wrong file
that other one was an engine for using text blitters for graphics
Re: RPG-like damage counters
O_O wow. Thanks for all the info and the example. This really shows off the text blitter object. This seems like an extremely overworked method for doing what you'd think is really simple though :\ not to mention having a giant TBO over my frame could possibly bog things down..but I'll see how it goes..would you have any simpler methods by chance? preferably using only one or two small objects?
On another note, so I don't make 2 posts..How do you get a dragging camera to not shake the player object when scrolling? I've tried multiple dragging methods but the player continues to shake..perhaps the camera's movement isn't the case?
Re: RPG-like damage counters
Well, I don't think there is a simple method, or someone would have found it by now. Its really been a tutorial/request I've seen a lot of, but I don't think i've seen too many people pulling it off. The TBO won't bog down your game- its an extremely optimized object, and at the most its probably going to be parsing 10 characters at a time.
In order to get it to work on a scrolling app, go into the "Destination X/Y" events of the callback, and subtract "X Left Frame" and "Y Top Frame" from each, respectively, and then go into the level editor and set the TBO to not follow the frame. Then it should work great! If you want to make it slightly more efficient, set the alterable text of the blitter to be just "AAAAAAAAAAAAAAA", that is, 15 characters long. Because I doubt you'll ever have more than 15 characters blitted to the screen at once, and even if you do, it will just cause them to flicker.
Re: RPG-like damage counters
That's some fantastic Text Blitter mad science there - thanks for putting all of that up! I would have suggested using the same object, but created/destroyed on an individual basis (as you have the advantage with Text Blitter of having alterable values...)
Re: RPG-like damage counters
I suppose yeah you could do that.
Create individual text blitters, treat them like active objects.
ofc that would be less efficient, and not give you as much control >.>
Re: RPG-like damage counters
So I spent some time messing with the above example, and got some pretty awesome results. This turned out to be exactly what I needed XD. No slowdown or anything either with the giant text blitter..even if there was I can add the scrolling stuff you mentioned and shrink it down to window size..Thanks for all the help!
Does anyone have any ideas about the dragging camera shaking my player when scrolling though? I can upload an example if needed..I'm sure someone's had this problem before o.o It may just be because my player object is kinda slow but I can't speed him up anymore :\
Re: RPG-like damage counters
Very nice example Pixelthief
I have never used the text blitter object as of yet, but now I'm going to!! :grin: Thanx