Author Topic: What is be best way to handle multi part enemies in my game.  (Read 2871 times)

0 Members and 1 Guest are viewing this topic.

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile


I've been picking my brain for some time trying to decide the best way to handle enemies in my game. Of course it is a shmup (that goes without saying). In this game you shoot connected clusters of cells. These cells are basically ngons that have the same side lengths so they can connect making larger shapes. My question is how to I handle grouping and moving all cells along a common spline path? The shape the cells form together must also rotate in respect to its direction. Does this mean that I give each cell in the enemy shape an x,y offset and an angle to maintain from the cluster's center? Do I store the cells in a cluster object or just update each cell with instructions to maintain the cluster shape? It seems simple in theory but for some reason I'm not sure about the best way to proceed and I want it done right.
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
I am thinking that the angle would be the same for the main body and the clusters, so you would only need x/y offsets. But you would need to rotate these offsets around the x/y location of the main body using the main bodys angle.

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
pretend that you are dealing with a skeleton animation routine. Pick a point for each seperate object and decide its origin point I will refer to this point as a node. Decide which node is to be the parent of each other node. if the entire object is to be moved in unison then only one node is needed but if you want arms etc to move around then each arm should be a child node to another node (prabably just the root node will do as the only parent). Now on to transformation.

first we will transform the nodes themselves. Each parent node that is transformed will effect all child nodes under it. subtract the position of the child node from its parent to convert the child node to local space. when in local space we can rotate, translate or scale each child node however we want. take the final position and angle of rotation of each node into account when dealing with their child nodes in turn.
when this is working properly you can move on to applying this skeleton to the vertices.
After you have translated any node and before moving onto that nodes child nodes you should apply the same translations to the child vertices as you did with the child nodes.

dont forget to add the new origin point of each node back in after transformations have taken place to convert back to global space this only needs to be added to the vertex positions.

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
K+ Rain Storm, good explanation :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile
Thanks for the help. I will soon have a system in place. :inspired:
Challenge Trophies Won: