Beispiel #1
0
        protected override void Initialize()
        {
            UITexture = Content.Load<Texture2D> ("TDUserInterface.png", TextureConfiguration.Nearest);
            SpriteSheet = new SpriteSheet2D (Content.Load<Texture2D> ("TDSheet.png", TextureConfiguration.Nearest), 16, 16);

            TileMap = new TileMap (Vector2.Zero, 26 / 2, 18 / 2, new Vector2 (16, 16), 4);
            TileMap.AddLayer ("GrassLayer", SpriteSheet);

            for (int y = 0; y < TileMap.Height; y++)
                for (int x = 0; x < TileMap.Width; x++)
                    TileMap.SetTile ("GrassLayer", x, y, new Tile { TileId = SpriteSheet.GetTileId(1, 1) });

            TileMap.AddLayer ("Track", SpriteSheet);
            var tiles = new int[][] {
                new int[] { },
                new int[] { 20, 1, 1, 2 },
                new int[] { -1, -1, -1, 32, 1, 2 },
                new int[] { 0, 1, 2, -1, -1, 16, -1, 16 },
                new int[] { 16, -1, 16, -1, -1, 18, -1, 16 },
                new int[] { 16, -1, 32, 1, 1, 34, -1, 16 },
                new int[] { 16, -1, -1, -1, -1, -1, -1, 16 },
                new int[] { 32, 1, 1, 1, 1, 1, 1, 34 }
            };

            for (int y = 0; y < tiles.Length; y++)
                for (int x = 0; x < tiles[y].Length; x++)
                    TileMap.SetTile ("Track", x, y, new Tile { TileId = tiles[y][x] });

            Font = Content.Load<Font> ("durselinvenice2015.ttf", 15f);

            base.Initialize ();
        }
Beispiel #2
0
 public Bird(Game game, TubeGenerator generator)
 {
     this.game = game;
     this.generator = generator;
     var sheetTex = game.Content.Load<Texture2D> ("flappymascot_char.png", TextureConfiguration.Nearest);
     sheet = new SpriteSheet2D (sheetTex, 4, 1);
     animator = new Animator (sheet, 4);
     animator.DurationInMilliseconds = 500;
     animator.Position.X = game.Resolution.Width * 0.25f;
     ypos = (game.Resolution.Height / 2) + (sheet [0].Height / 2);
 }
Beispiel #3
0
        public TileMapLayer(SpriteSheet2D sheet, int width, int height, float scale)
        {
            Sheet = sheet;

            Width = width;
            Height = height;
            Scale = scale;

            Layers = new Tile[Width * Height];
            for (int i = 0; i < Width * Height; i++)
                Layers[i] = Tile.Default;
        }
Beispiel #4
0
        public TileMapLayer(SpriteSheet2D sheet, int width, int height, float scale)
        {
            Sheet = sheet;

            Width  = width;
            Height = height;
            Scale  = scale;

            Layers = new Tile[Width * Height];
            for (int i = 0; i < Width * Height; i++)
            {
                Layers[i] = Tile.Default;
            }
        }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="nginz.Animator"/> class.
 /// </summary>
 /// <param name="sheet">Sheet.</param>
 /// <param name="tileCount">Tile count.</param>
 /// <param name="startTile">Start tile.</param>
 public Animator(SpriteSheet2D sheet, int tileCount, int startTile = 0)
 {
     Sheet     = sheet;
     StartTile = startTile;
     Count     = tileCount;
     Index     = 0;
     Speed     = 1;
     Position  = Vector2.Zero;
     Scale     = Vector2.One;
     Tint      = Color4.White;
     Origin    = Vector2.Zero;
     RotationX = 0;
     UpdateTarget();
 }
Beispiel #6
0
        protected override void Initialize()
        {
            var version = Assembly.GetEntryAssembly ().GetName ().Version;
            batch = new SpriteBatch (this);
            tex = Content.Load<Texture2D> ("nginz.png", TextureConfiguration.Nearest);

            testSheet = new SpriteSheet2D (Content.Load<Texture2D> ("classical_ruin_tiles_1.png", TextureConfiguration.Nearest), 23, 16);
            testMap = new TileMap (new Vector2 (128, 256), 32, 32, new Vector2(32, 32), 2);
            testMap.AddLayer ("testLayer", testSheet);

            /*testMap.SetTile ("testLayer", 0, 1, 0);
            testMap.SetTile ("testLayer", 1, 1, 1);
            testMap.SetTile ("testLayer", 2, 1, 2);
            testMap.SetTile ("testLayer", 3, 1, 3);*/

            stage = new Stage (this);
            var mascot = new MascotActor ();
            stage.AddActor (mascot);
            stage.AddAction (mascot);
            stage.TileMap = testMap;

            base.Initialize ();
        }
Beispiel #7
0
 /// <summary>
 /// Add a layer.
 /// </summary>
 /// <param name="name">Name.</param>
 /// <param name="sheet">Sheet.</param>
 public void AddLayer(string name, SpriteSheet2D sheet)
 {
     Layers[name] = new TileMapLayer(sheet, Width, Height, Scale);
 }
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="nginz.Animator"/> class.
 /// </summary>
 /// <param name="sheet">Sheet.</param>
 /// <param name="tileCount">Tile count.</param>
 /// <param name="startTile">Start tile.</param>
 public Animator(SpriteSheet2D sheet, int tileCount, int startTile = 0)
 {
     Sheet = sheet;
     StartTile = startTile;
     Count = tileCount;
     Index = 0;
     Speed = 1;
     Position = Vector2.Zero;
     Scale = Vector2.One;
     Tint = Color4.White;
     Origin = Vector2.Zero;
     RotationX = 0;
     UpdateTarget ();
 }