|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T c
Length: 3597 (0xe0d) Types: TextFile Names: »check_block.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Tetris/check_block.c«
/* ** written by adam margulies vespa@ssyx.ucsc.edu ** {...}!ucbvax!ucscc!ssyx!vespa ** ** permission is granted to freely distribute this code provided that you: ** ** 1) don't charge for it ** 2) leave my name and header on it ** 3) clearly document your changes and place your name on them ** */ /* Tetris: check_block() */ /* */ /* checks to make sure that the moving shape can proceed to the next */ /* line on the screen. the function returns 0 if the shape can't move */ /* on to the line below, 1 otherwise. */ #include "tetris.h" int check_block() { int x = curx, y = cury, sh = current->shape, rt = current->rot; if (y > (21 - current->height)) /* reached bottom of screen */ return(0); /* These lines check to make sure that the next line is clear */ if (shape[sh].table[3][rt] & 8 && window0[y+4][x] != ' ') return(0); if (shape[sh].table[3][rt] & 4 && window0[y+4][x+1] != ' ') return(0); if (shape[sh].table[3][rt] & 2 && window0[y+4][x+2] != ' ') return(0); if (shape[sh].table[3][rt] & 1 && window0[y+4][x+3] != ' ') return(0); /* These lines check to make sure that line 2 of the shape doesn't snag */ if ((shape[sh].table[2][rt] & 8) && (window0[y+3][x] != ' ' && !(shape[sh].table[3][rt] & 8))) return(0); if (shape[sh].table[2][rt] & 4 && (window0[y+3][x+1] != ' ' && !(shape[sh].table[3][rt] & 4))) return(0); if (shape[sh].table[2][rt] & 2 && (window0[y+3][x+2] != ' ' && !(shape[sh].table[3][rt] & 2))) return(0); if (shape[sh].table[2][rt] & 1 && (window0[y+3][x+3] != ' ' && !(shape[sh].table[3][rt] & 1))) return(0); /* These lines check to make sure that line 1 of the shape doesn't snag */ if (y > -1) { if (shape[sh].table[1][rt] & 8 && window0[y+2][x] != ' ' && !(shape[sh].table[2][rt] & 8)) return(0); if (shape[sh].table[1][rt] & 4 && (window0[y+2][x+1] != ' ' && !(shape[sh].table[2][rt] & 4))) return(0); if (shape[sh].table[1][rt] & 2 && (window0[y+2][x+2] != ' ' && !(shape[sh].table[2][rt] & 2))) return(0); if (shape[sh].table[1][rt] & 1 && (window0[y+2][x+3] != ' ' && !(shape[sh].table[2][rt] & 1))) return(0); } /* These lines check to make sure that line 0 of the shape doesn't snag */ if (y > 0) { if (shape[sh].table[0][rt] & 8 && (window0[y+1][x] != ' ' && !(shape[sh].table[1][rt] & 8))) return(0); if (shape[sh].table[0][rt] & 4 && (window0[y+1][x+1] != ' ' && !(shape[sh].table[1][rt] & 4))) return(0); if (shape[sh].table[0][rt] & 2 && (window0[y+1][x+2] != ' ' && !(shape[sh].table[1][rt] & 2))) return(0); if (shape[sh].table[0][rt] & 1 && (window0[y+1][x+3] != ' ' && !(shape[sh].table[1][rt] & 1))) return(0); } /* successful drop, return */ return(1); }