示例#1
0
文件: Game.cs 项目: K0bin/Snake
 public Game(IRenderer renderer, IRenderItemFactory factory, IInput input, int targetFramerate)
 {
     this.targetFramerate = targetFramerate;
     this.renderer = renderer;
     this.input = input;
     this.factory = factory;
     Start();
 }
示例#2
0
文件: SnakeHead.cs 项目: K0bin/Snake
 public SnakeHead(Game game, IRenderItemFactory factory)
     : base(game, factory, new Vector2I(0, 0))
 {
     Direction = Game.Rules.SnakeStartDirection;
     direction = Direction;
     Position = Game.Rules.SnakeStartPosition;
     RenderItem = factory.CreateRenderItem(RenderItemType.SnakeHead);
 }
示例#3
0
文件: World.cs 项目: 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)));
        }
示例#4
0
文件: Field.cs 项目: K0bin/Snake
 public Field(Game game, IRenderItemFactory factory, Vector2I position)
 {
     Position = position;
     Game = game;
     Factory = factory;
 }
示例#5
0
文件: Treat.cs 项目: K0bin/Snake
 public Treat(Game game, IRenderItemFactory factory, Vector2I position)
     : base(game, factory, position)
 {
     RenderItem = factory.CreateRenderItem(RenderItemType.Treat);
 }
示例#6
0
文件: SnakeBody.cs 项目: K0bin/Snake
 public SnakeBody(Game game, IRenderItemFactory factory, Vector2I position)
     : base(game, factory, position)
 {
     RenderItem = factory.CreateRenderItem(RenderItemType.SnakeBody);
 }
示例#7
0
 public SpeedPowerup(Game game, IRenderItemFactory factory, Vector2I position)
     : base(game, factory, position)
 {
     RenderItem = factory.CreateRenderItem(RenderItemType.SpeedPowerup);
 }
示例#8
0
文件: Game.cs 项目: K0bin/Snake
 public Game(IRenderer renderer, IRenderItemFactory factory, IInput input)
     : this(renderer, factory, input, 60)
 {
 }
示例#9
0
文件: World.cs 项目: 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)));
 }