06-19-2018, 04:33 AM
Hi,
I'm trying to get collision to work between a sprite and a map tile. From reading the docs, it would seem that there is no built in Tilengine functionality to check for this kind of collision. Am I correct in saying this? I turned to whatever examples I could find. The best I could find was from the Super Mario Clone in Player.cs.
Am I on the right track and are there any other examples of how this can be done?
I'm trying to get collision to work between a sprite and a map tile. From reading the docs, it would seem that there is no built in Tilengine functionality to check for this kind of collision. Am I correct in saying this? I turned to whatever examples I could find. The best I could find was from the Super Mario Clone in Player.cs.
Code:
if (y < oldy)
{
floor = false;
int[] points = { 4, 12 };
int c;
for (c = 0; c < points.Length; c++)
{
World.Tile tile = world.GetTile(x + points[c], y);
if (tile.Type == World.Type.Solid || tile.Type == World.Type.Question)
{
y = (y + 16) & ~15;
yspeed = 0;
t0Jump = 0;
if (tile.Type == World.Type.Question)
new Bumper(world, Game.objects, 0, tile.Row, tile.Col, 51);
}
else if (tile.Type == World.Type.Coin)
{
world.ClearTile(tile.Row, tile.Col);
new Collect(world, tile.Col * 16, tile.Row * 16);
Game.AddCoin();
}
}
}
Am I on the right track and are there any other examples of how this can be done?