Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (RealSerious3D, rvl), 1,187 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
squik, AemStones, LucasJoshua, Baklazhan, Hanky27
19060 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Attaching a target system to my minimap #425589
07/08/13 20:22
07/08/13 20:22
Joined: Jan 2013
Posts: 106
Only in your imagination!
The_KING Offline OP
Member
The_KING  Offline OP
Member

Joined: Jan 2013
Posts: 106
Only in your imagination!
I read the minimap tutorial in the AUM (fixing a view above the player which looks downwards...etc.) ,but unfortunately it was for beginners only and didn't include a target system


I made that minimap in my project ,but I need to display ,for example, a small square that indicates the destination and appears on the minimap borders ,then once the player is close enough ,the square is no longer on the borders and approaches the player (a small arrow in the center of the minimap that changes its angle according to the player's pan angle) gradually ,like the one in GTA

I know this may seem difficult a little bit ,but I really need it as it will be very difficult for the player in my game to know where to go

Thank you for reading & any help will be appreciated

Re: Attaching a target system to my minimap [Re: The_KING] #425590
07/08/13 22:24
07/08/13 22:24
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
This should not be to difficult, I done something similar with my map except that it is not on the borders, but that is not too hard too add. I created icons for the landmarks and positioned them as on the minimap through pan.x and pan.y IIRC. The player is shown as a white arrow icon that rotates when the player rotates too. I made the whole minimap through icons and used a small terrain like image as background. It is kind of late here and I am not behind my laptop, tommorrow I can give you a more detailed and usefull description.

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 Offline
Serious User
Reconnoiter  Offline
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):

Code:
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.

Code:
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 Offline OP
Member
The_KING  Offline 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 laugh

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 Offline
Serious User
Reconnoiter  Offline
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:

Code:
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:

Code:
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 Offline OP
Member
The_KING  Offline 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:

Code:
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

Thank you for your time...

Re: Attaching a target system to my minimap [Re: The_KING] #425644
07/09/13 15:22
07/09/13 15:22
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
That is even beter, great you got it figured out.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1