Page 1 of 1

someone could help me about Map

Posted: Fri Jan 28, 2011 4:14 am
by lxxkof
i've read some source of L2j. i wanna research the map technology.
but may be i am too dull to understand the below code

Code: Select all

     /*     * biteshift, defines number of regions     * note, shifting by 15 will result in regions corresponding to map tiles     * shifting by 12 divides one tile to 8x8 regions     */    public static final int SHIFT_BY = 12;        private static final int TILE_SIZE = 32768;//why here is 32768        /** Map dimensions */       //why subtractor is 17 18 19 20...    public static final int MAP_MIN_X = (Config.WORLD_X_MIN - 20) * TILE_SIZE;    public static final int MAP_MAX_X = (Config.WORLD_X_MAX - 19) * TILE_SIZE;    public static final int MAP_MIN_Y = (Config.WORLD_Y_MIN - 18) * TILE_SIZE;    public static final int MAP_MAX_Y = (Config.WORLD_Y_MAX - 17) * TILE_SIZE;        /** calculated offset used so top left region is 0,0 */    public static final int OFFSET_X = Math.abs(MAP_MIN_X >> SHIFT_BY);    public static final int OFFSET_Y = Math.abs(MAP_MIN_Y >> SHIFT_BY);        /** number of regions */    private static final int REGIONS_X = (MAP_MAX_X >> SHIFT_BY) + OFFSET_X;    private static final int REGIONS_Y = (MAP_MAX_Y >> SHIFT_BY) + OFFSET_Y; 
thanks i wanna someone help me to comprehend this code

Re: someone could help me about Map

Posted: Mon Feb 14, 2011 8:37 am
by Tryskell

Code: Select all

public static final int MAP_MIN_X
Only means the variable named "MAP_MIN_X" is an integer type.

There is no "maps" in your example. By maps, I mean Maps, FastMaps etc.

In your example, each variables got a normal value, that's all.

To take an exemple, let's calculate MAP_MIN_X = (Config.WORLD_X_MIN - 20) * TILE_SIZE

Higher you see TILE_SIZE = 32768
Let's say for exercice purpose WORLD_X_MIN = 1000.

MAP_MIN_X = (1000 - 20) * 32768
MAP_MIN_X = 32112640

That's all, lol.

That just defines 4 points for another program part. If you search about the use of those variables, just search where are used those variables.