Actually to fit the 800x600 screen better it's best to reduce the images by one pixel vertically so their 16x15. If you do that the grid array should be 49x39 (50x40 adding the zeros).
It's best not to use sprites at all and use PASTE IMAGE instead to show the screen. You show the array using two FOR/NEXT loops... one for the grids vertical coordinates and one for the horizontal coordinates.
Now I don't mean to just throw this code at you but here it is... it's kinda hard to tell you the concept without revealing the entire process in code. I remed off your media to make it easier to work with but you can delete the "make media" area and unrem your loaded images.
sync on : sync rate 0
set display mode 800,600,32
backdrop off : hide mouse
randomize timer()
`load image "media\snakehead.png",1000
`load image "media\snakebody2.png",1001
`load image "media\border.png",1002
`load image "media\nomz.png",1003
` Make media
for t=1000 to 1003
ink rgb(rnd(255),rnd(255),rnd(255)),0
box 0,0,16,15
get image t,0,0,16,15,1
next t
` Set players starting coordinates
global parts as integer : parts = 1
PlayerX=25:PlayerY=18
dim grid(49,39)
` Place snake head into array
grid(PlayerX,PlayerY)=1000
` Place first food into array
grid(rnd(49),rnd(35))=1003
` Place borders
for t=0 to 49:grid(t,0)=1002:grid(t,39)=1002:next t
for t=0 to 39:grid(0,t)=1002:grid(49,t)=1002:next t
` Create a timer for player movement
tim=timer()
do
cls
` Reset the x and y coordinates
x=0:y=0
` Show the array
for gy=0 to 39
for gx=0 to 49
` Check if theres something to show
if grid(gx,gy)>0
` Check if it's a tail piece (numbers 1 to 999)
if grid(gx,gy)<1000 then Img=1001 else Img=grid(gx,gy)
paste image Img,x,y,1
endif
` Increase x coordinate
inc x,16
next gx
` Reset x and increase y coordinate
x=0:inc y,15
next gy
` Check if it's time to allow the player to move (every 100 milliseconds)
if timer()>tim+100
` Check for movement changes
if keystate(17) then Direction=1
if keystate(30) then Direction=2
if keystate(31) then Direction=3
if keystate(32) then Direction=4
` Move the player
select Direction
` Up
case 1
` Save what's in the way of the player
Temp=grid(PlayerX,PlayerY-1)
` Change the current players location to the number of parts
grid(PlayerX,PlayerY)=parts
` Move the player Up
dec PlayerY
` Add the new players location to the array
grid(PlayerX,PlayerY)=1000
endcase
` Left
case 2
` Save what's in the way of the player
Temp=grid(PlayerX-1,PlayerY)
` Change the current players location to the number of parts
grid(PlayerX,PlayerY)=parts
` Move the player Left
dec PlayerX
` Add the new players location to the array
grid(PlayerX,PlayerY)=1000
endcase
` Down
case 3
` Save what's in the way of the player
Temp=grid(PlayerX,PlayerY+1)
` Change the current players location to the number of parts
grid(PlayerX,PlayerY)=parts
` Move the player Down
inc PlayerY
` Add the new players location to the array
grid(PlayerX,PlayerY)=1000
endcase
` Right
case 4
` Save what's in the way of the player
Temp=grid(PlayerX+1,PlayerY)
` Change the current players location to the number of parts
grid(PlayerX,PlayerY)=parts
` Move the player Right
inc PlayerX
` Add the new players location to the array
grid(PlayerX,PlayerY)=1000
endcase
endselect
` Check if the player hit food
if Temp=1003
` Increase the length of the tail
inc Parts
` Pick a new random spot for food
repeat
rx=rnd(49)
ry=rnd(39)
` Only leave this loop when the random spot is empty
until grid(rx,ry)=0
` Place the new food
grid(rx,ry)=1003
endif
` Check if the player hit anything else
if Temp>0 and Temp<1003
ink rgb(255,255,255),0
center text screen width()/2,screen height()/2,"You're Dead!"
sync
wait key
end
endif
` Reduce any tail sections
for gy=0 to 39
for gx=0 to 49
if grid(gx,gy)>0 and grid(gx,gy)<1000
` Reduce the number in the array (by 1)
dec grid(gx,gy)
endif
next gx
next gy
` Reset timer
tim=timer()
endif
sync
loop
This uses the same concept I explained earlier. The array is used to store the locations of everything and used to show the screen. When the user moves their location in the array changes and any change in the array is shown on the next loop. Wherever the player was is replaced by the number of Parts. When a user eats food the Parts variable increases. Close to the end of the loop the whole array is checked and any numbers between 1 and 999 are reduced by one so if the tail is 7 pieces long in the array it'll look like "1000 7 6 5 4 3 2 1". 1000 is the head and 7-1 is the tail. On the next loop the 1000 will turn into the total number of parts (another 7) and because the array is constantly being reduced the other numbers will be reduced and the one will disappear giving the illusion of movement with a tail.