Advertisement
Guest User

tetrise kontroll

a guest
Mar 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. bool block::checker(int nxloc, int xyloc, const* screen, int deltad = 0){
  2.     if ((dir+deltad)==0 && (xloc+dist_right)<xlen &&
  3.     (xloc-dist_left)>=0 && (yloc+dist_down)>=0){
  4.         for (int y=0;y<5;y++){
  5.             for (int x=0;x<5;x++){
  6.                 int absx = (xloc+x)-3;
  7.                 int absy = (yloc+y)-3;
  8.                 if (blueprint[y][x] && screen[absy][absx] == staticTetrimino){
  9.                     return false;
  10.                 }
  11.             }
  12.         }
  13.     } else if ((dir+deltad)==1 && (xloc+dist_up)<xlen &&
  14.     (xloc-dist_down)>=0 && (yloc+dist_right)>=0){
  15.         for (int y=0;y<5;y++){
  16.             for (int x=0;x<5;x++){
  17.                 int absx = (xloc+x)-3;
  18.                 int absy = (yloc+y)-3;
  19.                 if (blueprint[x][5-y] && screen[absy][absx] == staticTetrimino){
  20.                     return false;
  21.                 }
  22.             }
  23.         }
  24.     } else if ((dir+deltad)==2 && (xloc+dist_left)<xlen &&
  25.     (xloc-dist_right)>=0 && (yloc+dist_up)>=0){
  26.         for (int y=0;y<5;y++){
  27.             for (int x=0;x<5;x++){
  28.                 int absx = (xloc+x)-3;
  29.                 int absy = (yloc+y)-3;
  30.                 if (blueprint[5-y][5-x] && screen[absy][absx] == staticTetrimino){
  31.                     return false;
  32.                 }
  33.             }
  34.         }
  35.     } else if ((dir+deltad)==3 && (xloc+dist_down)<xlen &&
  36.     (xloc-dist_up)>=0 && (yloc+dist_left)>=0){
  37.         for (int y=0;y<5;y++){
  38.             for (int x=0;x<5;x++){
  39.                 int absx = (xloc+x)-3;
  40.                 int absy = (yloc+y)-3;
  41.                 if (blueprint[5-x][5-y] && screen[absy][absx] == staticTetrimino){
  42.                     return false;
  43.                 }
  44.             }
  45.         }
  46.     }
  47.     return true;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement