# How can I position different size creatures in a group automaticly

I'm doing a game (in xna) on my free time, as I'm not in the game market, I'm pretty sure I'm missing something that would help me get this right. Think of Ogre Battle. A group of unit moves, and when they cross enemy, a small automatic Final fantasy battle starts for 2 or 3 round.

I'm struggling on how I should place the creatures in the combat screen. A fight started. (final fantasy rpg battle ) The creatures part of this group needs to be positionned in a 16x16 grid. Some creatures are bigger and use larger than 1x1 square.

I create a class called group to represent groups of creature walking around. So far, I decide to put in an array of 4x4 representing the grid. How do I go around and position all the creatures on that grid and make sure they arent stepping on top of each other ?

some pseudo code I have right now :

 Class Group
array(4,4) of rectangle
array(4,4) of creature

Public sub Update()
end sub
End class

Class Creature
CombatValue as List of Enum.Qualities
PreferedPosition as Enum.Position
Range as smallint( 1 = melee, 2 = small range, 3 = long range)
End Class

Public Enum Position
Front
Middle
Back
End Enum

Public Enum Qualities
Melee
Armored
Strengh
Dodge
Siege
SmallRange
DPS
Nuker
Controller
Buffer
Dex
Int
Sick
Weak
End Enum


In the update of the group class , I need to create a function to set the position of all creatures when the combat starts.

Private Sub AdjustCreaturePosition()
' check the "prefered position" of all creep ( front, middle, back).
' if there are no more spot left for a creature, I need to check which creature is moved to the middle row based on A. if one of the creature on the front row will be able to attack on middle row ( based on the range ). If no unit can attack from the middle row,  the weaker one is send on the back ( the sum of their combatValue list)
Next
End Sub


I got no idea how I'll do the AdjustCreaturePosition in a smart way yet. but lets say it works. Where I'm at a loss is how should I handle large creature who needs a 2x2 grid ?

• not sure at all about those tag, let me know if I should add/change them. – Thierry Savard Saucier Feb 16 '14 at 6:01
• Some kind of image would really make this question more clear, at the moment it's written like a stream of consciousness. Keep it to one question per post, and be specific about your question. Keep in mind that there's no "best" way to do things. And frequently you'll get more help if you tell us what you've tried so we have something to work with. – MichaelHouse Feb 16 '14 at 6:17
• Also see these related: gamedev.stackexchange.com/questions/28146/… gamedev.stackexchange.com/questions/44361/… – MichaelHouse Feb 16 '14 at 6:24
• not sure about those, this seems to be for pathfinding, and I'm good on that. its on the battle phase that I'm struggling ... I'll try to adjust the question. – Thierry Savard Saucier Feb 16 '14 at 6:31
• The second question does not involve pathfinding. Thanks for working on the question. – MichaelHouse Feb 16 '14 at 6:35