home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
games
/
volume6
/
connect4
/
screen.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-07-06
|
3KB
|
183 lines
#include <stdio.h>
#include <curses.h>
#include "c4.h"
#define BASEY 0
#define BASEX 0
#define LINE0 " 0 1 2 3 4 5 6 "
#define LINE1 ".-------------------------------------------------------."
#define LINE2 "| | | | | | | |"
#define LINE3 "|-------+-------+-------+-------+-------+-------+-------|"
#define LINE4 "`-------------------------------------------------------'"
char *filler[] = {"XXXXXXX", "OOOOOOO" };
static int row_levels[] = {5, 5, 5, 5, 5, 5, 5};
void
init_screen()
{
initscr();
crmode();
noecho();
plot_screen();
}
void
plot_screen()
{
register int i;
register int j;
clear();
move(0,60);
standout();
printw("C O N N E C T 4");
standend();
move(4,60);
printw(" YOUR MOVE: ");
move(7,60);
printw(" MY MOVE: ");
move(BASEY,BASEX);
printw(LINE0);
move(BASEY+1,BASEX);
printw(LINE1);
for (i = 0; i < 6; i++){
for (j = 0; j < 2; j++){
move(BASEY + 2 + 3*i + j , BASEX);
printw(LINE2);
}
move(BASEY + 4 + 3*i , BASEX);
printw(LINE3);
}
move(BASEY + 19, BASEX);
printw(LINE4);
refresh();
}
void
show_move(column, who)
int column;
int who;
{
int row;
int other_row;
if (who == OURS){
row = 7;
other_row = 4;
}
else{
row = 4;
other_row = 7;
}
move(row, 73);
printw("%1d",column);
move(other_row, 73);
printw(" ");
move(other_row, 73);
refresh();
}
void
accept_move(who)
int who;
{
int row;
if (who == OURS)
row = 7;
else
row = 4;
move(row, 73);
printw(" ");
move(row, 73);
refresh();
}
/* VARARGS1 */
void
report(fmt, a, b, c, d, e, f)
char *fmt;
char *a, *b, *c, *d, *e, *f;
{
move(22, 0);
printw(fmt, a, b, c, d, e, f);
refresh();
}
void
plot_finish()
{
move(23,0);
refresh();
nocrmode();
echo();
}
void
fill_column(column, colour)
int column;
int colour;
{
register int i;
register int row;
row = row_levels[column];
row_levels[column]--;
for (i = 2; i < 4; i++){
move(BASEY + i + 3*row, BASEX + 1 + 8*column);
if (colour == OURS) {
standout();
printw(filler[colour]);
standend();
}
else{
printw(filler[colour]);
}
}
refresh();
}
void
fill_square(square, colour)
int square;
int colour;
{
register int i;
register int row;
register int column;
row = square / 7;
column = square % 7;
for (i = 2; i < 4; i++){
move(BASEY + i + 3*row, BASEX + 1 + 8*column);
if (colour == OURS) {
standout();
printw(filler[colour]);
standend();
}
else{
printw(filler[colour]);
}
}
refresh();
}
void
reset_row_levels()
{
register int i;
for (i = 0; i < COLUMNS; i++){
row_levels[i] = 5;
}
}