public void Move(int offset, Direction dir) { if (dir == Direction.right) x = x + offset; else if (dir == Direction.left) x = x - offset; else if (dir == Direction.up) y = y - offset; else if (dir == Direction.down) y = y + offset; }
public void HandlKey(ConsoleKey key) { if (key == ConsoleKey.LeftArrow) { direct = Direction.left; } else { if (key == ConsoleKey.RightArrow) { direct = Direction.right; } else { if (key == ConsoleKey.DownArrow) { direct = Direction.down; } else { direct = Direction.up; } } } }
public void Move(int offset, Direction direct) { if (direct == Direction.right) { x = x + offset; } else { if (direct == Direction.left) { x = x - offset; } else { if (direct == Direction.up) { y = y - offset; } else { y = y + offset; } } } }
public override bool CanStand(Creature creature, Direction direction) { creature.X += direction.dx; creature.Y += direction.dy; creature.Lifes++; return true; }
public Snape(Point tail , int lenght , Direction _direction) { direction = _direction; pLine = new List<Point>(); for(int i = 0 ; i< lenght; i++) { Point p = new Point(tail); p.Move(i, _direction); pLine.Add(p); } }
public void HandleKey(ConsoleKey key) { if (key == ConsoleKey.LeftArrow) dir = Direction.left; if (key == ConsoleKey.RightArrow) dir = Direction.right; if (key == ConsoleKey.UpArrow) dir = Direction.up; if (key == ConsoleKey.DownArrow) dir = Direction.down; }
public Snake(Point tail, int lenght, Direction _dir) { dir = _dir; pList = new List<Point>(); for (int i = 0; i < lenght; i++) { Point p = new Point(tail); p.Move(i, dir); pList.Add(p); } }
public Snake(Point tail, int length, Direction _direct) { PointList = new List<Point>(); direct = _direct; for (int i = 0; i < length; i++) { Point p = new Point(tail); p.Move(i, direct); PointList.Add(p); } }
public void HandleKey (ConsoleKey key) { if (key == ConsoleKey.LeftArrow) direction = Direction.LEFT; else if (key == ConsoleKey.RightArrow) direction = Direction.RIGHT; else if (key == ConsoleKey.UpArrow) direction = Direction.UP; else if (key == ConsoleKey.DownArrow) direction = Direction.DOWN; }
public void Move(int offset, Direction direction) { if (direction == Direction.LEFT) x = x - offset; else if (direction == Direction.RIGHT) x = x + offset; else if (direction == Direction.UP) y = y - offset; else if (direction == Direction.DOWN) y = y + offset; }
public bool TryToMove(Creature creature, Direction direction) { while(creature.IsAlive()) { var result = map[creature.X + direction.dx, creature.Y + direction.dy].CanStand(creature, direction); if (result) OnChanged(EventArgs.Empty); return result; } Console.WriteLine("Move is impossible. {0} is dead", creature.Name); return false; }
public void SwitchDirection(Direction.Dir newDir) { switch (newDir) { case Direction.Dir.Up: NewHeadCoord.Y--; break; case Direction.Dir.Right: NewHeadCoord.X++; break; case Direction.Dir.Down: NewHeadCoord.Y++; break; default: NewHeadCoord.X--; break; } }
public bool Down(Direction direction) { return KeyInfo.Key == ConsoleKey.DownArrow && direction.LastDirection != Direction.Dir.Up; }
public abstract bool CanStand(Creature creature, Direction direction);
public override bool CanStand(Creature creature, Direction direction) { return false; }
public static void PlaceOnBoard(string word, Position pos, Direction dir) { int x = pos.X; int y = pos.Y; for (int i = 0; i < word.Length; i++) { switch (dir) { case Direction.Down: Board[y + i][x] = word[i]; break; case Direction.Left: Board[y][x - i] = word[i]; break; case Direction.Right: Board[y][x + i] = word[i]; break; case Direction.Up: Board[y - i][x] = word[i]; break; } } }
public bool Up(Direction direction) { return KeyInfo.Key == ConsoleKey.UpArrow && direction.LastDirection != Direction.Dir.Down; }
private void Initiliaze() { GameIsPlaying = true; Paused = false; AppleEaten = false; TailCoordsList = new List<Coord>(); PlayField = new PlayField(TailCoordsList); Tick = new Stopwatch(); Renderer = new SnakeRenderer(); Player = new Snake(TailCoordsList); Direction = new Direction(); Tick.Start(); UpdatePlayField(); }
public bool Right(Direction direction) { return KeyInfo.Key == ConsoleKey.RightArrow && direction.LastDirection != Direction.Dir.Left; }