Example #1
0
        public void Draw(SpriteBatch spriteBatch, IsometricTile tile)
        {
            int yOff = 32;             // how much to displace actor up from tile (may not want this to be uniform...

            foreach (int ID in tile.ActorList)
            {
                SpriteClass actor = new SpriteClass(tile.X, tile.Y - (yOff * scale), scale);

                if (ID == TURTLE)
                {
                    actor.texture = turtle;
                }

                if (ID == TURTLEGANG)
                {
                    actor.texture = turtleGang;
                }

                if (ID == BADGER)
                {
                    actor.texture = badger;
                }

                // TODO try/catch for null texture, cause that can totally happen if ID is invalid
                actor.Draw(spriteBatch);
            }
        }
Example #2
0
 public void Draw(SpriteBatch spriteBatch, IsometricTile tile)
 {
     if (tile.TextureID == GRASS)
     {
         grass.Draw(spriteBatch);
     }
 }
        public IsometricMap(ContentManager content, GraphicsDevice graphicsDevice, Vector2 windowDimensions, int xLength, int yLength, int zLength, float scale)
        {
            this.xLength = xLength;
            this.yLength = yLength;
            this.zLength = zLength;
            this.scale   = scale;

            mouseHandler = new MouseHandler();

            lastKey = '_';

            tileMap       = new IsometricTile[xLength, yLength, zLength];
            tileMapIso    = new IsometricTile[xLength * 2 - 1, yLength *2 - 1, zLength];
            mapObjectList = new List <MapObject>();

            yCharacterOffset = 16 * scale;

            // load grass texture
            //grass = new SpriteClass(content, "tile-grass-no-detail", 0, 0, this.scale);
            //grass = new SpriteClass(content, "pixel-tile-deep", 0, 0, this.scale);
            grass = new SpriteClass(content, "pixel-tile-square", 0, 0, this.scale * .75f);

            int tileWidth  = (int)(grass.texture.Width * this.scale * .75f);
            int tileHeight = (int)(grass.texture.Height * this.scale * .75f);

            Vector2 boardDimensions = new Vector2(xLength * tileWidth, yLength * tileHeight);
            Vector2 startingPoint   = new Vector2(windowDimensions.X / 2 - boardDimensions.X / 2 - tileWidth / 2, windowDimensions.Y / 2 - boardDimensions.Y / 2 - tileHeight / 2);


            badger = new Badger(content, 3, 3, 0, scale);
            mapObjectList.Add(badger);

            for (int x = 0; x < xLength; x++)
            {
                for (int y = 0; y < yLength; y++)
                {
                    for (int z = 0; z < zLength; z++)
                    {
                        IsometricTile newTile;
                        if (z == 0 || x == 3 || y == 3)
                        {
                            newTile = new IsometricTile(1, 0, 0);
                        }

                        else
                        {
                            newTile = new IsometricTile(0, 0, 0);
                        }


                        newTile.X = startingPoint.X + x * tileWidth;
                        newTile.Y = startingPoint.Y + y * tileHeight;

                        tileMap[x, y, z] = newTile;
                        //tileMapIso[(int)iso.X, (int)iso.Y, z] = newTile;
                    }
                }
            }
        }
        public Boolean getTilePointCollision(IsometricTile tile, Vector2 point)
        {
            float halfTextureWidth  = grass.texture.Width / 2;
            float halfTextureHeight = grass.texture.Height / 2;

            if (point.X <= tile.X + halfTextureWidth && point.X >= tile.X - halfTextureWidth &&
                point.Y <= tile.Y + halfTextureHeight && point.Y >= tile.Y - halfTextureHeight)
            {
                return(true);
            }
            return(false);
        }
 public void DrawTiles(SpriteBatch spriteBatch)
 {
     for (int y = 0; y < yLength; y++)
     {
         for (int x = 0; x < xLength; x++)
         {
             IsometricTile curr = tileMap[x, y, 0];
             if (curr.TextureID == 1)
             {
                 grass.X = curr.X;
                 grass.Y = curr.Y;
                 grass.Draw(spriteBatch);
             }
         }
     }
 }