Board Thread:Questions and Answers/@comment-24454571-20140530055317/@comment-24854750-20140605220527

The DATA should be written out in such a way that when it is READ and saved to the MAP array, the values for the two dimensional array directly correspond to the x and y axes of the screen. That is, MAP(14,7) is representative of the space located at 14,7. As for how FLOOR(PLX/8) and FLOOR(PLY/8) refer to your position on the screen, let's work out the problem in reverse. Suppose your box was directly aligned with the space 14,7 (that is, the top left corner of your box is at the same spot as the top left corner of space 14,7). If you were to check the variables PLX and PLY and/or PLXO and PLYO, you would find that computer does not define your box as being located at 14,7 but instead at 112,56. Why? Because the position of your box on the screen is based on the pixel it is drawn at, and not based on the BG tiles or MAP array. The BG tiles are 8x8 pixels large which means that in order to convert your location based on pixels to your location on the BG tiles (and consequently the MAP array), you must divide by 8. 112/8=14. 56/8=7. And these numbers are what will be used within the MAP array [as in, MAP(14,7)]. Now suppose you press the right button and then the down button. Now your box is located at 113,57, and when you divide by 8, you get this: 113/8=14.125; 57/8=7.125. Technically, there is no tile placed at 14.125,7.125, but if you were to look at the screen as the program would display it, you would still be clearly within the 14,7 tile. Thus, the FLOOR function is added to reduce any decimal numbers to an integer. That is, 14.125 becomes 14 and 7.125 becomes 7, and then the program checks the MAP array using those values [as in, MAP(14,7)].

As for the zeros and ones, I have not actually downloaded the COLITEST but have only looked at the code you posted in the other thread. Based on what I saw, I would assume that the DATA posted at the end of the code was written using only zeros and ones, but maybe I am mistaken. If I am, then disregard what I'm about to say. What you have deduced skeptically is in fact true. The IF statements, while they do not actually contain any real conditional statements, Petit Computer reads it as, IF MAP(14,7) has value, THEN negate player movement. So at the beginning of the program, all of the DATA at the end is saved to the MAP array, thus, any value of MAP will either be equal to 1 or nothing. And when the program reaches those four IF statements, the program is simply checking "does the MAP array have value (or is not equal to 0)?" It is simply a matter of shorthand. I personally avoid it because I prefer reading my IF statements as explicitly conditional.