Skip to main content
GameDev.net gamedev.net
🔒 Locked

Map Reveal

Started by Daboy Nov 24, 2001 at 9:59 PM 22 replies 1.1k views
Original Post
Daboy
Daboy
Hey, Im making a game where u have to move a player around....is there a way i can make everything black until he moves to that part of the map??? One more thing... How can i make it possible to have a bigger map than the screen..For Example if i have a map that is two screen fulls how do i make it so that when he moves to the edge it will show him the other part of the map?? One last thing. Lets say to win the mission u have to get to a certain point on the map. How can i make it so that when u stand on a certain place it ends the mission? Thx Edited by - daboy on November 24, 2001 11:40:56 PM
Jordan Weberwww.pheonixsoftware.com
Daboy
Daboy
Funny no not really

Ok update tho all i need to know is how i can make the program know if he is standing in a certain part of the map. Please help
Jordan Weberwww.pheonixsoftware.com
AdmiralBinary
AdmiralBinary
If you are using tiles, have a BOOL for each tile stating whether it''s visible or not. Then when you get to blitting that tile, if it''s visible, blit it - if not, well, you get the idea...

If you''re using pre-rendered backgrounds, then I''m sorry, can''t help ya there.

Check if the player is standing on a certain point of the map??? Excuse me, Daboy - are you a programmer? Or are you working with some game dev SDK?

---------------

I finally got it all together...
...and then forgot where I put it.
Sly
Sly
Take a look at Amit''s Game Programming Information. He has a whole load of articles on tile-based games.

Each map cell has a visibility value. If this value is zero, then the cell is invisible (black). The higher this value, the higher the visibility until it is fully visible. Say you allowed one bit per map cell. This would allow two values, zero and one. Zero is black and one is fully visible. When your character moves, every map cell within a specified radius around the character has its visibility value set to one. When drawing the map, only draw the tiles in map cells that have a visibility value greater than zero.

Steve ''Sly'' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
Kwizatz
Kwizatz
Starcraft IS a Tiled game(just not ISO), perhaps you meant real time strategy or RTS?, what you can do is draw your world (Slide, Stagered, Diamond, Rectangular, not tiled at all, you chose) then make a surface that has the same proportions of the world (or just the same props of your screen space or view space), fill it with black pixels, set a radio for your units, then you just set a circle around your units using that radio, which then you mask to the black surface as being a transparent pixel (DX, SDL and even GDI do this) then you just blit the blackness over your world, and keep track of what is visible and what not.
Kwizatz
Kwizatz
invisible? didnt you meant visible? all I am saing is make a big black "picture" that covers all your map, then "make holes" in it so you can see through in certain areas, you can make it so the hole stays even if the unit is not there anymore (just like in starcraft or age of empires) , but you make the holes based on the units position

or you can make it so the hole is around the unit, and everything becomes black again when the unit moves, you can combine the 2 so you have a Gray area you have visited , but have no unit there.

I dont know if I am getting you right, I understand you want to make something like what Starcraft does to keep the terrain hidden until explored right?

Sly
Sly
Calculate the distance between the two characters. If it is less than a specified value, then the bad guy is within range.

Good guy is at (x1,y1).
Bad guy is at (x2,y2).

Range := Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));

I think I got that right.

Steve ''Sly'' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
Kwizatz
Kwizatz
I really think you should get more in touch with some technical terminology, the Game Dictionary might be a good start.

if you use squares instead of lines that means you will be using a

rectangular tile map, you still need the same calculation, but you

give tile coordinates instead of the pixel coordinates, of course

you need a tile map, and a way to figure out where the tiles are,

and so on, if you are already working on this, chances are, you

have it, you just dont know you do

BASSOFeeSH
BASSOFeeSH
Have you coded anything for this game yet, or are you just a sock/troll?

Wait, wait, wait....who's Nambla Fett?

Edited by - bassofeesh on November 27, 2001 1:31:27 PM
-- What would Sweetness do?
BASSOFeeSH
BASSOFeeSH
I''m still not convinced, but...

How do you know where to draw your characters? Well...if you know where to draw them, then you know where they are. Compare that location to which ever location to want some event to occur at.

Wait, wait, wait....who''s Nambla Fett?
-- What would Sweetness do?
Kwizatz
Kwizatz
then you should put us in your credits!

ok, no tile map, hmmmm I see it as:

Use Sly's function, you will get an X,Y location right? now you have to construct a square based on that, a square is made out of 4 points, each point is an x,y coordinate, you have the pixel coordinate you got from the function, that will be the center, all you really need is 2 coodrinates, upper left and lower right right?!

  
UpperLeftX = X - 30;
UpperLeftY = Y - 30;
LowerRightX = X + 30;
LowerRightY = Y + 30;

//Voila! (UPX,UPY) (LRX,LRY) define your square, now check if an object is in that boundary


if (((Object.x>UpperLeftX)||(Object.x<LowerRightX)) &&
(((Object.y>UpperLeftY)||(Object.y<LowerRightY)))
{
Erase(Object); // if in C

Object.Erase(); //if in C++

}


Edited by - kwizatz on November 27, 2001 2:28:56 PM
Kwizatz
Kwizatz
he he he, my code might not be what you want (realized later), but might prove usefull, in any case it can help you if perhaps you use your character position as one corner of the squeare, and the result of the function as the oposite corner
Lumin
Lumin
uhm what I think he has done is that he has painted a map in paint or similar, used it as a background picture in a image box
then "animated" the two "characters" on this screen.

so over to your problem to be bale to make line of sight or perhaps a "range" for the weapon you could do something like this:

This will not always work but it should give you an idea.

const
//10 pixels or whatever type of measurement you use in your picture box this will probably need to be altered tho
Player1Range = 10;

begin
If not Player1X >= BadGuyX + Player1Range then begin;
If not Player1Y >= BadGuyY + Player1Range then begin;

Kill BadGuy;

end;
end;
end.

Put this in your main loop of the game (got none main loop? use a timer or equalent that activates on form laod)

at the moment this looks like something that can work in top of my brain .. written down in 30 sec so it might not work tho.
Kwizatz
Kwizatz
that sounds like pascal alright!
mine is C/C++, what are you using? the only confusing part in mine should be the IF Statement

but is easy to figure out, just change it so && means AND, and || means OR, parentesis separates expresions, as usual.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.