コード例 #1
0
ファイル: MainGame.cs プロジェクト: splitandthechro/nginz
        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 ();
        }
コード例 #2
0
ファイル: Bird.cs プロジェクト: splitandthechro/nginz
 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);
 }
コード例 #3
0
ファイル: TileMapLayer.cs プロジェクト: splitandthechro/nginz
        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;
        }
コード例 #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;
            }
        }
コード例 #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();
 }
コード例 #6
0
ファイル: MainGame.cs プロジェクト: splitandthechro/nginz
        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 ();
        }
コード例 #7
0
ファイル: TileMap.cs プロジェクト: parhelia512/nginz
 /// <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);
 }
コード例 #8
0
ファイル: Animator.cs プロジェクト: splitandthechro/nginz
 /// <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 ();
 }