|
|
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 d
Length: 2848 (0xb20)
Types: TextFile
Names: »drop_block.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Tetris/drop_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: drop_block() */
/* */
/* This function calls check_block() to make sure that the block */
/* can drop down the screen. If so it increments the current y */
/* position and calls print_shape() with a "color" of ' '. This */
/* erases the shape. If the player has not requested */
/* a "fast drop" or the block has reached the bottom then the */
/* function draws the shape with a call to print_shape() and returns. */
/* */
/* If check_block() shows that the shape has been blocked then it gets */
/* trickier. If the current y position is too high then the game is */
/* over (i.e. the player has not successfully negotiated the block */
/* past the top of the screen). A call to score() updates the score */
/* and a call to end_game() terminates the program. */
/* */
/* If the above is false then the program knows that the block has */
/* successfully come to rest. The call to score() is made to record */
/* the score and check_horiz() is called to clear any complete horiz */
/* lines then setup_next() is called to ready the next block. */
#include "tetris.h"
#include <sys/ioctl.h>
void drop_block()
{
void end_game(), check_horiz();
int num_char_pend;
ioctl(1, TIOCOUTQ, &num_char_pend); /* this checks the number of characters
pending on the terminal */
if (num_char_pend != 0)
return;
if (check_block()) {
cury++;
print_shape(current->shape, curx, cury-1, current->rot, ' ');
if (!fast_drop || (cury + current->height == 22))
print_shape(current->shape, curx, cury, current->rot,
current->color);
}
else {
if (cury < 2) {
if (fast_drop)
print_shape(current->shape, curx, cury, current->rot,
current->color);
score(cury + current->height - 1);
end_game();
}
else {
if (fast_drop)
print_shape(current->shape, curx, cury, current->rot,
current->color);
score(cury + current->height - 1);
check_horiz();
setup_next();
}
}
}