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