ok, I've coded a little tilemap editor that uses MapStartX and MapStartY to hold where the tilemap should start on screen.
The problem I'm having is that the mouse doesnt tile up with the location of the map array and the placetile function causes an error. The full code is below with image and commented.

Run this in blitzmax and you will see what I'm trying to do.
The problem I'm having is that the mouse doesnt tile up with the location of the map array and the placetile function causes an error. The full code is below with image and commented.
Strict Graphics 1024,768,32,60 SetMaskColor 255,0,255' set the masking color Global tiles:TImage = LoadAnimImage("pole.png",32,32,0,5)'load the tiles Global mapstartX = 100' where the tilemap starts on the x axis Global mapstartY = 100' where the tilemap starts on the y axis Global map:Int[7,7]' Global array to hold map data Global mx:Int' Tracks mousex() movement Global my:Int' Tracks mousey() movement Global curtile:Int = 0'Holds the current tile number Repeat Cls mx:Int = MouseX()/32*32'= set the mouse to move 32 pixels at a time my:Int = MouseY()/32*32'= set the mouse to move 32 pixels at a time init_map()' Call the init_map function draw_map()' Call the draw_map function place_tile()'Call the place_tile function DrawImage tiles,mx,my,curtile ' Draw the current tile at mouse&mousey locations If MouseHit(KEY_MOUSERIGHT)'If right mouse button is hit curtile:+1'Increase curtile by 1 If curtile > 4 Then curtile = 0' if curtile is greater than 4 set curtile to 0 EndIf FlushMem Flip Until KeyHit(KEY_ESCAPE) 'the Function below sets all the map positions To 0 Function init_map() For Local x:Int = 0 To 6 For Local y:Int = 0 To 6 map[x,y] = 0 Next Next End Function 'the Function below updates the map and draws it to screen Function draw_map() For Local x:Int = 0 To 6 For Local y:Int = 0 To 6 'below we draw the tiles at mapstartx and mapstarty coords of the screen DrawImage tiles,MapstartX+x*32,mapstartY+y*32,map[x,y] Next Next End Function 'The function below places the tile on the map Function place_tile() If MouseDown(KEY_MOUSELEFT) 'Below we devide a map position by the tile size to get the correct place on the array map[MouseX() / 32, MouseY() /32] = curtile EndIf End Function

Run this in blitzmax and you will see what I'm trying to do.