0
\$\begingroup\$

I am working on a top down 2D grid based game, where as it is currently, units have a movement and an attack range. An example of this:

enter image description here

The blue squares are tiles the selected unit can move to, the red are tiles they can attack. Defining this is pretty easy, for the weapon/attack I just give it a minimum and a maximum range, and use that to figure out where they can attack. What I would like to do is create attacks that can attack multiple tiles. Something like a straight line would probably be pretty easy, but more complex patterns. Something like the following:

x-x

-x-

x-x

Or

--x--

-xxx-

xxxxx

Where the "x"s are the attackable tiles and the "-"s are not. An example illustration:

enter image description here

enter image description here

I am not sure how I should go about defining this data. I currently save the weapon/attack data in a CSV file, but am open to moving it to JSON as it gets more complicated. But right now I am just drawing a complete blank as to how I should approach this problem. Anyone have any ideas?

Thanks.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I would probably give it first an identifier (so your drawing code knows if it expects a single attack or a pattern) and give your drawing an array of places that correspond to the selection. Your first pattern would get something like (-1/+1, +1/+1, 0/0, -1/-1, -1/+1). This will allow you to create any shape you want \$\endgroup\$ Commented Jul 2 at 6:49

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.