User Tag List

Results 1 to 7 of 7

Thread: Help creating enemy groups for a platform game

  1. #1
    Clicker Multimedia Fusion 2

    Join Date
    Apr 2013
    Location
    Australia
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help creating enemy groups for a platform game

    So I am making a platform shooting game (similar to Contra) and have come across some problems with creating enemy groups. I will try and outline this as clearly as possible:

    - Enemies are created only when the player gets to certain points in the frame (so that all enemies and their AI are not on the frame simultaneously)

    - Enemies consist of 2 parts. First is an invisible rectangular enemy 'hitbox' that contains the enemy behavior and individual health (the 'hitbox' is the part that essentially is the 'enemy' and physically moves). The second part is the actual enemy graphic that is set to always be on top of the enemy hitbox and follow it.


    So during a frame I can easily make it so that when the player gets to certain points the enemies are created and behave properly. The problem is the actual visible enemy graphics that are supposed to be following the invisible enemy hitbox's.

    I can make it so that during a frame if I create for example 2 enemy hitboxes as well as 2 of the enemy graphics, then the 2 graphics are indeed properly set to be on top of each hitbox (they don't both overlap on one of the hitboxes). There is still a problem however because the enemy graphics are not individually associated with their respective hitbox, so if I kill one enemy hitbox which in turn destroys the enemy graphic, then BOTH enemy graphics will be destroyed (although the other enemy hitbox will of course still be there)

    As some of you may be able to guess, in the code for the enemy hitbox behavior I simply have it so that the enemy graphic position is always set to the hitbox, and when a hitbox is destroyed then the enemy graphic is destroyed.

    I could avoid this altogether by making enemies 1 object, but it would be superior to have the hitboxes separate from the enemy graphic which will make the collision detection far better.

    So how can I make it so that during a frame if I create a certain number of enemy hitboxes, I also create the same amount of enemy graphics that are individually associated with the enemy hitbox they are following, so that destroying a certain enemy hitbox will only destroy the respective enemy graphic thats following it?



    Thanks very much for any help, and let me know if anything needs clarification.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    DaveC's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Australia
    Posts
    2,112
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    I quickly made a couple of crude examples, they're mostly to just demonstrate the problem MMF has with knowing which sprite you want to destroy when it is not directly referenced in your event. To make it work perfectly I think you'd need to use fastloops.

    enemy examples.mfa

    with that said, the first method is very simple and could possibly solve your problem as is..

  3. #3
    Clicker Multimedia Fusion 2

    Join Date
    Apr 2013
    Location
    Australia
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, thanks a million! I got it working.

    Theres a small issue though, once an enemy is destroyed, all the other hitboxes and sprites blink for a split second. Seems MMF is somehow 'refreshing' the sprites? Anyway to get around this problem?


    Thanks again!


    *Edit* I just experimented a bit more and it seems the blinking only happens when certain numbered objects are destroyed. In your example if you click the enemies you can have the other ones not blink if you click them in a certain order. In my game I implemented the technique with 2 enemies onscreen, and if you kill a certain one first the other wont blink.

    How could this problem be averted so that the blinking never happens no matter what order the enemies are destroyed in?

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    DaveC's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Australia
    Posts
    2,112
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    hmm oh yeah looks like mmf is not actually destroying the correct object and is then re-positioning/re-syncing all the other objects each time one is destroyed. That second example really wasn't done correctly at all, normally you should use a fastloop to loop through and check each object individually, it's a tiny bit more complex though, it would fix the flicker problem.I could have another look when I get home.. about to go to work though >_<

  5. #5
    Clicker Multimedia Fusion 2

    Join Date
    Apr 2013
    Location
    Australia
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Theres no rush just take your time. I really appreciate the help.

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Oct 2007
    Location
    UK
    Posts
    304
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Hi Macaw,

    A fastloop example based on the one above.

    https://www.dropbox.com/s/y8sxdhl1p9...%20example.zip


    If you need help understanding it, just ask.

  7. #7
    Clicker Multimedia Fusion 2

    Join Date
    Apr 2013
    Location
    Australia
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just had a quick look at it and I think I can understand it, will tinker around with fastloops now in my game!

    Thanks!

Similar Threads

  1. Best Way for Platform Enemy AI?
    By Blue66 in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 1st July 2011, 06:53 PM
  2. Creating Groups
    By kmarshall in forum The Games Factory 2 - Technical Support
    Replies: 2
    Last Post: 18th June 2008, 11:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •