Hi guys.
I am creating a Level Editor and I'm facing a situation. When I add tiles to the level, I want to make collision detection in order not to cover the previously added one. So that, when moving with the mouse to stop when trying to pass inside the other tile.
Thanks in advance.
Loading
Steve TsikiPosted Dec 24, 2011, 2:10 PM
foreach (Tiles tile in tiles) // Updates each tile's position
{
if (tile.clic == true && mouseState.LeftButton == ButtonState.Pressed)
{
tile.tiles_rec.X = mouse_x;
tile.tiles_rec.Y = mouse_y;
tile.SetPos(new Vector2(mouse_x, mouse_y), window_width, window_height);
tile.t_body.Position = new Vector2(tile.tiles_rec.X, tile.tiles_rec.Y);
break;
}
else if (tile.clic == true && mouseState.LeftButton == ButtonState.Released)
{
tile.clic = false;
}
}
"""""""""""""""""""""""
This is the part of the code, where I update the position of the tiles with my mouse. The class of the tiles is "Tiles" and the "SetPos" function updates the position in the window borders.The "t_body" is the tiles' dynamic body using a Physics engine.