Spawning specific set of objects contained within a family.

Get help using Construct 2

Post » Wed May 06, 2015 2:19 am

Hi all,

I apologize if this is too long :P. 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 :).

I'm working on a project inspired by an Android game called MinuteQuest (https://www.youtube.com/watch?v=q-X0SUWbAQs). 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.
Code: Select all
 1.2.3.4.5.6.7...
[Enemy1]
  [Enemy2]
    [Enemy3]
      [Enemy4]
        [Enemy5]


This is currently what I have:

Image

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!
B
3
Posts: 7
Reputation: 239

Post » Wed May 06, 2015 3:52 am

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.
B
9
S
2
Posts: 54
Reputation: 638

Post » Wed May 06, 2015 4:22 am

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!
B
3
Posts: 7
Reputation: 239

Post » Wed May 06, 2015 6:19 am

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
B
9
S
2
Posts: 54
Reputation: 638

Post » Wed May 06, 2015 6:50 am

also why not kill the "overlaying" family and only spawn certain enemies at certain times (easy med and hard)
B
9
S
2
Posts: 54
Reputation: 638

Post » Thu May 07, 2015 5:11 am

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

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):

Code: Select all
       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      


I was trying to compare the current roomNumber to see if it fell between rMin and rMax 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 roomNumber between (roomNumber-1) and (roomNumber+1). 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 ((enSpawnArray.At(CurX,0)&"Idle"). 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: viewtopic.php?f=147&t=125961&p=892402&hilit=import+csv#p892402 and am wondering if I should be using enSpawnArray.At(0,CurY)&"Idle" instead. Any help is greatly appreciated!
B
3
Posts: 7
Reputation: 239

Post » Tue May 19, 2015 9:44 pm

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.
B
9
S
2
Posts: 54
Reputation: 638


Return to How do I....?

Who is online

Users browsing this forum: marc254 and 7 guests