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 Function Setfocuspoint (p:point): void{ _orx = _viewrect.x; _ory = _viewrect.y; Record the original window coordinates (the function of the record?) ) _focuspoint.x = p.x >> 0; _focuspoint.y = p.y >> 0; Focuspointchanged (); Trigger View Change Event}
Private Function Focuspointchanged (): void{
Change the screen window coordinates if detected (_focuspoint.x < _movablerect.x) {_viewrect.x = _focuspoint.x-_VIEWRECT.WIDTH/2 + _movablerect.wi DTH/2;} if (_focuspoint.x > _movablerect.right) { _viewrect.x = _focuspoint.x-_VIEWRECT.WIDTH/2-_movablerect.wid TH/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
Setmovableoffset (); Screen window XY changed, need to change the coordinates of the moving window
Movemap ();//Load Map}
The screen window changes as the movement is in the center of the screen window, and the Mobile window recalculates its XY coordinates.
Private Function Setmovableoffset (): Void{_movablerect.x = _viewrect.x + (_viewrect.width-_movablerect.width) * 0.5;_mo Vablerect.y = _viewrect.y + (_viewrect.height-_movablerect.height) * 0.5;}
Detecting boundaries of screen windows
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)