示例#1
0
 private Program()
 {
     _map = MapLoader.LoadMap();
     PerlinApp.Start(_map.Width * Tiles.TileWidth,
                     _map.Height * Tiles.TileWidth,
                     "Dungeon Crawl",
                     OnStart);
 }
示例#2
0
 /// <summary>
 /// Entry point
 /// </summary>
 public static void Main()
 {
     PerlinApp.Start(
         Globals.WindowWidth,
         Globals.WindowHeight,
         "Snake Game",
         OnInit);
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Program"/> class.
 /// </summary>
 public Program()
 {
     PerlinApp.Start(
         (int)(Width * _cellSize),
         (int)(Height * _cellSize),
         "Snake Game",
         OnInit);
 }
示例#4
0
 private Program()
 {
     _map = MapLoader.LoadMap();
     PerlinApp.Start(
         _map.Width * Tiles.TileWidth,
         _map.Height * Tiles.TileWidth,
         "Codecool Quest",
         OnStart);
 }
示例#5
0
        private Program()
        {
            var(width, height) = MapLoader.GetMapDimensions();

            PerlinApp.Start(width * TileSet.Size * TileSet.Scale,
                            height * TileSet.Size * TileSet.Scale,
                            "Dungeon Crawl",
                            OnStart);
        }
示例#6
0
        /// <summary>
        ///     Entry point
        /// </summary>
        public static void Main()
        {
            var(width, height) = MapLoader.GetMapDimensions();

            PerlinApp.Start(width * TileSet.Size * TileSet.Scale,
                            height * TileSet.Size * TileSet.Scale,
                            "Dungeon Crawl",
                            OnStart);
        }
示例#7
0
        private void OnInit()
        {
            PerlinApp.Stage.BackgroundColor = new Rgb24(200, 200, 200);
            //TextFieldTests();
            //TestDragging();
            //TestTextureSubRegion();
            //TestTransparency();

            // sample snake game
            var scoreTextField = new TextField(PerlinApp.FontRobotoMono.CreateFont(18));

            scoreTextField.BackgroundColor = Color.Coral;
            scoreTextField.X         = 260;
            scoreTextField.Y         = 5;
            scoreTextField.FontColor = Color.White;
            PerlinApp.Stage.AddChild(scoreTextField);
            var highScore = 0;
            var worldSize = new Vector2(Width, Height);
            var world     = new World(worldSize, _cellSize);
            var snake     = new Snake(world);

            snake.ScoreChanged += () => scoreTextField.Text = snake.Score.ToString();
            snake.ScoreChanged += () => highScore = Math.Max(highScore, snake.Score);
            var headPath = Path.Combine(AppContext.BaseDirectory, "Assets", "snake-head.png");
            var bodyPath = Path.Combine(AppContext.BaseDirectory, "Assets", "snake-3.png");

            var s2 = new Sprite(headPath)
            {
                X = 150, Y = 150
            };
            var s3 = new Sprite(headPath)
            {
                X = 0, Y = 50
            };
            var s4 = new Sprite(bodyPath)
            {
                X = 0, Y = 30
            };

            s2.ScaleX   = 2;
            s2.PivotX   = 8;
            s2.PivotY   = 8;
            s3.Rotation = 6f;
            PerlinApp.Stage.AddChild(s2);
            s2.AddChild(s3);
            s3.AddChild(s4);
            int a = 1;

            PerlinApp.Stage.EnterFrameEvent += (target, secs) =>
            {
                s2.Rotation += 1f;
                a++;
                if (a > 99)
                {
                    a = 0;
                }
                // Console.WriteLine(s2.Rotation + " " + s2.GetBoundsWithChildren().Width);
            };

            PerlinApp.ShowStats(HorizontalAlignment.Right, VerticalAlignment.Bottom);
        }