hey mate!
That's a very nice game you have going there!
I didn't really understand how your game checked for whether the robot is in the tile, so I wrote an alternative way which works

-- and it was such fun that I added a sketch of the whole battery-thingy, too!

I hope you didn't mind xD
Rem Project: Levels
Rem Created: Sunday, March 25, 2012
Rem Class: CIT 458
Rem ***** Main Source File *****
rem define map width and height
#constant MapWidth 64
#constant MapHeight 64
#constant TileWidth 32
#constant TileHeight 32
rem create our map array
dim map( MapWidth , MapHeight ) as integer
rem define tile indexes
#constant Rock2 1
#constant Rock1 2
#constant Sand 3
rem load tile images
load image "rock2.png" , Rock2
load image "rock1.png" , Rock1
load image "sand.png" , Sand
load music "music.mp3" , 1
loop music 1
load image "mars.jpg" , 1000
paste image 1000, 0,50
Set window on
Set window layout 1,1,1
Set Window title "The Mars Landing"
Set window position 100,200
Set Text Font "Ariel"
Set Text Size textSize
paste image 1000, 0,50
wait 1000
center text 320, 240, "CIT 458 Developers bring you..."
sync
wait 1000
paste image 1000, 0,50
set Text Size 60
CLS
inc textSize
wait 1
paste image 1000, 0,50
center text 320, 200, "The Mars Landing"
sync
wait 1
set text size 20
center text 320, 420, "Press any key to start playing..."
sync
direction = 1
Wait key
CLS
rem make everything grass
for x = 0 to MapWidth
for y = 0 to MapHeight
map( x , y ) = Sand
next y
next x
rem randomly place 10 dirt blocks
for n = 1 to 25
x = rnd( MapWidth )
y = rnd( MapHeight )
map( x , y ) = Rock1
next n
rem randomly place 10 empty blocks
for n = 26 to 51
x = rnd( MapWidth )
y = rnd( MapHeight )
map( x , y ) = Rock2
next n
rem global variables
global MapOffX as integer
global MapOffY as integer
load image "robot.png" , 1612
load image "robot2.png" , 2161
REM DEFINE THE DEFAULT VALUE OF THE BATTERY LIFE
REM ALSO SPECIFY THE VALUES OF THE PlayerX and PlayerY Variables which are used later on
battery# = 1000
PlayerX = 300
PlayerY = 220
do
Rem scroll map with arrow keys
rem ALSO REDUCE BATTERY POWER FOR EVERY MOVE
if upkey() then inc MapOffY : battery# = battery# - 1
if downkey() then dec MapOffY : battery# = battery# - 1
if leftkey()
inc MapOffX
direction = 2
battery# = battery# - 1
endif
if rightkey()
dec MapOffX
direction = 1
battery# = battery# - 1
endif
Rem draw everything to the screen
for x = 0 to MapWidth
for y = 0 to MapHeight
paste image map( x , y ) , TileWidth * x + MapOffX , TileHeight * y + MapOffY
if direction = 1
paste image 1612 , 300 , 220
endif
if direction = 2
paste image 2161 , 300 , 220
ENDIF
rem check if player is in bounds
remstart
Note: when pasting the image, the game pastes the TOP LEFT corner of the image to the specified coordinate,
thus the center of the image is at this coordinate PLUS 1/2 the width/height of the used image (50pixels).
The following conditions thus check if:
-the center of the robot image is to the right of the left border of the current map tile (given by x and y)
-the center of the robot image is to the left of the left border of the NEXT map tile (x+1), this being the "right border" of the current map tile
-the center of the robot image is below the upper border of the current map tile
-the center of the robot image is above the upper border of the next map tile (=lower border of THIS map tile)
If all conditions are met, continue to checking whether the current tile is a "special tile"
remend
if playerX + 25 > tilewidth * x + MapOffX AND playerX + 25 < tilewidth * (x+1) + MapOffX
if playerY + 25 > tileheight * y + MapOffY AND playerY + 25 < tilewidth * (y+1) + MapOffY
rem check if player is on a stone tile
if map( x , y ) = Rock1
rem increment samples collected
samples = samples + 1
rem set tile to grass now that we've collected it
map( x , y ) = Sand
endif
rem check if player is on a "crystal" tile
if map( x , y ) = Rock2
rem RECHARGE THE BATTERY TO FULL POWER
battery# = 1000
rem set tile to grass now that we've collected it
map( x , y ) = Sand
endif
endif
endif
next y
next x
rem display the calculated percentage of remaining battery life with one number behind the decimal point ( str$( ... , 1) )
text 100 , 80 , "Battery Life: " + str$( (battery# / 1000 ) * 100 , 1) + "%"
text 100 , 100 , "Samples Collected: " + str$(samples)
if battery# <= 0
text 300 , 150, "GAME OVER"
rem DO WHATEVER SHOULD REALLY HAPPEN WHEN RUNNING OUT OF POWER
endif
sync
loop
end
To be honest, though, I'm not sure if it's the most elegant way..
I hope the annotations are somewhat clea... if you have any questions about the code or anything else, just shout