Anon there are several things wrong?
First if you want to place your tiles in a 32 by 32 system you cannot set the Startx and Starty at 100 it should be 96, or better a number divideable (can you say that in english) by 32
Then you should concentrate on a system you want to use throughout your program. Either you want to use the Array indexes or the screencoordinates.
You start the tiledrawing map[0,0] at 100,100 and don't add that to mousex mousey before - so no wonder you will not place the tiles where your mouse is...
Try this ;-)
Edited klepto2 was quicker :-P
Try this one as well. I added a rectangle and security question to avoid an error when you klick outside the array dimensions
First if you want to place your tiles in a 32 by 32 system you cannot set the Startx and Starty at 100 it should be 96, or better a number divideable (can you say that in english) by 32
Then you should concentrate on a system you want to use throughout your program. Either you want to use the Array indexes or the screencoordinates.
You start the tiledrawing map[0,0] at 100,100 and don't add that to mousex mousey before - so no wonder you will not place the tiles where your mouse is...
Try this ;-)
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 = 96' where the tilemap starts on the x axis Global mapstartY = 96' 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 init_map()' Call the init_map function 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 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 SetColor 255,255,255 DrawLine mx-1,my-1,mx+33,my-1 DrawLine mx-1,my-1,mx-1,my+33 DrawLine mx+33,my-1,mx+33,my+33 DrawLine mx-1,my+33,mx+33,my+33 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) Local mx:Int = MouseX()/32-3'= set mousex position according to the array Local my:Int = MouseY()/32-3'= set mousey position according to the array If mx>=0 And mx<=6 And my>=0 And my<=6 map[mx, my] = curtile EndIf EndIf End Function
Edited klepto2 was quicker :-P
Try this one as well. I added a rectangle and security question to avoid an error when you klick outside the array dimensions