in racing game how to creat a minimap?

Started by Uncle Ray, September 18, 2014, 05:44:21 AM

Previous topic - Next topic

Uncle Ray

    SOLVED THX EGO                                                                                                         ________________
                                                                                                             |    ___________   |
                                                                                                             |    ____●___     |  |
                                                                                                             |                  |    |  |→→→→→→→→→minimap
                                                                                                             |                  | ● |  |
_______________________________                                                     |__________|__|_|
                                                       |
                  npc_car ← ■                   |
______________________               |
                                       |  my_car  |
                                       |    ↑ ■       |→→→→→→→→→→→→my_main_world(which place the Object3D)
                                       |               |
                                       |               |



                                                                                                                           _____________________________________________________________________________________________________________

In the unity 3d ,if you want to create a minimap just set second camera,and...............

but in the jpct,how?
And i want to show whole of  the trace in the minimap,and just the location of the my_car and npc_car but not rotation,because in my game cars always forward.

i have the model of trace,how to reach that?
Anymore help would much appreciated.


EgonOlsen

It's basically the same thing as in Unity: Render the scene with a different camera. You can swap cameras in the world instance. In your case, it seems reasonable to render the scene in bird's view once into a texture and blit the result into the map view. The position of the cars can then be calculated based on the texture's size then their position in world space. Just make sure to enable OpenGL ES 2.0 or otherwise, render to texture won't work reliable on some devices.

Uncle Ray

My question was solved ,thx ego.

But there is a new question:
when i use buffer.blit(texture, 0, 0,1256+225-(mycar_dx), 8+220+(mycar_dz), 32, 32, FrameBuffer.TRANSPARENT_BLITTING);
in device which is 1920*1080,it is ok,just in the right location.
in device which is 1280*720,it's dispear......
when i switch LANDSCAPE to PORTRAIT,it's dispear too.


I think the problem is locate the minimap was based on the pixel,is that right?
Is there a method of blit() which is not base location on pixel but base on the proportion of device's screen(1080p,720p,480P)

thanks

EgonOlsen

No, there isn't. But you do this pretty easily by yourself by taking the actual screen resolution into account. I tend to wrap such blits in a some helper methods that either take normalized coordinates or work with a virtual resolution like 800*480 and maps that to the actual coordinates. Just keep in mind that as aspect ratios differ between devices as well.