Online Game Demo Development Example: Multiplayer RPG (MMO RPG) Demo Development Record (9th article)

Source: Internet
Author: User
Tags abs

Version11

Main content: Viewport, map scrolling, debugging information output

Owning part: Client

Code address Https://github.com/changjixiong/MMO-RPGGame, how to get the code, refer to how to check out the different versions of code from GitHub with SVN

e-mail address: changjixiong@gmail.com This series directory


This update, the main increase in the viewport, so that the characters walking, the map will scroll

The so-called viewport, is the game window, in a certain scenario, assuming that the map width and height are 640*3,480*3, that is, the size of the current scene, then, the map is the 3*3 screen, and the viewport in this range according to the movement of the characters moved, see the picture of the real line box, the figure in position 1th, Viewport at the top left of the scene, when the character is at position 2nd, the viewport moves to the center-right position of the scene.

The map background itself can be stitched together, pay attention to the image, the gap is to facilitate the explanation and deliberately left out. When the viewport moves, the coordinates of the map are calculated according to the scene coordinates of the viewport, and then the map is pasted, for example, when the viewport is in position 2nd, it needs to be affixed 4 times.

Specific code, reference Gamemap::moveviewport, Gamemap::D Raw


Adjusts the character's stride size to 32*24, and the grid resizes simultaneously

Adjusted the direction of the judgment

As shown in figure

ABS (DY)/dx < steplen_y/(3*steplen_x) and dx>0 determines the distance from the coordinates of the coordinate click coordinates and the person's coordinates respectively.

For ease of calculation, the above calculation variants are abs (DY) * (3*steplen_x) < STEPLEN_Y*DX

Other aspects in accordance with the same method, note that the determination of the North is 4*steplen_y (when dx!=0), when the dx=0, directly using DY to determine


Add Sprite::movepos, make the character walk, change their coordinates in the scene

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.