home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
games
/
volume6
/
sun-tetris2
/
notify.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-07-06
|
4KB
|
142 lines
#include "defs.h"
Notify_value
drop_block(me, which)
Notify_client me;
int which;
{
if (block_can_drop(shape_no, xpos, ypos, rot))
print_shape(shape_no, xpos, ypos++, rot, WHITE);
else {
if (ypos < 0)
end_game();
else {
score += shape[shape_no].pointv[rot];
store_shape(shape_no, xpos, ypos, rot);
remove_full_lines(ypos);
create_shape();
show_score();
show_next();
}
}
print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
return (NOTIFY_DONE);
}
show_score()
{
char buf[BUFSIZ], buf1[BUFSIZ], buf2[BUFSIZ];
sprintf(buf, "Score: %d", score);
panel_set(score_item, PANEL_LABEL_STRING, buf, 0);
sprintf(buf1, "Level: %d", rows / 10);
panel_set(level_item, PANEL_LABEL_STRING, buf1, 0);
sprintf(buf2, "Rows : %d", rows);
panel_set(rows_item, PANEL_LABEL_STRING, buf2, 0);
}
void
quit_proc()
{
clear_events();
stop_timer();
window_destroy(frame);
}
end_game()
{
end_of_game = 1;
clear_events();
stop_timer();
panel_set(game_over, PANEL_SHOW_ITEM, TRUE, 0);
update_highscore_table();
print_high_scores();
}
void
restart_proc()
{
clear_events();
stop_timer();
init_all();
}
void
start_proc()
{
if (end_of_game)
return;
set_events();
start_timer();
}
void
pause_proc()
{
clear_events();
stop_timer();
}
left_proc()
{
if (block_can_left(shape_no, xpos, ypos, rot)) {
print_shape(shape_no, xpos, ypos, rot, WHITE);
xpos--;
print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
}
}
right_proc()
{
if (block_can_right(shape_no, xpos, ypos, rot)) {
print_shape(shape_no, xpos, ypos, rot, WHITE);
xpos++;
print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
}
}
anti_proc()
{
int newrot;
newrot = (rot + 3) % 4;
if (check_rot(shape_no, xpos, ypos, newrot)) {
print_shape(shape_no, xpos, ypos, rot, WHITE);
rot = newrot;
print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
}
}
clock_proc()
{
int newrot;
newrot = (rot + 1) % 4;
if (check_rot(shape_no, xpos, ypos, newrot)) {
print_shape(shape_no, xpos, ypos, rot, WHITE);
rot = newrot;
print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
}
}
fast_proc()
{
while (block_can_drop(shape_no, xpos, ypos, rot)) {
print_shape(shape_no, xpos, ypos, rot, WHITE);
ypos++;
print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
}
}
void
done_proc()
{
window_set(score_frame, WIN_SHOW, FALSE, 0);
}