예제 #1
0
 public void RefreshBackground(Field[,] fields)
 {
     background = new Cairo.ImageSurface (Cairo.Format.ARGB32, width * fieldSize, height * fieldSize);
     using (Cairo.Context context = new Cairo.Context(background)) {
         paintBackground (context, fields);
     }
 }
예제 #2
0
파일: Sniffer.cs 프로젝트: Teyras/Bounce
 protected Direction getDirection(Field from, Field to)
 {
     if (from.X > to.X) {
         return Direction.Left;
     } else if (from.X < to.X) {
         return Direction.Right;
     } else if (from.Y > to.Y) {
         return Direction.Up;
     } else if (from.Y < to.Y) {
         return Direction.Down;
     }
     return Direction.None;
 }
예제 #3
0
 protected void paintBackground(Cairo.Context context, Field[,] fields)
 {
     context.SetSourceRGB (0.8, 0.8, 0.8);
     context.Paint ();
     for (int i = 0; i < width; i++) {
         for (int j = 0; j < height; j++) {
             paintSquare (context, i * fieldSize, j * fieldSize, fields [i, j].Full);
         }
     }
     paintGrid (context);
     context.Paint ();
 }
예제 #4
0
파일: Board.cs 프로젝트: Teyras/Bounce
 public NeighbourMap(Field current, IEnumerable<Field> neighbours)
 {
     this.Current = current;
     foreach (Field neighbour in neighbours) {
         if (neighbour.X == current.X - 1) {
             Left = neighbour;
         }
         if (neighbour.X == current.X + 1) {
             Right = neighbour;
         }
         if (neighbour.Y == current.Y - 1) {
             Up = neighbour;
         }
         if (neighbour.Y == current.Y + 1) {
             Down = neighbour;
         }
     }
 }
예제 #5
0
파일: Board.cs 프로젝트: Teyras/Bounce
 public IEnumerable<Field> GetNeighbours(Field field)
 {
     if (field.X > 0) {
         yield return fields [field.X - 1, field.Y];
     }
     if (field.X + 1 < Width) {
         yield return fields [field.X + 1, field.Y];
     }
     if (field.Y > 0) {
         yield return fields [field.X, field.Y - 1];
     }
     if (field.Y + 1 < Height) {
         yield return fields [field.X, field.Y + 1];
     }
 }
예제 #6
0
파일: Board.cs 프로젝트: Teyras/Bounce
 public void Clear()
 {
     balls = new List<Ball> ();
     monsters = new List<Monster> ();
     fields = new Field[Width, Height];
     for (int i = 0; i < Width; i++) {
         for (int j = 0; j < Height; j++) {
             fields [i, j] = new Field ();
             if (i == 0 || j == 0 || i + 1 == Width || j + 1 == Height) {
                 fields [i, j].Full = true;
             } else {
                 fields [i, j].Full = false;
             }
             fields [i, j].X = i;
             fields [i, j].Y = j;
         }
     }
     Player = new Player (0, 0);
     Player.BaseField = fields [0, 0];
     renderer.RefreshBackground (fields);
 }