adonthell-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-devel] Re: Interaction on the map


From: Kai Sterker
Subject: [Adonthell-devel] Re: Interaction on the map
Date: Wed, 22 Apr 2009 09:50:13 +0200

On Wed, Apr 8, 2009 at 11:38 AM, Kai Sterker <address@hidden> wrote:

> To sum it up in pseudo code, we'd have something like this:
>
> on button pressed:
>   action_type = calculate_action_type_for_button_and_mode()
>   if (action_type == combat)
>       weapon = player.get_active_weapon_or_spell()
>       area_of_effect = weapon.get_area_of_effect()
>   else
>       area_of_effect = player.get_area_of_effect()

Starting with implementation on Monday, I stumbled across the first
problems around line 3 or so :-). My idea for get_area_of_effect() is
to return a radius and an arc to define the area in which to check for
affected objects.

The arc could be anything between 0° and 360° (although in reality we
might see something between 90° and 180°). We know the direction the
character is facing, so we can determine the angles between which
possible objects must be found.

The problem is, we cannot really construct a bounding box around the
resulting arc and retrieve the objects that way, as it will get wildly
inaccurate, especially if the character is facing in a diagonal
direction (NE, SE, etc ...). Directly using the arc and radius data to
get matching objects from the map isn't something I wanted to
implement, so I wasn't sure how to go on.

Yesterday night, I had an idea that might actually work, with a bit of
an overhead. Use the radius to construct a bounding box around the
character center, and get all matching objects. (I am thinking about
adding an object type parameter to the according method, so we can
limit the objects returned to those of the given type(s)).

Once the objects are returned, we could calculate the line between the
character and each object and then the angle of that line with the
x-axis. We then check if the angle lies between start end end of our
arc. If it isn't we discard the object.

Finally, all remaining objects are sorted by their distance to the
center of the arc and their distance to the character.


Sounds feasible?

Kai




reply via email to

[Prev in Thread] Current Thread [Next in Thread]