예제 #1
0
파일: Shape.cs 프로젝트: Paradox97/Tetris
        private void rotation_transformation(List <shape_block> change_map, List <shape_block> orig_map, Field grid)
        {
            int delta_x = orig_map[this.center].x_coord;         //placing shape block at (0,0) for rotation simplicity then placing it back where it was, delta = current coordinates of the figure
            int delta_y = orig_map[this.center].y_coord;         //referring to the shape's centre

            for (int i = 0; i < SHAPE_SIZE; i++)
            {
                change_map.Add(new shape_block {
                    x_coord = orig_map[i].x_coord - delta_x, y_coord = orig_map[i].y_coord - delta_y
                });
            }

            for (int i = 0; i < SHAPE_SIZE; i++)
            {
                change_map[i] = new shape_block {
                    x_coord = change_map[i].y_coord, y_coord = SHAPE_SIZE - orig_map[i].x_coord
                };
            }

            int delta_new_x = Math.Abs(change_map[this.center].x_coord - delta_x); //offset - centre should be in the same location
            int delta_new_y = Math.Abs(change_map[this.center].y_coord - delta_y);

            for (int i = 0; i < SHAPE_SIZE; i++)
            {
                change_map[i] = new shape_block {
                    x_coord = change_map[i].x_coord + delta_new_x, y_coord = change_map[i].y_coord + delta_new_y
                };
            }
        }
예제 #2
0
파일: Shape.cs 프로젝트: Paradox97/Tetris
 private int check_self(shape_block change_map_part, List <shape_block> orig_map)  //if piece of the new map corresponds to original map
 {
     for (int i = 0; i < orig_map.Count; i++)
     {
         if ((orig_map[i].x_coord == change_map_part.x_coord) && (orig_map[i].y_coord == change_map_part.y_coord))
         {
             return(0);
         }
     }
     return(1);
 }
예제 #3
0
파일: Shape.cs 프로젝트: Paradox97/Tetris
        private void reposition(List <shape_block> change_map, List <shape_block> orig_map, Field grid)
        {
            for (int i = 0; i < SHAPE_SIZE; i++)
            {
                grid.area[orig_map[i].x_coord, orig_map[i].y_coord] = ' ';      //cleaning up figure trails
            }

            for (int i = 0; i < SHAPE_SIZE; i++)
            {
                orig_map[i] = new shape_block {
                    x_coord = change_map[i].x_coord, y_coord = change_map[i].y_coord
                };
                grid.area[change_map[i].x_coord, change_map[i].y_coord] = '#';
            }
        }