Click cmatch(Click c, int dtop) { Click lc; lc.d = dtop; do { for(lc.y = 0; lc.y < Ly; lc.y++) for(lc.x = 0; lc.x < Lx; lc.x++) if(level.board[lc.d][lc.x][lc.y].which == TL && isfree(lc) && !eqcl(c, lc) && level.board[c.d][c.x][c.y].type == level.board[lc.d][lc.x][lc.y].type) return lc; } while(--lc.d >= 0); return NC; }
void drawbrick(Click c) { Rectangle r; r = tilerect(c); draw(img, r, tileset, nil, level.board[c.d][c.x][c.y].start); if(level.board[c.d][c.x][c.y].clicked) draw(img, r, selected, nil, ZP); if(eqcl(level.l, c)) border(img, r, 2, litbrdr, level.board[c.d][c.x][c.y].start); /* looks better without borders, uncomment to check it out with'em */ // r = Rpt(r.min, addpt(r.min, Pt(Tilex, Tiley))); // draw(img, r, brdr, nil, ZP); }
void clicked(Point coord) { Click c; Brick *b, *bc; c = findclick(coord); if (c.d == -1) return; b = &level.board[c.d][c.x][c.y]; if(isfree(c)) { if(level.c.d == -1) { level.c = c; b->clicked = 1; b->redraw = 1; } else if(eqcl(c, level.c)) { level.c = NC; b->clicked = 0; b->redraw = 1; } else { bc = &level.board[level.c.d][level.c.x][level.c.y]; if(b->type == bc->type) { clearbrick(c); bc->clicked = 0; clearbrick(level.c); level.c = NC; } else { bc->clicked = 0; bc->redraw = 1; b->clicked = 1; b->redraw = 1; level.c = c; } } updatelevel(); if(!canmove()) done(); } }
void light(Point coord) { Click c = findclick(coord); if (c.d == -1) return; if(eqcl(level.l, c)) return; if (level.l.d != -1) { level.board[level.l.d][level.l.x][level.l.y].redraw = 1; level.l = NC; } if(isfree(c)) { level.l = c; level.board[c.d][c.x][c.y].redraw = 1; } updatelevel(); }