Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class I_piece
- {
- int x1, x2, x3, x4, y1, y2, y3, y4;
- uint rotation = 0;
- public Point Square1
- {
- get { return new Point(x1 * 30, y1 * 30); }
- }
- public Point Square2
- {
- get { return new Point(x2 * 30, y2 * 30); }
- }
- public Point Square3
- {
- get { return new Point(x3 * 30, y3 * 30); }
- }
- public Point Square4
- {
- get { return new Point(x4 * 30, y4 * 30); }
- }
- public void I_Piece()
- {
- x1 = 5;
- y1 = 0;
- x2 = 5;
- y2 = 1;
- x3 = 5;
- y3 = 2;
- x4 = 5;
- y4 = 3;
- State[x1, y1] = true;
- State[x2, y2] = true;
- State[x3, y3] = true;
- State[x4, y4] = true;
- }
- public void moveDown()
- {
- if(!State[x1, y1 + 1] && !State[x2, y2 + 1] && !State[x3, y3 + 1] && !State[x4, y4 + 1])
- {
- State[x1, y1] = false;
- State[x2, y2] = false;
- State[x3, y3] = false;
- State[x4, y4] = false;
- y1++;
- y2++;
- y3++;
- y4++;
- State[x1, y1] = true;
- State[x2, y2] = true;
- State[x3, y3] = true;
- State[x4, y4] = true;
- }
- else
- {
- //get next piece
- }
- }
- public void rotateLeft()
- {
- if (rotation == 0)
- {
- if (!State[x1 - 2, y1 + 2] && !State[x2 - 1, y2 + 1] && !State[x4 + 1, y4 - 1])
- {
- State[x1, y1] = false;
- State[x2, y2] = false;
- State[x4, y4] = false;
- x1 = x1 - 2;
- y1 = y1 + 2;
- x2 = x2 - 1;
- y2 = y2 + 1;
- x4 = x4 + 1;
- y4 = y4 - 1;
- State[x1, y1] = true;
- State[x2, y2] = true;
- State[x4, y4] = true;
- }
- else
- {
- //shift to avoid collision
- }
- }
- if (rotation == 1)
- {
- if (!State[x1 + 2, y1 + 2] && !State[x2 + 1, y2 + 1] && !State[x4 - 1, y4 - 1])
- {
- State[x1, y1] = false;
- State[x2, y2] = false;
- State[x4, y4] = false;
- x1 = x1 + 2;
- y1 = y1 + 2;
- x2 = x2 + 1;
- y2 = y2 + 1;
- x4 = x4 - 1;
- y4 = y4 - 1;
- State[x1, y1] = true;
- State[x2, y2] = true;
- State[x4, y4] = true;
- }
- else
- {
- //shift to avoid collision
- }
- }
- if (rotation == 2)
- {
- if (!State[x1 + 2, y1 - 2] && !State[x2 + 1, y2 - 1] && !State[x4 - 1, y4 + 1])
- {
- State[x1, y1] = false;
- State[x2, y2] = false;
- State[x4, y4] = false;
- x1 = x1 + 2;
- y1 = y1 - 2;
- x2 = x2 + 1;
- y2 = y2 - 1;
- x4 = x4 - 1;
- y4 = y4 + 1;
- State[x1, y1] = true;
- State[x2, y2] = true;
- State[x4, y4] = true;
- }
- else
- {
- //shift to avoid collision
- }
- }
- if (rotation == 3)
- {
- if (!State[x1 - 2, y1 - 2] && !State[x2 - 1, y2 - 1] && !State[x4 + 1, y4 + 1])
- {
- State[x1, y1] = false;
- State[x2, y2] = false;
- State[x4, y4] = false;
- x1 = x1 - 2;
- y1 = y1 - 2;
- x2 = x2 - 1;
- y2 = y2 - 1;
- x4 = x4 + 1;
- y4 = y4 + 1;
- State[x1, y1] = true;
- State[x2, y2] = true;
- State[x4, y4] = true;
- }
- else
- {
- //shift to avoid collision
- }
- }
- }
- public void rotateRight()
- {
- if (rotation == 0)
- {
- if (!State[x1 + 2, y1 + 2] && !State[x2 + 1, y2 + 1] && !State[x4 - 1, y4 - 1])
- {
- State[x1, y1] = false;
- State[x2, y2] = false;
- State[x4, y4] = false;
- x1 = x1 + 2;
- y1 = y1 + 2;
- x2 = x2 + 1;
- y2 = y2 + 1;
- x4 = x4 - 1;
- y4 = y4 - 1;
- State[x1, y1] = true;
- State[x2, y2] = true;
- State[x4, y4] = true;
- }
- else
- {
- //shift to avoid collision
- }
- }
- if (rotation == 1)
- {
- if (!State[x1 + 2, y1 - 2] && !State[x2 + 1, y2 - 1] && !State[x4 - 1, y4 + 1])
- {
- State[x1, y1] = false;
- State[x2, y2] = false;
- State[x4, y4] = false;
- x1 = x1 + 2;
- y1 = y1 - 2;
- x2 = x2 + 1;
- y2 = y2 - 1;
- x4 = x4 - 1;
- y4 = y4 + 1;
- State[x1, y1] = true;
- State[x2, y2] = true;
- State[x4, y4] = true;
- }
- else
- {
- //shift to avoid collision
- }
- }
- if (rotation == 2)
- {
- if (!State[x1 + 2, y1 + 2] && !State[x2 + 1, y2 + 1] && !State[x4 - 1, y4 - 1])
- {
- State[x1, y1] = false;
- State[x2, y2] = false;
- State[x4, y4] = false;
- x1 = x1 + 2;
- y1 = y1 + 2;
- x2 = x2 + 1;
- y2 = y2 + 1;
- x4 = x4 - 1;
- y4 = y4 - 1;
- State[x1, y1] = true;
- State[x2, y2] = true;
- State[x4, y4] = true;
- }
- else
- {
- //shift to avoid collision
- }
- }
- if (rotation == 3)
- {
- if (!State[x1 - 2, y1 + 2] && !State[x2 - 1, y2 + 1] && !State[x4 + 1, y4 - 1])
- {
- State[x1, y1] = false;
- State[x2, y2] = false;
- State[x4, y4] = false;
- x1 = x1 - 2;
- y1 = y1 + 2;
- x2 = x2 - 1;
- y2 = y2 + 1;
- x4 = x4 + 1;
- y4 = y4 - 1;
- State[x1, y1] = true;
- State[x2, y2] = true;
- State[x4, y4] = true;
- }
- else
- {
- //shift to avoid collision
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement