Hardness Maps


Goity

VIP Sleaze
Joined
Jun 22, 2004
Messages
5,598
Location
Isle of Ewe
How the hell do you do these in fenix? All the guides I find use Div palletes, therefore I cannot find out how they work!
 
devlkore posted on May 24 2005 at 11:45 PM said:
Can't you use the same palettes in Fenix?

If you're using 16bit graphics, try 8.
well I need to know the colour number of the colous I'm using, and I have no idea how!
 
Last edited by a moderator:
Right then.. This is the main thing in Fenix which still really confuses me... How the hell do I do hardness maps?
 
I still don`t know. Didn`t use them yet.

Didn`t see Moogle around here for some time now, maybe you try pm`ing him. He knows the answer.
 
If you are using 8 bit you have to use this:

(map_get_pixel(file,graph,x,y)==palettecolornumber)

And if you use 16 bit:

(map_get_pixel(file,graph,x,y)==rgb(rrr,ggg,bbb))
 
16 bit should be semi-clear now, goity:

You just use as sprite and you have it, lets say white, so the r,g,b value is 255,255,255. So you just put in your code:

if(map_get_pixel(*)==rgb(255,255,255)do_something;end;

*I`m not sure about this, has it to be about the sprite or the object touching it?

Please correct me if I`m wrong with something!

8bit should work the same but I have no clue on how to get the numbers of certain color in a pelatte. When I extract the palette out of a 8bit fpg, I can`t find a program to open it (tried Irfanview)
 
I'm no coder or anything... but maybe... just maybe, if you need a number, the number is a hexadecimal number? it's the same thing, 0 - 255, but after a certain number, letters are used to represent the numbers. Unless you know for sure that the hexadecimal numbers are what you do not need, try searching for hexadecimal color codes, insert one, and give it a whirl. If I'm totally wrong, then sorry... just trying to help if i can.

And if my description of hexadecimals sucked... do a google search.
 
Didn`t see Moogle around here for some time now, maybe you try pm`ing him. He knows the answer.

I'm still reading everything, it's just that more questions get good answers so I'm not replying as often anymore.

let's see, hardness maps. :)

First of all, don't use 16 bit graphics for hardness maps, there is no guarantee you get your colours back the way you write them. See, in the rgb command there are 3 values(r,g and B) taking 1 byte each(0-255). Normally you would then take 3 bytes per pixel(24 bits), but since we're talking 16 bit graphics in Fenix, it needs to convert those 8 bits per colour you would NEED, to the 5 you actually HAVE. The other way around too, Fenix converts them from 5 to 8 bits when you call map_get_pixel. So for some values for r,g or b this means that when you write them you get different values back. In conclusion, just don't use 16 bit graphics for hardness maps.

So let's assume you chose 8 bit graphics(1 bit is possible too) for your hardness map. First you need to ask yourself, what is the problem I have. A typical problem that can be solved with hardness maps is the following. Imagine you have a big map(a level in this case), where some regions have different properties than others. Here, you want a character to be able to walk on grass, but not through walls. Now if you would want to find out where he is walking and if he is allowed to do so you COULD try to grab the big map and try to figure out if there is green(implying grass) or brown(for wall) where mr. main character is walking. This could however get tricky when there are other green things he isn't supposed to walk through, and surely costs a decent amount of processing power to determine every frame.

This is where hardness maps come in. Wouldn't it be much easier to have a separate map, with which the only thing you can do is determine whether or not you can walk on that place in the grass/wall/etcetera level map. Instead of using all sorts of colours for eye-candy you would want in the level map the player sees, in that separate map you would only use 2 colours, green and brown(normally you just use colour 1 and 0, or 234 and 163), making the life of mr main character one hell of a lot easier. Just check for green(or the number you assigned 'walkable' to), ok, he can walk, or otherwise conclude that there is no walking allowed.

And that is the basic principle for hardness maps: You have a complicated situation and you solve it by creating a new map with only the specific property filled in you want to know. In this example that may be whether or not a spot in the level is 'walkable', but the idea is extendable to loads of things, checking if a car is still on the racetrack, in the grass or maybe parked against that big wall over there. Or maybe in Kururin if you can go certain places with that stick.

Of course, since you have 255 colours(read, numbers) available per pixel, you could not only specify if there is grass or wall, but if you'd want to you could have colours(numbers) for beach, water, level portals, and who knows what else. Another thing usually done is use a smaller map than the original. Saves space in ram, and if for instance you would make the hardness map a factor 2 smaller one pixel on the hardness map would represent 4(2x2) pixels on the level map, which is often not much of a problem. Of course whether or not that is possible depends on what you are using the hardness map for, but if for instance you are using tiles you could use 1 pixel for every tile.

Hope that clears some things up :)
 
Thanks Moogle, it do. Now I got it working, but my Character gets stuck when it collides with one of the areas.
Any ideas?

Code:
Program RPG;
GLOBAL   
FPGGAME;
PRIVATE
BEGIN
Set_mode(m320x240);   
FPGGAME=LOAD_FPG("RPG.fpg");
Chara(160,120);   
PUT_SCREEN(FPGGAME,2);
Loop
FRAME;
END
END

PROCESS Chara(x,y);          
BEGIN  
Graph=3;
LOOP
If(KEY(_LEFT) AND X>10 AND NOT (map_get_pixel(FPGGAME,1,x/2,y/2)==0))
X=X-4;
END    
If(Key(_Up) AND Y>10 AND NOT (map_get_pixel(FPGGAME,1,x/2,y/2)==0))
Y=Y-4;
END
If(KEY(_DOWN) AND Y<230 AND NOT (map_get_pixel(FPGGAME,1,x/2,y/2)==0))
Y=Y+4; 
END
If(KEY(_RIGHT) AND X<310 AND NOT (map_get_pixel(FPGGAME,1,x/2,y/2)==0))
X=X+4;
END 
FRAME;
END
END

~Goity
 
Code:
Program RPG;
GLOBAL  
FPGGAME;
PRIVATE
BEGIN
Set_mode(m320x240);  
FPGGAME=LOAD_FPG("RPG.fpg");
Chara(160,120);  
PUT_SCREEN(FPGGAME,2);
Loop
FRAME;
END
END

PROCESS Chara(x,y);          
BEGIN  
Graph=3;
LOOP
If(KEY(_LEFT) AND X>10 AND NOT (map_get_pixel(FPGGAME,1,(x-4)/2,y/2)==0))
X=X-4;
END    
If(Key(_Up) AND Y>10 AND NOT (map_get_pixel(FPGGAME,1,x/2,(y-4)/2)==0))
Y=Y-4;
END
If(KEY(_DOWN) AND Y<230 AND NOT (map_get_pixel(FPGGAME,1,x/2,(y+4)/2)==0))
Y=Y+4;
END
If(KEY(_RIGHT) AND X<310 AND NOT (map_get_pixel(FPGGAME,1,(x+4)/2,y/2)==0))
X=X+4;
END
FRAME;
END
END

Try it like this then. You were checking the hardness where you are, not where you are about to move.
 
Back
Top