richelbilderbeek / djog_unos_2018

Project by the Uno's at DJOG 2018-2019: Nature Zen
GNU General Public License v3.0
6 stars 2 forks source link

Refactor agent::move to get correct behavior #623

Open richelbilderbeek opened 5 years ago

richelbilderbeek commented 5 years ago

Is your feature request related to a problem? Please describe.

In agent::move there is this mess:

  if((is_on_tile(g, center_temp.x + temp_x, center_temp.y + temp_y)
     && t_temp[0].get_type() != tile_type::water)
     || (!will_drown(m_type, 12.34) && is_on_tile(g, center_temp.x + temp_x, center_temp.y + temp_y))
     || m_type == agent_type::bird){
    m_x += temp_x;
    m_y += temp_y;
  }

There are two problems:

  1. I cannot read it
    1. I've added the magic number 12.34 as the [something with] depth

Describe the solution you'd like

Please do:

  1. Refactor in such a way it can be read.
  2. Find a way to replace 12.34 by a sane value

Describe alternatives you've considered

None.

Additional context

None.