aboutsummaryrefslogtreecommitdiff
path: root/dat.h
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-08-15 02:41:43 +0000
committerrodri <rgl@antares-labs.eu>2023-08-15 02:41:43 +0000
commit04c90470556a5d3a66fb592ff7b6fee1228be95e (patch)
tree5201b75c3e56fa595ceff71bd2173a041541be0e /dat.h
parent8285721acfc247d57e0831503543dd29290ac4c5 (diff)
downloadbattleship-04c90470556a5d3a66fb592ff7b6fee1228be95e.tar.gz
battleship-04c90470556a5d3a66fb592ff7b6fee1228be95e.tar.bz2
battleship-04c90470556a5d3a66fb592ff7b6fee1228be95e.zip
added ship drawing and placement procedures.
Diffstat (limited to 'dat.h')
-rw-r--r--dat.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/dat.h b/dat.h
index 2a2c6b5..6d2a6ba 100644
--- a/dat.h
+++ b/dat.h
@@ -5,6 +5,9 @@ enum {
Tmiss,
NTILES,
+ OH, /* horizontal */
+ OV, /* vertical */
+
Waiting0 = 0,
Outlaying,
Waiting1,
@@ -22,8 +25,8 @@ enum {
};
typedef struct Input Input;
-typedef struct Board Board;
typedef struct Ship Ship;
+typedef struct Board Board;
typedef struct Player Player;
typedef struct Playerq Playerq;
typedef struct Chanpipe Chanpipe;
@@ -34,24 +37,28 @@ struct Input
Keyboardctl *kc;
};
-struct Board
+struct Ship
{
- RFrame;
- char map[17][17];
+ Point2 p; /* board cell */
Rectangle bbox;
+ int orient;
+ int ncells;
+ int *hit; /* |hit| = ncells and hit = {x: 0 ≤ x ≤ 1} */
+ int sunk;
};
-struct Ship
+struct Board
{
RFrame;
- int ncells;
- int sunk;
+ char map[17][17];
+ Rectangle bbox;
};
struct Player
{
int fd;
int sfd;
+ Channel *mc; /* for matching */
Player *o; /* opponent */
};