Board Thread:Questions and Answers/@comment-24454571-20140517053531/@comment-5334617-20140521024230

an Array can only be as large as what's inbetween the parenthesis

You're confusing the value of the index with the value that is stored in the array at that index. gives you a book with 100 pages, numbered 0 to 99 inclusive. You cannot look at page 572. If you try anything with, you will get an error. But, on page 7, you can write the number 572:. You can test if the number written on page 68 is very large:, and sometimes it can be over 9000, even though that is not a page number.

MAPLINE$ only stores the value of "I"

is a numerical variable (because it does not end in ). The value of  is a number. is a string variable (because it ends in ). It stores string values, so to say it stores the value of, a numerical value, is not accurate. It stores the Ith (I=0, first; I=1, second; etc.) DATA element. (I'm not trying to berate and nit-pick; I'm trying to give you the vocabulary and language to help you understand the issues better and express yourself better when you do need to ask for help.)

to me it seemed as though the equation wouldn't simply result in a 1 or a 0, but I'm unsure of how the Array is interacting with the equation

You don't say what equation exactly you're referring to. If you're talking about  (from the first IF statement in the block of 4 that uses  ), think of it as   where   is   and   is. If the indices are within bounds,  will always return either a 0 or a 1, because the only values that are ever in   are 0 and 1.

Next, there's the divide-by-eight happening there. There are 256 pixels across the width of the screen, and there are 32 characters across the width of the screen. There are 8 pixels per character. So, pixel X-values 0 to 7 correspond to somwehere in character X-value 0, pixel X-values 8 to 15 are in character X-value 1, pixel X-values 16 to 23 are in character X-value 2, and so on. If you divide a pixel X-value by 8, and round down, you will get a character X-value, and the same calculation applies for Y-values. (SmileBasic has increasing Y-values going down the screen for both characters and pixels; not every programming environment is like this.)

So, if the upper-left corner of the box you're driving around the screen is at pixel location, that corner is in character location  , and it's no coincidence that that's the pair of values used as indices into.

Now, a square has four corners. It would look odd if the square's upper-left corner were not allowed to crash into a wall... but the upper-right corner was allowed! The upper-right corner is at pixel location ... apply the logic of the paragraph above, and you'll recognize another bit of the code. Then, figure out the pixel coordinates of the lower-left and lower-right corners, and the four IF statements will make sense.