Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Legend {
- // The coordinates for the blocks that form a piece are stored in block[][]
- // x,y positions are stored in the 4 keys.
- int block[][] = new int[4][2];
- // The 3 red, green, blue colors for the piece.
- int color[] = new int[3];
- public Legend(int x0, int y0, int x1, int y1, int x2, int y2, /**/ int c0, int c1, int c2) {
- color[0] = c0;
- color[1] = c1;
- color[2] = c2;
- block[0][0] = 0;
- block[0][1] = 0;
- block[1][0] = x0;
- block[1][1] = y0;
- block[2][0] = x1;
- block[2][1] = y1;
- block[3][0] = x2;
- block[3][1] = y2;
- }
- // Fetch data for the main class
- // the block number, x or y pos, amount rotation (in quarters)
- public int fetch(int i, int a, int rotate) {
- // Too complex to explain. It basically swaps the values and negativity depending
- // if it's the x or y position that is requested
- int a_rot = 1;
- int b_rot = 0;
- int neg_a = 1;
- int neg_b = -1;
- if (a == 1) {
- a_rot = 0;
- b_rot = 1;
- neg_a = -1;
- neg_b = 1;
- }
- // Return the x or y coordinate that corresponds to the amount of rotation
- switch (rotate) {
- case 1:
- return neg_a*block[i][a_rot];
- case 2:
- return neg_a*neg_b*block[i][b_rot];
- case 3:
- return neg_b*block[i][a_rot];
- }
- return block[i][a];
- }
- // Fetch the color. R, G or B.
- public int fetchColor(int i) {
- return color[i];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement