2 registered members (RealSerious3D, rvl),
1,187
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Attaching a target system to my minimap
[Re: Reconnoiter]
#425612
07/09/13 11:34
07/09/13 11:34
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
Serious User
|
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
First thing first, I do not create here the minimap through a 'view' since it drains some fps in my map, but it should not be too much of a difference. We begin with the needed panels for the landmarks and an arrow for the player (what you already have but oh well):
PANEL* Minimap_pan =
{
pos_x = 0;
pos_y = 0;
bmap = "InterfaceMinimap.png";
layer = 2;
flags = SHOW | OUTLINE;
}
// this icon = 16 by 16, placing it at 56 allows it to appear //exactly at the middle of the minimap if your minimap is 128*128
//, otherwise change the pos_x and pos_y here
PANEL* Minimap_player_pan =
{
pos_x = 56;
pos_y = 56;
bmap = "InterfaceMinimapPlayer.bmp";
layer = 4;
flags = SHOW | OVERLAY;
center_x = 8; // set the rotation center at the panel center
center_y = 8;
}
// same here, icon of 16 by 16
PANEL* Minimap_cave_pan =
{
pos_x = 56;
pos_y = 0;
bmap = "InterfaceMinimapCave.png";
layer = 3;
flags = SHOW | OVERLAY;
}
In your case you can leave out the Minimap_pan since you use a 'view' for this. Also check if the layers of panels are good for your map. The layers of the panels should be higher than your 'view'. I use a cave here as an example for the landmarks. Now to your question. You can use VEC_DIST to check if the distance between your player vector and the landmark vector is big enough to position the icon on the border. Else it is placed somewhere within the minimap / 'view'. I take it that the minimap itself does not rotate when the player rotates right? In that case you can do the following (otherwise it gets more complicated). For this example the landmark is in the center north of the map/level. Put the beneath in a while loop but create a vector first (here vector_landmarkCave) that has the position of the landmark in your map/level.
if (player) {
distance = vec_dist(player.x,vector_landmarkCave.x); // calculate distance of player and cave entities
if (distance > 500) { //change this number according to the size and height of your 'view'
Minimap_cave_pan.pos_x = 56; // cave icon here = 16 by 16 pixels, now it is centered on x axis of the minimap
Minimap_cave_pan.pos_y = 0;} // and on the border of the y_axis of the minimap
else {
//check if the x axis in your map is the same line as the pos_x
//on your minimap, otherwise do vector_landmarkCave.y for pos_x and vector_landmarkCave.x for pos_y
Minimap_cave_pan.pos_x = vector_landmarkCave.x / 40; //play a bit with the number 40
Minimap_cave_pan.pos_y = vector_landmarkCave.y / 40;} //play a bit with the number 40
}
Play a bit with the pos_x and pos_y of the Minimap_cave_pan in the else. Add e.g. +16 or -8 to it if needed in your map to get the positions right. Hope this was clear, if not just fire away. ps: this might not be the best way but it does work (atleast here it does :P)
Last edited by Reconnoiter; 07/09/13 11:36.
|
|
|
Re: Attaching a target system to my minimap
[Re: Reconnoiter]
#425626
07/09/13 13:34
07/09/13 13:34
|
Joined: Jan 2013
Posts: 106 Only in your imagination!
The_KING
OP
Member
|
OP
Member
Joined: Jan 2013
Posts: 106
Only in your imagination!
|
@Reconnoiter Thank you for helping ,but this isn't what I need.... The only thing in your method that doesn't work as I want is that the target icon is always on the center north when the player is faraway from the target ,even when the view itself rotates with the player (I haven't tried that ,but I am sure about it).... Anyway, thank you for your time
Last edited by The_KING; 07/09/13 13:36.
|
|
|
Re: Attaching a target system to my minimap
[Re: The_KING]
#425633
07/09/13 14:28
07/09/13 14:28
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
Serious User
|
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Oh yeah I get what you mean but you only have to change the following lines for this:
Minimap_cave_pan.pos_x = 56;
Minimap_cave_pan.pos_y = 0;
to something more complicated. I quess you could adds some If's before this that check if the x of vector player is bigger or smaller than the x of vector vector_landmarkCave, and that check if the y of vector player is bigger or smaller than the y of vector vector_landmarkCave. This way you can get a basic idea which direction the landmark is from the player. Than place the icon landmark panel according to these results on the minimap. E.g. like this:
If (player.x > vector_landmarkCave.x) Minimap_cave_pan.pos_x = 0;
If (player.x < vector_landmarkCave.x) Minimap_cave_pan.pos_x = 112;
If (player.y > vector_landmarkCave.y) Minimap_cave_pan.pos_y = 0;
If (player.y < vector_landmarkCave.y) Minimap_cave_pan.pos_y = 112;
Anyway you're welcome.
Last edited by Reconnoiter; 07/09/13 14:30.
|
|
|
Re: Attaching a target system to my minimap
[Re: The_KING]
#425640
07/09/13 15:06
07/09/13 15:06
|
Joined: Jan 2013
Posts: 106 Only in your imagination!
The_KING
OP
Member
|
OP
Member
Joined: Jan 2013
Posts: 106
Only in your imagination!
|
Thanks. I made a method by myself using vec_to_screen. See it below: First, I defined a vector "dest_close" that returns the position of the destination and will be converted into a XY screen position. Look: I put the following in a while loop:
vec_set(dest_close.x,destination.x);
vec_to_screen(dest_close.x,minimap_view);
minimap_target_pan.pos_x = dest_close.x;
minimap_target_pan.pos_y = dest_close.y;
minimap_target_pan.pos_x = clamp(minimap_target_pan.pos_x,x_min,x_max);
minimap_target_pan.pos_y = clamp(minimap_target_pan.pos_y,y_min,y_max);
And that method works perfectly for me ![laugh laugh](/ubb7/images/graemlins/default_dark/laugh.gif) Thank you for your time...
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|