Amon,
What is this doing?
If MouseX()/32 *32 And MouseY()/32 *32 = id
It divides by 32 then multiples by 32.
If mousex() is 200 it'll be 200/32 = 6. 6*32 = 200.
That's what you were doing wrong
here .
Anyway, I would strongly recommend redesigning.
This works but needs more cleaning :
SuperStrict
Graphics 800,600
Global ThisImage:TImage = LoadAnimImage("12.png" , 32 , 32 , 0 , 2)
Const MAPWIDTH:Int = 22
Const MAPHEIGHT:Int = 18
Global TileMap:ttile[ MAPWIDTH , MAPHEIGHT]
For Local yiter:Int = 0 Until MAPHEIGHT-1
For Local xiter:Int = 0 Until MAPWIDTH - 1
Local mydata:Int
ReadData mydata
tilemap[xiter , yiter] = ttile.create()
tilemap[xiter,yiter].image=thisimage
tilemap[xiter , yiter].frame = mydata
tilemap[xiter , yiter].x = xiter * 32
tilemap[xiter , yiter].y = yiter * 32
Next
Next
While Not KeyHit(KEY_ESCAPE)
Local mx:Int = MouseX()
Local my:Int = MouseY()
If MouseHit(1) ttile.change_tile(mx,my)
Cls
ttile.draw_tiles
Flip
Wend
Type ttile
Field x:Int
Field y:Int
Field frame:Int
Field image:timage
Function Create:ttile()
Return New ttile
End Function
Function Draw_tiles()
For Local yiter:Int = 0 Until MAPHEIGHT-1
For Local xiter:Int = 0 Until MAPWIDTH - 1
Tilemap[xiter,yiter].Draw
Next
Next
End Function
Method Draw()
DrawImage Image , x ,y , frame
End Method
Function change_tile(mx:Int , my:Int)
Local xiter:Int = mx/32
Local yiter:Int = my/32
Select tilemap[xiter , yiter].frame
Case 0
tilemap[xiter , yiter].frame = 1
Case 1
tilemap[xiter , yiter].frame = 0
Default Notify"Incorrect Frame Number"
Return
End Select
End Function
End Type
DefData 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DefData 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DefData 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DefData 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DefData 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DefData 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DefData 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DefData 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DefData 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
<edit> Code edited a couple of times to get rid of stupid mistakes and clean it up a bit. Could still be more encapsulated but there you go.