Spawning specific set of objects contained within a family.

0 favourites
  • 7 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hi all,

    I apologize if this is too long <img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz">. That said, I'll try to get straight to the point: I need to know if there's any way to spawn a specific set of objects that belong to a family, and have it be based off of a variable. For further explaination, please see below <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">.

    I'm working on a project inspired by an Android game called MinuteQuest (

    ). Currently, I have my entire game taking place in a single layout and whenever the player exits on the left or right side of the screen, the player spawns on the other end of the screen and a new set of enemies spawn to give the illusion the player is moving through different screens.

    Right now, there are six invisible objects that enemies spawn from. Each time the player enters a new "room", the spawner objects randomly select between things like "Enemy","Item", etc. and spawn that thing. So far, this has been working fine, but I need the enemies to increase in difficulty and change type as the player progresses through each "room". I'm using a global variable called "roomNumber" to measure this that increases/decreases each time the player exits the screen to the right/left respectively.

    So, essentially, I need something like this:

    Enemy1 can spawn in "rooms" 1, 2 and 3.

    Enemy2 can spawn in "rooms" 2, 3 and 4.

    Enemy3 can spawn in "rooms" 3, 4 and 5.

    ...and so on.

    Not sure if this will translate well visually, but imagine the [Enemy] represents the range of rooms I would like them to spawn in.

     1.2.3.4.5.6.7...
    [Enemy1]
      [Enemy2]
        [Enemy3]
          [Enemy4]
            [Enemy5] [/code:2k3ygpox]
    
    This is currently what I have:
    
    [img="https://trello-attachments.s3.amazonaws.com/55497989501cd5e8db426309/964x317/005f5e8a05db3b5ec690a1b33954d961/forums1.JPG"]
    
    I've been using Construct 2 (as well as Construct Classic) for some time now. That said, I am extremely visual and have a very hard time wrapping my head around some of the more abstract concepts such as how arrays/dictionaries/hash tables/etc. interact with Construct 2. This also extends to picking families as well. I've looked through many, many posts/tutorials that try to explain this, but it's just not sticking so I'm hoping someone can show me or at least explain how I can apply these concepts to my own project. Rexrainbow's plugins look to be extremely powerful and may be just the thing I need, but they are also very advanced/abstract (to me anyway) and go right over my head.
    
    Hopefully what I'm trying to explain makes sense. I can try to take some screens  and I really appreciate anyone taking the time to assist me with this. Just please know if it involves tables and stuff like that, I may need a fair bit of hand holding until I get my legs.
    
    Thanks in advance!
  • I've never tried myself (so might be wrong) but I always assumed that you could have multiple families with the same objects in theme... Just by theory I'd say you could probably make sub-families of the monsters you want and then have that only spawn from that family.

    Another idea could be to give each monster a variable (such as room spawn) and then not let them spawn until they hit that variable.. Such as room 1 monster has 1, any time the room number is 1 or greater that monster can spawn.

    These are both array free ideas btw. using an array would make this super simple. define array of monsters in x and an in y do the initial levels (or lvl it's allowed) then if wanted in Y2 you could define the frequency (such as 1 for every level, 2 for every other) then add that to the original Y after that monster has spawned so a monster would only show up every few levels.

    Couple of other ways around this as well.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the suggestions, MythStylz. I did start off trying some kind of sub-family system ("famEnemiesEasy", "famEnemiesMedium, "famEnemiesHard', etc) and C2 seemed to treat them as entirely separate objects from those contained in the parent-family "famEenemies".

    I also set them up with variables similar to what you suggested -- famEnemies has two instance variables, roomMin and roomMax. I was trying to make a comparison that For Each spawner object, if roomNumber is greater than famEnemies.roomMin and lower than famEnemies.roomMax, to spawn famEnemies (preferably a random one as there should be a bit of overlap between which enemies are eligable to be spawned using this comparison.

    I'm open to arrays as I'd love to not have this kind of stuff be an obstacle anymore. I just have no idea how to use them to achieve what I've described above, so I would need some detailed assistance. Thanks again!

  • I'm still knew with families so I may not be the best help.

    Ummm... are the enemies sprites all one object? or are they multiple different objects? Typically you can make one object many different "animations" and then choose(animationname1,animationname2) based on the variables you have set up.

    The array would be set up like so Z=0

    X or Width = Number of monsters - 1 (0 based I think, so 0 would be your monster)

    Height or Y = 1, The variables you want to store for each monster.

    Then at the beginning of the game you would feed in the info

    X at 0 would be monster 1

    Y at 0,0 would be initial round for monster 1

    Y at 0,1 would be frequency for monster 1

    X at 1 would be monster 2

    Y at 1,0 would be initial round for monster 2

    Y at 1,1 would be frequency for monster 2

    etc....

    IDK I'd look into arrays if I got a chance, they are real simple once you get the hang of them

  • also why not kill the "overlaying" family and only spawn certain enemies at certain times (easy med and hard)

  • I appreciate the detailed explaination. Let the hand-holding begin!

    I ditched the family approach (though I currently still have me enemies in a family for now in case I need to fall back on it later). I moved all the animations from the separate enemies into one object. I also started delving into arrays and this is what I've got at the moment (the "En1","En2", etc. have the enemy names on my actual array, this is just for example purposes):

    	    En1 En2 En3 En4 En5 	
    rMin    1	2	3	4	5	
    rMax 	3	4	5	6	7	
    HP: 	 2	2	3	3	4	
    ATK: 	1	1	2	2	3	
    DEF: 	0	1	2	3	4	
    SPD: 	1	2	2	3	3		
    [/code:21lthanv]
    
    I was trying to compare the current [b]roomNumber [/b]to see if it fell between [b]rMin[/b] and [b]rMax [/b]of each Y column, which would then create the main enemy object. Another tricky bit is that after spawn, I'm trying to set the animations to be whatever column or "En" was chosen to spawn. Would this be better compared with something like 'Is [b]roomNumber [/b]between [b](roomNumber-1)[/b] and [b](roomNumber+1)[/b]. I'm thinking whichever way I approach it, I'll need to send each enemy that meets these conditions to a second array, then randomly choose from that array to determine which enemy actually gets spawned.
    
    This is currently set to [b]((enSpawnArray.At(CurX,0)&"Idle")[/b]. This is because all of the idle animations for each enemy are named "En1Idle", "En2Idle", "En3Idle," etc. Does anyone know if this is the right way I should be approaching this? I saw this thread:  and am wondering if I should be using [b]enSpawnArray.At(0,CurY)&"Idle"[/b] instead. Any help is greatly appreciated!
  • I think you should set up the enemy names in the x axis, so you can call them by name later (i.e. enemy name on the x axis) this allows these arrays to be a little more useful, for this instance I think you could call array for each element of X and then compare the value of XY at X = AAPlayerInfoArray.CurX Y=1 is less than room number, and use Y=2 to compare the third value. (cause the names will be 0) This will allow you to do these actions plus you can easily reference your array by the math. (this is my example) AAPlayerInfoArray.At(AAPlayerInfoArray.IndexOf(Body.WrestlerAlias),2) <<< references whatever wrestler i'm dealing with in my game for example

    The number at the end can be any Y so you can reference each stat by whatever enemy your currently dealing with. This also helps you deal with referencing which column the monster is in to set its animation to. (AAPlayerInfoArray.IndexOf("MonsterName") would tell you what column that is on very easily.

    Usually keep a pad handy on which stat is which column (i.e. I have 9 stats per wrestler in my game, so it gets a little confusing,,, right that down somewhere for easy reference.)

    Basically it's much easier to select stuff on columns then it is rows.

    I.E.

    X= EnemyName Y1 = rMin Y2 = rmax Y3 = HP etc.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)