#include "defs.h" static short icon_image[] = { #include "autotetris.icon" }; mpr_static(tetris_icon, 64, 64, 1, icon_image); main(argc, argv) int argc; char **argv; { Display *dpy; int i; Icon icon; name = "AutoTetris, v 3"; xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0); icon = icon_create(ICON_IMAGE, &tetris_icon, 0); mainframe = xv_create(NULL, FRAME, XV_LABEL, "Auto Tetris -- Weiser@parc", FRAME_ICON, icon, FRAME_ARGS, argc, argv, XV_WIDTH, UWIDTH*UNIT, XV_HEIGHT, UHEIGHT*UNIT*2, 0); dpy = (Display *)xv_get(mainframe, XV_DISPLAY); if (DefaultDepth(dpy, DefaultScreen(dpy) ) < 2 ) { color = 0; } else { color = 1; } panel = xv_create(mainframe, PANEL, 0); score_item = xv_create(panel, PANEL_MESSAGE, PANEL_LABEL_STRING, "Score: 0 ", 0); level_item = xv_create(panel, PANEL_MESSAGE, PANEL_LABEL_STRING, "Level: 0 ", 0); rows_item = xv_create(panel, PANEL_MESSAGE, PANEL_LABEL_STRING, "rows : 0 ", 0); game_over = xv_create(panel, PANEL_MESSAGE, PANEL_LABEL_BOLD, TRUE, PANEL_LABEL_STRING, "Game Over", XV_SHOW, FALSE, 0); xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Start", PANEL_NOTIFY_PROC, start_proc, 0); xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Pause", PANEL_NOTIFY_PROC, pause_proc, 0); xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "New Game", PANEL_NOTIFY_PROC, restart_proc, 0); xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Scores", PANEL_NOTIFY_PROC, print_high_scores, 0); xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Quit", PANEL_NOTIFY_PROC, quit_proc, 0); xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "About", PANEL_NOTIFY_PROC, about_proc, 0); xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Control Panel", PANEL_NOTIFY_PROC, control_panel_proc, 0); xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Adversary Panel", PANEL_NOTIFY_PROC, adversary_panel_proc, 0); window_fit_height(panel); canvas = xv_create(mainframe, CANVAS, WIN_X, 0, WIN_BELOW, panel, XV_WIDTH, UWIDTH * UNIT + 8 /* 8 for borders */, XV_HEIGHT, UHEIGHT * UNIT + SHADOW_HEIGHT + NEXT_HEIGHT, WIN_EVENT_PROC, canvas_event_proc, /* WIN_DYNAMIC_VISUAL, TRUE, */ 0); pw = canvas_pixwin(canvas); setup_colours(pw); window_fit(canvas); window_fit(mainframe); initautocontrol(); initialise(); score_frame = xv_create(mainframe, FRAME, WIN_SHOW, FALSE, 0); score_panel = xv_create(score_frame, PANEL, XV_WIDTH, xv_cols(score_frame, 132), XV_HEIGHT, xv_rows(score_frame, HIGH_TABLE_SIZE+3), 0); for (i = 0; i < HIGH_TABLE_SIZE; i++){ high_score_item[i] = xv_create(score_panel, PANEL_MESSAGE, XV_X, xv_col(score_panel, 0), XV_Y, i >= HIGH_TABLE_SIZE - LOW_SCORES ? xv_row(score_panel, i+3) : xv_row(score_panel, i+2), PANEL_LABEL_STRING, " ", 0); } high_score_label_item = xv_create(score_panel, PANEL_MESSAGE, XV_X, xv_col(score_panel, 0), XV_Y, xv_row(score_panel, 1), PANEL_LABEL_STRING, " ", 0); xv_set(high_score_label_item, PANEL_LABEL_BOLD, TRUE, PANEL_LABEL_STRING, "Pos Name Score Rows Lev Machine When seed row flt var hol ovr fis exp pro tim", 0); xv_create(score_panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, panel_button_image(score_panel, "done", 0, 0), PANEL_NOTIFY_PROC, done_proc, XV_X, xv_col(score_panel, 0), XV_Y, xv_row(score_panel, 0), 0); window_fit(score_panel); window_fit(score_frame); initadversary(); init_timer(); window_main_loop(mainframe); exit(0); } void about_proc() { Frame aboutframe; Textsw aboutwindow; aboutframe = xv_create(mainframe, FRAME, FRAME_SHOW_LABEL, TRUE, XV_LABEL, "Autotetris 'about' message.", 0); aboutwindow = xv_create(aboutframe, TEXTSW, TEXTSW_CONTENTS, about_string(), TEXTSW_READ_ONLY, TRUE, TEXTSW_LINE_BREAK_ACTION, TEXTSW_WRAP_AT_WORD, WIN_ROWS, 8, 0); window_fit(aboutwindow); window_fit(aboutframe); xv_set(aboutframe, WIN_SHOW, TRUE, 0); }