Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sprite Collision With Map Tiles
#1
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.

 
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?
Reply


Messages In This Thread
Sprite Collision With Map Tiles - by Daniel H. - 06-19-2018, 04:33 AM
RE: Sprite Collision With Map Tiles - by megamarc - 06-22-2018, 06:46 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)