djpercy
Member
|
How create a new Point in the Minimap
Hello,
how create a new point in the minimap for all the NPC on my world map?
I have create a function:
Code:
void Minimap::DrawPoint(C Rect &rect,POINT_TYP pointTyp){
if (pointTyp==PT_PLAYER){
rect.center().draw(WHITE);}
if (pointTyp==PT_NPC){
rect.center().draw(RED);}
}
at the moment i set the red point for the NPC to center.
I hope you can help me.
greeting Denis
|
|
10-28-2010 10:58 PM |
|
Dynad
Member
|
RE: How create a new Point in the Minimap
Well you have to give the RED and the WHITE points different positions to make it work.
There is always evil somewhere, you just have to look for it properly.
|
|
10-29-2010 03:28 AM |
|
djpercy
Member
|
RE: How create a new Point in the Minimap
Hi,
thanks that's right
The NPC has a position on the World-Map now i must calculate the position on the minmap. How to get the NPC position from the World-Map and how translate this position to the minimap.
Greeting Denis
|
|
10-29-2010 05:58 PM |
|
Dynad
Member
|
RE: How create a new Point in the Minimap
Well i guess you have a container with your Players and NPC's... just iterate through all the NPC's and getting their positions and draw them on the minimap.
e.g like this code snippet:
REPA(Monsters)
{
D.Dot(posToScreen(Monsters[i].pos()));
}
There is always evil somewhere, you just have to look for it properly.
|
|
10-29-2010 06:18 PM |
|
djpercy
Member
|
RE: How create a new Point in the Minimap
Hi,
thanks for your Help.
I understand your code but can you help me a littel bit more?
how make a trigger for my NPC that he ping always his position to your code or to my minimap?
Grettings Denis
|
|
10-29-2010 07:11 PM |
|
Dynad
Member
|
RE: How create a new Point in the Minimap
Well you can use this in your update() loop to keep it always updated. So use this in the same class where you have your minimap and it should work.
There is always evil somewhere, you just have to look for it properly.
|
|
10-29-2010 07:19 PM |
|
djpercy
Member
|
RE: How create a new Point in the Minimap
Hi,
how can i access a NPC? tell my the code how find one or any NPC in the World. Sorry, I don't know it. I have added three Coblin over the World Editor into my map. They all have the Type OBJ_CHR, when I start my Map in the World-Editor I see all Coblin but when I started the World from C++ I see nothing except the terrain why?
Greetings Denis
(This post was last modified: 10-30-2010 12:40 AM by djpercy.)
|
|
10-29-2010 10:05 PM |
|
djpercy
Member
|
RE: How create a new Point in the Minimap
Hi,
ok I'am really blind, my code not the OBJ_CHR Type called listed.
All the Coblin have a red Dot on hier own body. How create the red Dot to the right position in my minmap? How translate it from the wordlposition to the minimap position.
Greeting Denis
(This post was last modified: 10-30-2010 09:54 AM by djpercy.)
|
|
10-30-2010 09:53 AM |
|
Dynad
Member
|
RE: How create a new Point in the Minimap
Well if you had read/understand my post with the code earlier you wouldn't ask for that.
There is always evil somewhere, you just have to look for it properly.
|
|
10-30-2010 05:10 PM |
|
djpercy
Member
|
RE: How create a new Point in the Minimap
Hi,
your code displayed a point on the display directly on the Monster position and translate not the point to the minmap. What must i do to translate the point and display on the Minimap? I have the follow code.
Code:
Vec2 t = Game::World.mini_map.worldToArea(point);
if (pointTyp==PT_NPC){
D.dot(RED,t);
}
this is not the Solution.
Greeting Denis
(This post was last modified: 10-30-2010 06:55 PM by djpercy.)
|
|
10-30-2010 06:55 PM |
|
Dynad
Member
|
RE: How create a new Point in the Minimap
I don't really understand your problem....
Just please take a closer look at my code:
REPA(Monsters)
{
D.Dot(posToScreen(Monsters[i].pos()));
}
posToScreen-> Translates a World Vec to a Screen Vec2 position which means you can use e.g:
REPA(Monsters)
{
Vec2 t = Game::World.mini_map.worldToArea(posToScreen(Monsters[i].pos()));
if (pointTyp==PT_NPC){
D.dot(RED,t);
}
}
There is always evil somewhere, you just have to look for it properly.
|
|
10-31-2010 12:37 AM |
|
djpercy
Member
|
RE: How create a new Point in the Minimap
Hi,
thanks for your help. This is a mistake I call the Code with the right point. This is my code example:
Code:
void Draw()
{
Renderer(Render);
Minimap::Draw(Rect_RU(D.w(),D.h(),0.5,0.5).extend(-0.05f), Cam.at.xz(), MapRadius);
REPA(Chrs)
{
Minimap::DrawPoint(Rect_RU(D.w(),D.h(),0.5,0.5).extend(-0.05f),PT_NPC,PosToScreen(Chrs[i].pos()));
}
Minimap::DrawPoint(Rect_RU(D.w(),D.h(),0.5,0.5).extend(-0.05f),PT_PLAYER,PosToScreen(player.pos()));
}
void Minimap::DrawPoint(C Rect &rect,POINT_TYP pointTyp,C Vec2 point){
if (pointTyp==PT_PLAYER){
rect.center().draw(WHITE);
}
Vec2 t=rect.center()-point;
if (pointTyp==PT_NPC){
D.dot(RED,t);
}
}
I understand the code this is not my problem.
Look to the picture. You can See the red dot is not on right place on the Minmap.
The Translation between the Worldpoint and the mappoint a not correct.
Greeting Denis
(This post was last modified: 10-31-2010 03:02 AM by djpercy.)
|
|
10-31-2010 02:57 AM |
|
Dynad
Member
|
RE: How create a new Point in the Minimap
Well please take a look at the tutorial Mini maps... if you just use that DrawMiniMap() function and you're done.
There is always evil somewhere, you just have to look for it properly.
(This post was last modified: 10-31-2010 03:31 AM by Dynad.)
|
|
10-31-2010 03:31 AM |
|
djpercy
Member
|
RE: How create a new Point in the Minimap
hi, Thank you for your Help.
Ok, I think you doesn't understand my problem.
The Tutorial do paint one Point on the map
rect.center().draw(WHITE)
and not more.
Once again how Translate my Point to the Minmap.
what is the Factor?
have Esenthel a Function maybe like this:
float translatePoint(myWorld,Minimap){
point.x=Minimap/myWorld*x
point.y=minimap/myWorld*y
return point
}
Unfortunately, the documentation ist very poor.
You must searches all the header files, so that you get one information.
look at my Picture.
Greeting Denis
|
|
10-31-2010 11:50 AM |
|
Esenthel
Administrator
|
RE: How create a new Point in the Minimap
you shouldn't use postoscreen as it projects 3d point,
you should use Vec2 pos2d=chr.pos().xz();
scale it by MapRadius, offset by map center (camera.at.xz())
it's just basic maths
you have the formulas in DrawMiniMap
|
|
10-31-2010 12:00 PM |
|