Skip to content
Kelvin Yang edited this page Mar 11, 2015 · 2 revisions

##Level Map Data The map data for each level consists of a 17x17 array of shorts. Which can be found in Grid.java.

###Bit Meanings Currently, only the 6 LSB of each short are used, so there are still 10 more bits for future implementation
0th bit : Left boundary
1st bit : Upper boundary
2nd bit : Right boundary
3rd bit : Lower boundary
4th bit : Pellet
5th bit : Fruit

These can be combined in a single element of the array. So if you wanted to create a location that is entirely boxed in, you would convert 001111 to binary which would result in 15. Therefore the value 15 corresponds to a location where the Character cannot move in any direction.

###Reading Bits In the code, you might see many statements where it will read an element from the map data, and & (bitwise AND) it with another value. This is done to retrieve specific bits from a value. For example if you had the value "010011", and you wanted to see if this element contained a pellet, you would and it with "010000", to retrieve only the 4th bit, which you can then check the value of.

###Tunneling To utilize tunnels, all you have to do is not block off the edge of a map. If this is done, the game will handle the Character going off screen by looping it back around to the other side of the map. This works both vertically and horizontally.

###Additional Information Each of the boundaries in a location apply only to that location, so if you had an element with value 15 (Complete enclosed box) Other Characters would be able to enter the box, but none would be able to leave. In order to create a boundary from both sides, you will have to include the data in the adjacent locations as well.

Clone this wiki locally