diff options
| author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-05-08 13:17:59 +0530 | 
|---|---|---|
| committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-05-08 13:17:59 +0530 | 
| commit | bdd79c42a1ab4147af978e89fae96ce01554a519 (patch) | |
| tree | 2f3a8d1bfe8702e24463a388bc171779d2197bf0 /src | |
| parent | 5cb2ff3a1a5afa74bca0b32c3c69462500fc1a20 (diff) | |
| download | snek-bdd79c42a1ab4147af978e89fae96ce01554a519.tar.gz snek-bdd79c42a1ab4147af978e89fae96ce01554a519.tar.bz2 snek-bdd79c42a1ab4147af978e89fae96ce01554a519.zip | |
Head of player is now distinctive
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 38 | 
1 files changed, 35 insertions, 3 deletions
| diff --git a/src/main.cpp b/src/main.cpp index 5c73e68..b75f7c9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -146,10 +146,42 @@ struct State        }      } -    for (const auto p : player.points) +    double x_ = +        rescale(player.points.begin()->x, HEIGHT < WIDTH, (WIDTH - HEIGHT) / 2); +    double y_ = +        rescale(player.points.begin()->y, WIDTH < HEIGHT, (HEIGHT - WIDTH) / 2); +    DrawRectangle(x_, y_, square_size, square_size, YELLOW); +    // Eyes based on direction +    double x_eye_1 = x_; +    double y_eye_1 = y_; +    double x_eye_2 = x_; +    double y_eye_2 = y_; +    switch (player.dir)      { -      double x_ = rescale(p.x, HEIGHT < WIDTH, (WIDTH - HEIGHT) / 2); -      double y_ = rescale(p.y, WIDTH < HEIGHT, (HEIGHT - WIDTH) / 2); +    case Direction::UP: +      x_eye_2 += (9.0 / 10) * square_size; +      break; +    case Direction::DOWN: +      y_eye_1 += (9.0 / 10) * square_size; +      y_eye_2 += (9.0 / 10) * square_size; +      x_eye_2 += (9.0 / 10) * square_size; +      break; +    case Direction::RIGHT: +      x_eye_1 += (9.0 / 10) * square_size; +      x_eye_2 += (9.0 / 10) * square_size; +      y_eye_2 += (9.0 / 10) * square_size; +      break; +    case Direction::LEFT: +      y_eye_2 += (9.0 / 10) * square_size; +      break; +    } +    DrawRectangle(x_eye_1, y_eye_1, square_size / 10, square_size / 10, BLACK); +    DrawRectangle(x_eye_2, y_eye_2, square_size / 10, square_size / 10, BLACK); +    for (size_t i = 1; i < player.points.size(); ++i) +    { +      const auto &p = player.points[i]; +      x_            = rescale(p.x, HEIGHT < WIDTH, (WIDTH - HEIGHT) / 2); +      y_            = rescale(p.y, WIDTH < HEIGHT, (HEIGHT - WIDTH) / 2);        DrawRectangle(x_, y_, square_size, square_size, GREEN);      }    } | 
