Exemplo n.º 1
0
Arquivo: World.cs Projeto: 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)));
        }
Exemplo n.º 2
0
Arquivo: Game.cs Projeto: 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();
        }
Exemplo n.º 3
0
Arquivo: World.cs Projeto: 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)));
 }