About Store Forum Documentation Contact



Post Reply 
How create a new Point in the Minimap
Author Message
djpercy Offline
Member

Post: #16
RE: How create a new Point in the Minimap
Hi,

@Both
many thanks for your patience with me.

that was the missing piece of Puzzel (chr.pos().xz()wink.
It work, now i must displayed on the right position on the screen.

Greeting Denis
10-31-2010 04:45 PM
Find all posts by this user Quote this message in a reply
djpercy Offline
Member

Post: #17
RE: How create a new Point in the Minimap
Hi,

how can i check is my point in the Minmap rectangle. Has Esenthel a function for this?

Greeting Denis
10-31-2010 06:46 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #18
RE: How create a new Point in the Minimap
something similar to:
Dist(pos_2d, map_center) < MapRadius
10-31-2010 06:56 PM
Find all posts by this user Quote this message in a reply
djpercy Offline
Member

Post: #19
RE: How create a new Point in the Minimap
Hi,

thank you, it works but the Minmap ist a Mask a circle.
also a function for it?

Grettings Denis
10-31-2010 07:21 PM
Find all posts by this user Quote this message in a reply
djpercy Offline
Member

Post: #20
RE: How create a new Point in the Minimap
Hi,

i have the solution, it works fine.
how many thanks for your Help.

Greeting Denis
10-31-2010 09:31 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #21
RE: How create a new Point in the Minimap
Maybe you can post you're solution as well... there are more people that can make use of it... after all this community that shares their ideas and skills with each other.

There is always evil somewhere, you just have to look for it properly.
10-31-2010 10:01 PM
Visit this user's website Find all posts by this user Quote this message in a reply
djpercy Offline
Member

Post: #22
RE: How create a new Point in the Minimap
hi,

i can do this, but my minimap is not finished.
the next step is how can I rotate my Minimap?
Can i the Minimap put on of a GUI?
and so on....

I will do post my completed code her,
for a better work with the engine.

Gretting Denis
10-31-2010 11:13 PM
Find all posts by this user Quote this message in a reply
djpercy Offline
Member

Post: #23
RE: How create a new Point in the Minimap
Hi,

I'am again smile

I can nothing found to rotate my Minmap.
How can i Rotate the minimap or the Image.

what makes image.drawRotate or drawCenter?

Greeting Denis
11-01-2010 07:49 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #24
RE: How create a new Point in the Minimap
hi, you can use drawRotate preceeded by D.clip (this will allow you to draw rotated images in rectangular mini map preview)
but you can't mix rotate with masking (circular mini map)
11-01-2010 09:31 PM
Find all posts by this user Quote this message in a reply
djpercy Offline
Member

Post: #25
RE: How create a new Point in the Minimap
Hi,

what should i do my minimap has a mask :o
What is my way out?
Can i create a Minmap with a camera and a mask on it?
Is it possibility work with layers for the camera?

Greeting Denis
11-01-2010 09:55 PM
Find all posts by this user Quote this message in a reply
djpercy Offline
Member

Post: #26
RE: How create a new Point in the Minimap
Hi,

have someone a work around for me?
or gives it a ready solution from someone?

Greeting Denis
11-02-2010 06:49 PM
Find all posts by this user Quote this message in a reply
yvanvds Offline
Member

Post: #27
RE: How create a new Point in the Minimap
I was looking for a solution for this too. The hints were not exactly clear to me though. (Perhaps I should have taken math classes in school :-)

I came up with the following code. I don't assume it's the best method to do this, but at least I could make it work this way. The peer dot calculation is in the second part of the draw function. After that, an arrow is also drawn in the center to see which way the player is looking. rect is the rectangle used to display the minimap on screen. mapDot is a little image that is loaded for every peer. In my game, every player has his own color, so you could leave out the part of coloring the dot if you want to.

PHP Code:
void cMiniMap::draw(EE::Vec2 &pos) {
    if (!
guiLoadedloadGui();
    if (
hidden) return;


    if ((*
minusButton)()) {
        
radius *= Time.d();
        if (
radius 150radius 150;
    }
    if ((*
plusButton)()) {
        
radius /= Time.d();
        if (
radius 10radius 10;
    }

    
_time32(&time);
    
_localtime32_s(&newtime, &time);
    
EE::Str t newtime.tm_hour ":";
    if (
newtime.tm_min 10) {
        
+= "0";
    }
    
+= newtime.tm_min;
    
timeText->set(t);

    
Vec2    worldMin pos radius,
                
worldMax pos radius;

    
Vec2    imageMin        Game::World.mini_map.worldToImage(worldMin),
                
imageMax        Game::World.mini_map.worldToImage(worldMax),
                
imageCenter Game::World.mini_map.worldToImage(pos            );

    
VecI2    imageMini        Floor(imageMin),
                
imageMaxi        Floor(imageMax);

    
Vec2    imageSize        rect.size() / (imageMax imageMin);

    
// iterate through all image maps to be displayed
    
for (Int y imageMini.y<= imageMaxi.yy++) {
        for (
Int x imageMini.x<= imageMaxi.xx++) {

            
// calculate screen position of the (x,y) image map
            
Vec2    imagePos rect.center() - imageCenter imageSize;
            
imagePos.+= imageSize.x;
            
imagePos.+= imageSize.y;

            
// prepare the screen rectangle of the (x, y) image map
            
Rect_LD map_image_rect(imagePosimageSize.ximageSize.y);
        
            
// draw image
            
Image &image Game::World.mini_map(VecI2(xy));
            if (
image.is()) {
                
image.drawMask(WHITEColor(0000), map_image_rect, *Images("gfx/mini map alpha.gfx"), rect);
            }
        }
    }
    
Flt angle 0.0;

    if (
Peers.elms()) {
        
Peers.lock();
        
// show other players
        
for (int x 0Peers.elms(); x++) {
            
Vec2 pos2d Peers.lockedData(x).pos().xz();
            
// only draw if within range
            
if (Dist(pospos2d) < (radius 0.8)) {
                
// set overlay color
                
Color add Peers.lockedData(x).color;
                
add.0;

                
// maximum distance on screen in pixels
                
VecI2 lu D.screenToPixel(rect.lu());
                
VecI2 ru D.screenToPixel(rect.ru());
                
VecI2 ld D.screenToPixel(rect.ld());
                
                
VecI2 maxDist;
                
maxDist.Abs(ru.lu.x) * 0.5;
                
maxDist.Abs(ld.lu.y) * 0.5;

                
// peer position towards player
                
Vec2 peerPos pos2d pos;

                
// normalize with radius and maximum screen distance
                
peerPos /= radius;
                
peerPos *= maxDist;

                
// reverse y position for screen coördinates
                
peerPos.= -peerPos.y;

                
// get center of rectangle in pixels
                
VecI2 center;
                
center D.screenToPixel(rect.center());
                
                
// offset to minimap center
                
peerPos += center;

                
// convert back to screen position format
                
Vec2 p2 D.pixelToScreen(peerPos);
                
Peers.lockedData(x).mapDot.drawCenter(Peers.lockedData(x).coloraddp2.xp2.y0.030.03);
            }
        }
        
Peers.unlock();
    }

    if (
Players.elms()) {
        
// show player direction on top
        
angle Players[0].angle.x;
        
pointer.drawRotate(rect.center(), 0.05 ,0.05angle);
    }

(This post was last modified: 04-30-2011 06:54 PM by yvanvds.)
04-30-2011 06:09 PM
Find all posts by this user Quote this message in a reply
Post Reply