Map of ARPG Web game (ii)

Source: Internet
Author: User

[Turn]http://www.cnblogs.com/bluewoods/p/4684557.html

This section speaks of Windows, the window, which is the visual angle of the game. Now the web game is divided into 2D games, 2.5D games and 3D games, 2D game is basically some horizontal board, 2.5D is basically ARPG, you can say the game screen projection angle slightly different, 3D Web game, now there are many, the effect is good, are with the micro-end, There will be a lag if there is too many people on the same screen with no micro-end. Personal feeling Web page is not suitable for 3D, one is the efficiency problem, the second is the performance is not as good as the end of the tour. End-trip development cycle longer, the world view is more ambitious, players, to adapt to the game world, and find their own positioning, so that the player's loyalty is higher, and the purpose of the web game is not the opposite, it is mainly to cater to the player's taste, and the use of the player's psychology to induce its recharge, game cycle of about Players play one months basically there is nothing new.

That's a little off the topic. This window is mainly based on the player's coordinates to control the character layer and the map layer movement, it contains four attributes: Focuspoint, max window: maxrect, Mobile window: moverect, screen window Viewrect

    • People coordinates fp: When you play a Web game, you will find the player's moving range. When he moves to the border of the map, he really moves to the border, and when he is away from the border, he basically stays in the middle of the screen. Although the character position is expressed in grid coordinates, the character moves in the same way as the pixel.
    • Maximum range Maxrect: is the width and height of the current map
    • Moving range Moverect: The player moves within this range, does not change the map layer coordinates, in the game I set the movable range is 100*100. In fact, you can imagine: in the center of the screen, there are 100*100 in the rectangle, the player in this move is not to push the map, to help improve the player's experience, improve efficiency.
    • Screen window Screenrect: Is the height of the stage

The algorithm code is as follows:

 Public void {    = _viewrect.x;     // record the original window coordinates (the function of the record?) )    0;     0 ;     // Trigger View Change event }

Privatefunction focuspointchanged ():void{<br>//change the coordinates of the screen window when detecting    if(_focuspoint.x <_movablerect.x) {_viewrect.x= _focuspoint.x-_viewrect.width/2+ _movablerect.width/2; }        if(_focuspoint.x >_movablerect.right) {_viewrect.x= _focuspoint.x-_viewrect.width/2-_movablerect.width/2; }    if(_focuspoint.y <_movablerect.y) {_viewrect.y= _focuspoint.y-_viewrect.height/2+ _movablerect.height/2; }    if(_focuspoint.y >_movablerect.bottom) {_viewrect.y= _focuspoint.y-_viewrect.height/2-_movablerect.height/2; }===========================================================================Checkviewrectoffset ();//Detection Boundary <br><br> setmovableoffset ();//screen window XY changed, need to change the coordinates of the moving window
<em id="__mcedel">  movemap ();   load Map }</em>
// The screen window changes as the movement is in the center of the screen window, and the Mobile window also recalculates its XY coordinates <br>private function setmovableoffset (): void {    0.5;     0.5 ;}
//Detecting Boundary of screen window <br>private function checkviewrectoffset (): void{    if(_viewrect.x <0) {_viewrect.x=0; }    if(_viewrect.y <0) {_viewrect.y=0; }    if(_viewrect.x + _viewrect.width >_maxrect.width) {_viewrect.x= _maxrect.width-_viewrect.width; }    if(_viewrect.y + _viewrect.height >_maxrect.height) {_viewrect.y= _maxrect.height-_viewrect.height; }}
This is the game window manager, according to the changes in the movement of the coordinates of the code, the map layer is based on the coordinates of the screen to determine which map to load.

Map of ARPG Web game (ii)

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.