Page 1 of 1
Displaying something like a life guage on Dreamcast VMU
Posted: Mon Jul 26, 2004 12:45 pm
by Falco Girgis
Lord. This is REALLY going to be a pain. You guys all know that in a shooter game you need to display stuff like: life, ammo, frags, etc. Well I decided that I'd give the option to display that junk on TV, VMU, or both. I'm having no problem with TV, but the VMU....
First off, here is what it'll look like on the VMU:
Do you notice the health meter and junk? I need the health and jet meter to go down appropriately and numbers to display how much ammo and how many frags you have.
The thing that makes this so hard is, here is the source:
Code: Select all
static const char death_vmu[] = {
".+++++++++..++++++++++++++++++++++++++++++++++++"
".+++++.++.++.+++++++++++++++++++++++++++++++++++"
".++++++++.+++..+++....................++++++++++"
".+++++.++.++.++.++....................++++++++++"
".+++++.+...+....++....................++++++++++"
".+++++.++.++.+++++....................++++++++++"
".....+.++.+++...++....................++++++++++"
"++++++++++++++++++++++++++++++++++++++++++++++++"
".....++++++++++++++++++++++++...++++++++++++++++"
".+++++++++++++++++++++++++++.+++.+++++++++++++++"
".+++++++++++++++++++++..++++.+++.+++++++++++++++"
"...+.+..+++..++++..++.++++++.+++.+++++++++++++++"
".+++..++.+.++.++.++.++..++++.+++.+++++++++++++++"
".+++.+++++.++.++.++.++++.+++.+++.+++++++++++++++"
".+++.++++++..+.++...++..+++++...++++++++++++++++"
"+++++++++++++++++++.++++++++++++++++++++++++++++"
"+++.+++++++++++++++.++++++++++++++++++++++++++++"
"++.+.++++++++++++..+++++++++++++++++++++++++++++"
"++.+.+++++++++++++++++++++++++++++++++++++++++++"
"+.+++.++.+.+.++.+.+.+++..+++++..+..+++++++++++++"
"+.....++..+.+.+..+.+.+.++.+++.++.++.++++++++++++"
".+++++.+.++.+.+.++.+.+.++.+++.++.++.++++++++++++"
".+++++.+.++.+.+.++.+.++..+++++..+..+++++++++++++"
"++++++++++++++++++++++++++++++++++++++++++++++++"
"++.....+++++++++++++++++++++++++++++++++++++++++"
"++++.+++++++++++++++++++++++++++++++++++++++++++"
"++++.++..+++.+++++....................++++++++++"
"++++.+.++.+...++++....................++++++++++"
"++++.+....++.+++++....................++++++++++"
".+++.+.+++++.+.+++....................++++++++++"
"+...+++...+++.++++....................++++++++++"
"++++++++++++++++++++++++++++++++++++++++++++++++"
};
That stores the image above as a char array. (48x32 )
Do you see where that would be hard? Would I not have to make a whole other image for every freaking combination of stats? Do you have any ideas what to do? So far I've had great success with the VMU and it is so convenient and great that I really want this to be a part of the game.
Any help would be appreciated a HELL OF ALOT.
Posted: Mon Jul 26, 2004 1:23 pm
by Guest
Hmmm...can you put IF statments everywhere? If your life is whatever, draw whatever as the line. Or...maybe use arrays for every '.' or '+', and whenever your health decreases, change a dot to a plus.
Blitz example:
Code: Select all
Dim PlussesDots
Global plus = 1
Global rowX=0
Global columY= 0
If health$ = "fine" then
For row = 0 to 31
for colums = 0 to 31
PlussesDots(rows,colums,plus) = findchar$(plus)
Next
Next
Endif
If health = "-1" then
PlussesDots(rowx+25,colum+25,0)
Endif
Function findchar$(i)
If i = 0 then
return "."
Elseif i >= 1 then
return "+"
Endif
End function
See? Each thingy in the erray has a variable: plus, when it's 0, it becomes a little dot, when it's 1, it becomes a +. I hope i did that stuff up there correctly, but oh well, that was just an example, you couldn't use it anyway, you use c++. I hope that helps, but I doubt it. x.x If you find a solution, tell me.
Posted: Mon Jul 26, 2004 1:26 pm
by MarauderIIC
Display your life gauge and stuff the same way you display people so that you can display it over the background as two images - the word "life" and then the solid black bar. When a player gets hit, shrink its x-dimension.
Edit: But apparently I'm looking at this in a totally different fashion. :) I'm thinking of an image essentially displayed on a box that is totally separate from everything else. Perhaps the problem stems from the fact that I haven't done any console programming and don't know what a VMU is or stands for.
Posted: Tue Jul 27, 2004 9:50 pm
by Guest
Edit: But apparently I'm looking at this in a totally different fashion.
I'm thinking of an image essentially displayed on a box that is totally separate from everything else. Perhaps the problem stems from the fact that I haven't done any console programming and don't know what a VMU is or stands for.
LOL, VMU stands for visual memory unit, it's a memory card with a tiny little screen on it, and he's trying to make it display you're health on it while it's hooked up to your controller. The code for this would be displaying a "." for each blank pixel and a "+" for each light up one. But rather than rewriting the whole 40x32 (or whatever the VMU is) screen with dots and plusses, how'd he make it change whenever his health does?
X.X, you would not have posted that edit if you didn't already know what I just said, right?
Posted: Fri Jul 30, 2004 5:19 pm
by MarauderIIC
Actually, I sat on the page and didn't hit post for a bit. There wasn't a reply when I started writing. And no, I didn't know what a VMU was, but I talked to Sonic and you finished it off, thanks.
Your post, however, gave me an idea: you could make an array of an array of characters (which you essentially already have anyway) and just replace the part you want.
..Dang, I'm no good with handling C-style strings anymore. Will have to use both C++ and C-style...
Code: Select all
#include <string> //C++-style strings
#include <cstring> //C-style string functions
using namespace std;
/*...*/
char* wholeDisplay[] = { /* all your stuff */ };
string strLifeRow; //Holds our life meter display data.
int i;
unsigned int lifeRowLength;
//Create the "I-Have-Life" part of the gauge.
strLifeRow = "";
//vvv I think there's a built in string function that'll do this vvv
for (i = 0;i < life;++i) {
strLifeRow += "+";
}
//Fill with "Dont-Display-Me" after the life gauge.
lifeRowLength = strLifeRow.length();
for (i = lifeRowLength;i < strlen(wholeDisplay[/*correct row number*/];++i) {
strLifeRow += ".";
}
//Move it over to the array that stores the stuff we're gonna display.
strcpy(wholeDisplay[/*correct row number*/], strLifeRow.c_str());
Hopefully that'll work.
Note this is pretty hardcoded, esp. the "correct row number" parts.
If you want your gauge to be thicker just copy it to more than one row.
I had a thing where I dynamically allocated a new array but I figured that was unnecessary since you needed it all in the wholeDisplay anyway.
EDIT: You'll want a multiplier to make the maximum length of the life bar be limited to 32 units or whatever. Don't forget if you want a result when you divide you should convert them to floats. Something like:
Code: Select all
float multiplier = 32.0/(float)maxLife;
int realLife = (life * multiplier) + 0.5;
//Adding 0.5 and converting to int (which cuts off everything
//after the decimal) effectively rounds to the nearest whole number.
if (realLife > 32)
realLife = 32;
{ End edit }
..."Ohhh, did I winnnn?" - Peach, SSBM
Posted: Fri Jul 30, 2004 7:03 pm
by Wutai
Although someone has probably already said this, and I just couldn't understand them, I will give my idea.
My idea is to have the life, ammo, etc all be separate pictures, which in my mind seems to be better than having to make all those combinations.
Posted: Fri Jul 30, 2004 11:13 pm
by Falco Girgis
Lemme first say that I read Maruader's post and was intrigued. I have yet to study its full detail. This is as a reply to Wutai.
Wutai:
I don't think you realize what this is we're dealing with. A primitive 8-bit processer of a memory card. You can't load images to the thing. You can't really do anything but display stuff without hard core assembly-ing. A 48x32 pixel screen memory card capable of showing a black or white dot.
Heh, don't get it confused with a computer! :spin:
Posted: Sat Jul 31, 2004 6:27 pm
by Wutai
You wouldn't have to use pictures, you could use text instead. (Which is what I meant in the first place)
Posted: Sun Aug 01, 2004 8:47 pm
by Falco Girgis
... Just forget it. You obviously don't understand--the whole point was that it is impossible to do with multiple images. It seems MarauderIIC has figured out a way, but I have to go to the drive-in movies right now. Check it out when I get home.
Posted: Mon Aug 02, 2004 3:54 pm
by MarauderIIC
The thing is there's no way to tell it to display a picture. You have to tell it, "I want dot (10,15) on. I want dot (11, 15) on. I want dot (12, 15) on. I want dot (13, 15) off." and so on.
Edit: Super Sonic, looking at your original code, it seems as though I got my +'s and .'s reversed :)
Edit2: Ah, if you want to have the life bar start after the word "life," tweak it a bit and have it copy the first specified # of chars over and then add on the stuff you need. Don't forget to have i (or whatever my variable name is) start at the # of chars you copied over instead of 0. As for you and your frags, that'll be trickier, I think. You might hack it and use define a "1" and a "2" and so on in arrays that are say 5x10 or something (one array for each number) and then replace the 5x10 square in the wholeDisplay by copying one row at a time over your old frag number. Multiple digits might be a problem. Again, since it's so primitive you might just hack it again -- allocate space for two digits and if they have ninety nine frags then display 00 for 100, 01 for 101, etc, or just have it not increment or display a >99 or something. "Hack it" as opposed to programming yourself some sort of real font/display system.
Edit3: You might consider an array of strings to avoid memory problems. Although if it goes over the maximum size of the VMU who knows what'll happen, but at least you won't have screwed up some memory you weren't supposed to. And you can use "string.find()" as well.