The realization of small-scale game map

Source: Internet
Author: User

In the game, some scenes will use a small map.
As its name, the essence of the small map is the map, the abbreviated simplified two-dimensional coordinate set body, does not indicate the height, only the plane coordinates are marked. The key to a small map is the scale bar. Simply label the actual object position proportionally on a thumbnail. Objects can be divided into two types, static and dynamic, according to whether there is any change (whether it persists or if the position will change). A static object is drawn directly into a background image, and a dynamic object, given a symbol, needs to be placed in a small map in real time according to its state of presence and position change.
A small map also needs to be clear, what needs to be reflected on the map, and which can be omitted. For example, considering the purpose of the game and the performance of the game, in the Moba battle, I just want to know the position of the protagonist, the location of the wild strange, the state of the blood spring, as for the soldier, if you do not care, you can not use the small map to reflect the creep information.
Condition: Art provides a background map of the static objects drawn proportionally. Horizontal and vertical scales are kept as consistent as possible.

Art can tell you the scale, but I think it's better to set 2 datum points to calculate the scale based on the coordinates of the datum point in the actual scene and the relative coordinates in the small map. With the scale, the coordinates of all the objects in the scene can be fed back to the small map in real time.

private void Callittlemapscale ()    {       float mapwidth = Mathf.abs (m_transmapbase1.localposition.x-m_ transmapbase2.localposition.x); M_fmapscale = Mapwidth/mathf.abs (m_db.m_gomobabase1.transform.position.x-m_db.m_ gomobabase2.transform.position.x);     Need fine art to guarantee the width of the high M_vscenecenter = (m_db.m_goMobaBase1.transform.position + m_db.m_goMobaBase2.transform.position)/2.0f ;    }


private void Worldpositiontolittlemappos (Gameobject _mappoint, Vector3 _worldpos)    {        Vector3 Vposfromworldcenter = _worldpos-m_vscenecenter;             _mappoint.transform.localposition = new Vector3 (vposfromworldcenter.x * m_fmapscale, Vposfromworldcenter.z * m_ Fmapscalez, _mappoint.transform.localposition.z) + m_TransMapCenter.transform.localPosition;              }
Points:
1. Set datum point, Calculate scale. See if it is necessary to calculate horizontally and vertically separately.

2. Calculate the coordinates of the actual object position on the small map according to the scale. Note that with localposition, it is recommended to use a relative center position offset.

This deals with the updating of the object's location on the small map, as well as the hidden needs caused by the player being killed and defending the building from being destroyed. It is necessary to establish a mapping between the points on the small map and the actual gameobject, using event delegation to notify the small map to hide the corresponding points when the Gameobject is destroyed.


Of course, some games on the requirements of the small map, a wide range of maps, according to the player's game progress and all the current location only display the present part, in the end of the tour is more common, the hand tour is generally displayed directly.



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The realization of small-scale game map

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.