Black and white chess

xiaoxiao2021-03-05  46

#include #include #define off 0 # define on 1 # define isvalid (x, y) ((x> -1) && (x <8) && (Y> -1) && (Y <8)) # Define Player1 0 # define Player2 1 # Define Black 0 # Define White 1 # Define Space 2 # define x (0) #define x (k) (x (k-1) step) # Define y (0) #define y (k) (Y (k-1) step) Void Change (int X, int y, const Int m, const Int n); int CBoard [8] [8]; int color1 , Color2; Static Int I, J; Int Player; main () {init (); while (1) {DRAWC (); RMVP (i, j); if (player == Player1) Player = Player2; Else Player = Player1; key = bioskey (); switch (key) {Case W: IF (isvalid (i, --j) mvp (x (i), y (j); else { J; Continue;} Break; Case S: IF (isvalid (i, j) mvp (x (i), y (j); else {--j; Continue;} Break; Case A: IF (isvalid (- i, j) MVP (ISVALID (- i, j) MVP X (i), y (j); else { i; continue;} Break; Case D: IF (IsValid ( i, j) MVP (x (i), y (j); else { I; Continue;} Break; Case Esc: EXIT (); Default: MVP (i, j); CO Ntinue;} IF ((CHECK (i, j, player)) Continue; if (end ()) exit ();} Drawscore ();

INT CHECK (INT X, INT YER) {IF (! isvalid (x, y)) Return 0; if (CBoard [x]! = space) Return 0;

IF (Player == Player1) Color1 = Black, Color2 = White; Else Color1 = White, Color2 = Black;

Change (X, Y, 0, 1); Change (x, y, 0, -1); Change (x, y, 1, 0); Change (x, y, -1, 0); Change (X, Y, 1, 1); Change (x, y, -1, -1); Change (x, y, 1, -1); Change (x, y, -1, 1);

Return 1;}

/ * ............ * / void change (int X, int y, const Int m, const INT N) {int hx, hy; int 2;

转载请注明原文地址:https://www.9cbs.com/read-32980.html

New Post(0)