Radar screen blips for npc and player characters

Started by jamesreg, Wed 02/06/2010 16:33:45

Previous topic - Next topic

jamesreg

Ok,

I have the following things in my room.

1) Large scrollable space background
2) 25 seperate hotspots which in total cover the scrollable background
3) 1 large region which covers the entire scrollable background.
4) a radar gui at corner of screen (which has 25 invisible buttons representing the 25 hotspots above)

now I have two characters a player character which is set to a crosshairs cursor and looks like the viewscreen of a ship moving
then I have a npc character which is the enemy ship moving around the screen at random

this is the script i used to move the NPC around


bool found;
 int x,y;
 if (!cGronShip.Moving) {
   while(!found) {
     x = Random(Room.Width);
     y = Random(Room.Height);
     if (Region.GetAtRoomXY(x, y) == region[1]) found = true;
   }
   cGronShip.Walk(x, y);

it works the npc moves all over the place like I wanted

I have the hotspots set up so that when the player character (the crosshairs of the viewscreen) move over the hotspot it changed the correct button image on the radar gui to make it look like your showing the player characters ship on the radar

this also works perfectly

the problem I am having is I guess step on hotspot or walk on hotspot codes do not work for npc characters that are moving over those hotspots

so How do I get the hotspots to understand when my NPC ship is over those hotspots so I can get them to appear on the radar too.

basicaly I need to know how to get the npc to appear on my radar screen too

the code im doing for the radar for the player character is

function hradar1_WalkOn()
{
if (player==cEnterprise {

  Radar1.NormalGraphic=2142;
}
}

but no matter what i do i cant get this to work for npc characters that move onto that hotspot

RickJ

Just put some code in the room's repeatedly execute function that looks up each character's x,y position and translates that to a position on the radar GUI.

jamesreg

OK so say my hotspot area is 800*600 over 25 seperate locations for a total of a 5000*5000 background

I would have to basicaly figure out the starting coordinates and ending coordinates for each of those locations
and tell it that if its within that area to change my graphic on my radar screen


Khris

No, just divide cGronShip.x by 800 and cGronShip.y by 600.
This will give you an x and y in the range of 0-4 which directly translates to the GUI button.
If the buttons are numbered like this:
 0  1  2  3  4
 5  6  7  8  9
 10 11 12 ...
then the button's ID is y*5 + x.

Note that you can greatly refine the radar display by using a single button that's drawn dynamically. You don't need hotspots or multiple buttons at all, just a factor to translate room coordinates to GUI coordinates.

Also, what's the point of the region? Right now, it covers the whole background, thus the while loop will hit a spot on the first try.

SMF spam blocked by CleanTalk