jonoxia / rpgbase

Generic Node.js/HTML5 role-playing game client/server
8 stars 6 forks source link

Map wraparound feature #93

Closed jonoxia closed 10 years ago

jonoxia commented 10 years ago

If you set x_wrap and/or y_wrap on the map to true, then walking off the (left,right) and/or (top, bottom) sides of the map takes you to the opposite side.

Consists of three parts:

  1. If you actually walk off that side, your position needs to be set to the opposite side.
  2. Don't block scrolling when you approach that side, but rather fill up the screen with tiles from opposite side of map to keep the scrolling continuous
  3. If anything needs to check the square you're facing or about to move into -- such as the canMove method -- then if you're on the edge of the map, it needs to query the square from the opposite edge of the map.

Anywhere that map[y][x-1] or map[y][x+1] is accessed directly, it needs to be replaced with a function call which returns the neighboring square based on current map topology.

jonoxia commented 10 years ago

Done except that the "camera" does not follow you when you sail east across the "international date line". I suspect the reason may be in calcAutoScroll.

jonoxia commented 10 years ago

Fixed that last problem. Could use some unit tests for the edge cases but this is done now.