diff options
| author | Oxore <oxore@protonmail.com> | 2018-07-09 02:43:50 +0300 | 
|---|---|---|
| committer | Oxore <oxore@protonmail.com> | 2018-07-09 02:43:50 +0300 | 
| commit | a9e7132e6a430e86e8a69d1301252e38daf6e593 (patch) | |
| tree | 08e7865c55883e40db966a9851b546b95bc4524b /src/painter.c | |
| parent | 67186f876e17696858495a2a7a699344b0f94178 (diff) | |
Introduce phantom shape, refactor field
Introduce phantom shape feature, yay!
Refactor field: rename attribute of invisible empty cells, remove
"color" member from struct shape, introduce shape movement functions
with embedded collision checking and success reporting,
Diffstat (limited to 'src/painter.c')
| -rw-r--r-- | src/painter.c | 15 | 
1 files changed, 11 insertions, 4 deletions
| diff --git a/src/painter.c b/src/painter.c index 9f6b911..c0e93ea 100644 --- a/src/painter.c +++ b/src/painter.c @@ -120,7 +120,7 @@ void painter_update_field(unsigned long id, struct field *fld)              if (fld->c[j][i].a) {                  sfRectangleShape_setFillColor(f->p[j][i], shape_color_map[fld->c[j][i].color]);                  sfRectangleShape_setOutlineColor(f->p[j][i], (sfColor)UIFGACTIVECOLOR); -            } else if (f->attr & FLD_ATTR_TRANSPARENT) { +            } else if (f->attr & FLD_ATTR_HIDE_EMPTY_CELLS) {                  sfRectangleShape_setFillColor(f->p[j][i], (sfColor)UITRANSPARENT);                  sfRectangleShape_setOutlineColor(f->p[j][i], (sfColor)UITRANSPARENT);              } else { @@ -129,17 +129,24 @@ void painter_update_field(unsigned long id, struct field *fld)              }          }      } -    for (unsigned int s = 0; s < fld->shape_cnt; ++s) +    for (unsigned int s = 0; s < fld->shape_cnt; ++s) { +        sfColor fill_color = shape_color_map[fld->shape[s].t]; +        sfColor outline_color = (sfColor)UIFGACTIVECOLOR; +        if (fld->shape[s].attr && SHP_ATTR_GHOST) { +            fill_color.a = 100; +            outline_color.a = 100; +        }          for (int j = 0; j < 4; j++)              for (int i = 0; i < 4; i++)                  if (fld->shape[s].c[j][i] && j + fld->shape[s].y < (int)fld->size.y) {                      sfRectangleShape_setFillColor(                              f->p[j + fld->shape[s].y][i + fld->shape[s].x], -                            shape_color_map[fld->shape[s].color]); +                            fill_color);                      sfRectangleShape_setOutlineColor(                              f->p[j + fld->shape[s].y][i + fld->shape[s].x], -                            (sfColor)UIFGACTIVECOLOR); +                            outline_color);                  } +    }  }  static void draw_field_drawable(struct drawable *d) | 
