aboutsummaryrefslogtreecommitdiff
path: root/bts.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-09-01 11:07:48 +0000
committerrodri <rgl@antares-labs.eu>2023-09-01 11:07:48 +0000
commit4f514003a8236aaeb9621b932c0f8329e03c1dd8 (patch)
tree98f02ef9ae95cb0e68a54341f1e2ba17bbc9fc7e /bts.c
parent344e764a193a70807d429e54c36f4cf5a5d0e8c7 (diff)
downloadbattleship-4f514003a8236aaeb9621b932c0f8329e03c1dd8.tar.gz
battleship-4f514003a8236aaeb9621b932c0f8329e03c1dd8.tar.bz2
battleship-4f514003a8236aaeb9621b932c0f8329e03c1dd8.zip
change mmb to rotate the ship without presenting a menu.
Diffstat (limited to 'bts.c')
-rw-r--r--bts.c77
1 files changed, 34 insertions, 43 deletions
diff --git a/bts.c b/bts.c
index 4706c23..a167f86 100644
--- a/bts.c
+++ b/bts.c
@@ -39,15 +39,15 @@ Cursor waitcursor = {
};
Cursor boxcursor = {
{-7, -7},
- { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F,
- 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+ { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f,
+ 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
},
- { 0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE,
- 0x70, 0x0E, 0x70, 0x0E, 0x70, 0x0E, 0x70, 0x0E,
- 0x70, 0x0E, 0x70, 0x0E, 0x70, 0x0E, 0x70, 0x0E,
- 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x00, 0x00
+ { 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe,
+ 0x70, 0x0e, 0x70, 0x0e, 0x70, 0x0e, 0x70, 0x0e,
+ 0x70, 0x0e, 0x70, 0x0e, 0x70, 0x0e, 0x70, 0x0e,
+ 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00
}
};
Cursor aimcursor = {
@@ -500,47 +500,38 @@ lmb(Mousectl *mc)
void
mmb(Mousectl *mc)
{
- enum {
- ROTATE,
- };
- static char *items[] = {
- [ROTATE] "rotate ship",
- nil
- };
- static Menu menu = { .item = items };
-
if(game.state != Outlaying)
return;
- mc->xy = addpt(mc->xy, screen->r.min);
- switch(menuhit(2, mc, &menu, _screen)){
- case ROTATE:
- if(curship != nil){
- curship->orient = curship->orient == OH? OV: OH;
- curship->bbox = mkshipbbox(curship->p, curship->orient, curship->ncells);
-
- /* steer it, captain! don't let it go off-board! */
- if(!rectinrect(curship->bbox, localboard.bbox)){
- switch(curship->orient){
- case OH:
- curship->bbox.min.x -= curship->bbox.max.x-localboard.bbox.max.x;
- curship->bbox.max.x = localboard.bbox.max.x;
- break;
- case OV:
- curship->bbox.min.y -= curship->bbox.max.y-localboard.bbox.max.y;
- curship->bbox.max.y = localboard.bbox.max.y;
- break;
- }
- curship->p = toboard(&localboard, curship->bbox.min);
- moveto(mc, addpt(screen->r.min, curship->bbox.min));
+ if(curship != nil){
+ curship->orient = curship->orient == OH? OV: OH;
+ curship->bbox = mkshipbbox(curship->p, curship->orient, curship->ncells);
+
+ if(debug)
+ fprint(2, "curship orient %c\n", curship->orient == OH? 'h': 'v');
+
+ /* steer it, captain! don't let it go off-board! */
+ if(!rectinrect(curship->bbox, localboard.bbox)){
+ switch(curship->orient){
+ case OH:
+ curship->bbox.min.x -= curship->bbox.max.x-localboard.bbox.max.x;
+ curship->bbox.max.x = localboard.bbox.max.x;
+ break;
+ case OV:
+ curship->bbox.min.y -= curship->bbox.max.y-localboard.bbox.max.y;
+ curship->bbox.max.y = localboard.bbox.max.y;
+ break;
}
- /* …nor ram allied ships! */
- if(rectXarmada(curship->bbox))
- curship->bbox = ZR;
+ curship->p = toboard(&localboard, curship->bbox.min);
+ moveto(mc, addpt(screen->r.min, curship->bbox.min));
+ readmouse(mc); /* ignore mmb click triggered by moveto */
}
- break;
+ /* …nor ram allied ships! */
+ if(rectXarmada(curship->bbox))
+ curship->bbox = ZR;
+
+ send(drawchan, nil);
}
- send(drawchan, nil);
}
void