I have made a simple chess-like board. Each tile instance is from the same object.
On this board the player may each turn spawn units, and move them, and they may attack enemies, etc. It all works. Except for movement...
The movement works perfectly almost all of the time. However, for reasons unknown to me; a unit that attempts to move onto the top or far-left row of tiles, at the edge of the board, is instead moved a tile in the opposite direction. It does not however do anything strange if a piece is moved on to the bottom or far-right rows. And everything is fine with any tile that is not at any edge.
I have used the debugger in order to determine what is happening with the global variables I use. They log the selected piece, the tile that piece is on, the tile that piece is moving to, etc. The globals do not change unexpectedly, and appear to point the piece to the correct tile, and nothing changes unexpectedly when the piece is moved to the wrong tile either.
I am rather confused, has anyone else had any similar problems?
Right Released
if global.obj!=0 // check key variables if a source unit is selected
{
dist=point_distance(global.obj.x,global.obj.y,global.vtile.x,global.vtile.y) // get distance from source object to tile
rang=global.obj.range*100+90 // calculate the range variable
//MOVE UNIT
if global.obj_mode==1 // selected instance is the player's own
and global.obj!=0 // source unit exists
and collision_point(mouse_x,mouse_y,tile,1,1) // there is a tile there
and not collision_point(mouse_x,mouse_y,object1,1,1) // there is not another unit there
and global.obj.moves>0 // unit has moves
and dist<160 // within range
{
with(global.obj)
{
move_snap(global.vtile.x,global.vtile.y) // move the source unit to the target tile
global.obj.moves=global.obj.moves-1; // reduce source unit's moves
}
}
else
{
move_snap(global.otile.x,global.otile.y) // move the source unit to their origin tile
}











