home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
games
/
volume6
/
sun-tetris2
/
init.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-07-06
|
2KB
|
52 lines
#include "defs.h"
#include <sys/types.h>
#include <sys/timeb.h>
#include <pwd.h>
initialise()
{
struct passwd *who;
int depth;
Pixrect *mem_create();
char *getenv();
srand((int) time((time_t *) 0));
define_shapes();
depth = pw->pw_prretained->pr_depth;
monochrome = 0;
if (depth == 1)
monochrome = 1;
if ((pr = mem_create(UNIT * UWIDTH, UNIT * UHEIGHT, depth)) == NULL) {
fprintf(stderr, "mem_create() returned NULL\n");
exit(-1);
}
if ((name = getenv("TETRIS")) == NULL) {
who = getpwuid(getuid());
name = who->pw_name;
}
print_authors();
init_all();
read_high_scores();
}
init_all()
{
int i, j;
score_position = -1;
end_of_game = 0;
rows = score = shape_no = rot = xpos = ypos = 0;
for (i = 0; i < UWIDTH; i++)
for (j = 0; j < UHEIGHT; j++)
grid[i][j] = 0;
create_shape(); /* Set up 1st shape */
create_shape(); /* Set up next shape */
pw_rop(pw, 0, 0, UNIT * UWIDTH, UNIT * UHEIGHT, PIX_SRC | PIX_COLOR(WHITE), NULL, 0, 0);
pw_vector(pw, 0, UHEIGHT * UNIT, UWIDTH * UNIT, UHEIGHT * UNIT, PIX_SRC | PIX_COLOR(BLACK), 0);
pw_vector(pw, 0, UHEIGHT * UNIT + SHADOW_HEIGHT, UWIDTH * UNIT, UHEIGHT * UNIT + SHADOW_HEIGHT, PIX_SRC | PIX_COLOR(BLACK), 0);
panel_set(game_over, PANEL_SHOW_ITEM, FALSE, 0);
show_score();
show_next();
draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
}