tresinformal / drakkar

The tresinformal video game called 'Drakkar'
GNU General Public License v3.0
11 stars 4 forks source link

When a player gets within the radius of a food, it eats the food #392

Closed TheoPannetier closed 3 years ago

TheoPannetier commented 3 years ago

Depends on

//#define FIX_ISSUE_392
#ifdef FIX_ISSUE_392
  //When a player gets within the radius of food it eats it
  {
    game g;
    food f = g.get_food()[0];
    double food_radius = f.get_radius();
    // Player beyond food radius should not trigger collision
    put_player_near_food(g.get_player(0), f, food_radius + 1.0);
    assert(!has_any_player_food_collision(g));
    g.tick();
    assert(has_food(g));
    // Player within food radius should trigger collision
    put_player_near_food(g.get_player(0), f, food_radius - 1.0);
    assert(has_any_player_food_collision(g));
    g.tick();
    assert(!has_food(g));
    assert(!has_any_player_food_collision(g));
  }
//#endif
TheoPannetier commented 3 years ago

Done!