Esempio n. 1
0
File: World.cs Progetto: K0bin/Snake
        public World(Game game, IRenderItemFactory factory, GameRules rules)
        {
            this.game = game;
            this.factory = factory;

            Head = new SnakeHead(game, factory);
            CreateWorld(game, factory, rules, rules.WorldSize);

            Random random = new Random();
            Treat = new Treat(game, factory, new Vector2I(random.Next(1, rules.WorldSize.X - 1), random.Next(1, rules.WorldSize.Y - 1)));
        }
Esempio n. 2
0
File: Game.cs Progetto: K0bin/Snake
        public void Start()
        {
            Score = 0;
            Rules = new GameRules()
            {
                Duration = 32,
                SnakeStartPosition = new Vector2I(6, 6),
                WorldSize = new Vector2I(8, 8),
                IsDegenerativeSpeedEnabled = true,
                DegenerativeSpeed = 1.1f,
                DegenerativeSpeedMax = 128
            };

            world = new World(this, factory, Rules);

            watch.Start();
        }
Esempio n. 3
0
File: World.cs Progetto: K0bin/Snake
 private void CreateWorld(Game game, IRenderItemFactory factory, GameRules rules, Vector2I size)
 {
     for (int x = 0; x < size.X; x++)
         for (int y = 0; y < size.Y; y++)
             if ((x == 0 || x == size.X - 1) || (y == 0 || y == size.Y - 1))
                 blocks.Add(new Block(game, factory, new Vector2I(x, y)));
 }