Exemple #1
0
        public Jumper()
        {
            Collision = CollisionType.A;

            MaxVelocity = new Vector2 {
                X = 300, Y = 450
            };

            Animations = new AnimationSheet(@"Textures\player", 64, 64);

            Animations.Add("idle", 1f, true, 0, 1);

            Animations.Add("run", 0.07f, true, 12, 13, 14, 15, 16, 17, 18, 19, 20);

            Animations.Add("jump", 0.09f, false, 21, 22);

            Animations.Add("wallSlide", 1f, true, 2);

            Index = PlayerIndex.One;

            // our player only has horizontal friction
            Friction = new Vector2(2000, 0);

            Settings["_feDrawBox"] = "true";

            BoundingBox = new HitBox {
                Height = 64, Width = 64
            };
        }
Exemple #2
0
        public void DrawMap(SpriteBatch spriteBatch)
        {
            if (_tileSetTextureIsDirty)
            {
                TileSetTexture = ContentCacheManager.GetTexture(TileSetTexturePath);

                TileSheet = new AnimationSheet(TileSetTexture, TileSize, TileSize);

                // add the animations
                for (int frame = 0; frame < TileSheet.TotalFrames; frame++)
                {
                    TileSheet.Add(frame, 1f, false, frame);
                }
            }

            if (TileSetTexture != null)
            {
                MapData.EachCell((cell, tile) =>
                {
                    // adjust the vector position according to the tilesize
                    cell *= TileSize;

                    // only draw tiles that have data
                    if (tile > -1)
                    {
                        TileSheet[tile].Draw(spriteBatch, cell, Color.White * Opacity);
                    }

                    if (DrawGrid)
                    {
                        var frame = new Rectangle((int)cell.X, (int)cell.Y, TileSize, TileSize);

                        var whiteTexture = new Texture2D(spriteBatch.GraphicsDevice, 1, 1);
                        whiteTexture.SetData(new Color[] { Color.White });

                        spriteBatch.Draw(whiteTexture, new Rectangle(frame.Left, frame.Top, frame.Width, 1), Color.White);
                        spriteBatch.Draw(whiteTexture, new Rectangle(frame.Left, frame.Bottom, frame.Width, 1), Color.White);
                        spriteBatch.Draw(whiteTexture, new Rectangle(frame.Left, frame.Top, 1, frame.Height), Color.White);
                        spriteBatch.Draw(whiteTexture, new Rectangle(frame.Right, frame.Top, 1, frame.Height + 1), Color.White);
                    }
                });
            }
        }