Randomly generated parties

Get help using Construct 2

Post » Tue Jan 14, 2014 3:24 am

I'm reasonably new to Construct 2. I've done a couple of the tutorials making the Ghost shooter, breakout clones, and platformers so I understand the general workflow.

I'm looking into working on my own thing now and I'm not sure how to manage a central aspect of it. From what I understand sprite is a plugin you use to create objects that you can then instantiate to create many copies.

I don't think I can use that for what I want to do. I want to create adventuring parties of 6 characters. Each character will be an object that has a number of attributes that might change, including things like a randomly selected representation graphic, 4 stats that are randomly generated, a character class that's randomly generated, etc...

Does Construct 2 have something already set up along those lines? If I use something like an array, how would I tie the generated information in the array to a represented "sprite" on the screen?

Thanks for any help you can provide.
B
25
S
4
G
2
Posts: 11
Reputation: 1,630

Post » Tue Jan 14, 2014 5:42 am

I would store all the character details as instance variables in the sprite object.

If you are going to have a lot of animation for the characters then you would make a small invisible sprite to hold their variables and location on the screen, and then pin another animated sprite on top of that for things like walking, idle, jumping, falling, fighting, dead, etc.
B
99
S
35
G
20
Posts: 438
Reputation: 17,910

Post » Tue Jan 14, 2014 5:46 pm

Why would you suggest one sprite for variables and one sprite for graphics?
B
25
S
4
G
2
Posts: 11
Reputation: 1,630

Post » Fri Jan 24, 2014 3:18 am

I've gotten a bit further along and I'm now generating a screen of six adventurers, each with instance variables for their stats.

The problem I have now is it continues to randomly generate stats even after filling all of the available slots. I've attached a .capx file. I'd rather have one code block that populates all six instances rather than having to make a block for each of the 6 slots if possible.

Note: Remove the space after "https://" as my forum account doesn't have URL permissions yet.
https:// dl.dropboxusercontent.com/u/14668079/DPM-A1.capx
B
25
S
4
G
2
Posts: 11
Reputation: 1,630

Post » Fri Jan 24, 2014 4:57 am

Event sheets continuosly loop, executing the code over and over again. So your code to create characters is repeating forever.

If you want code to only run once when your layout starts (like creating characters), then create an "On Start of Layout" section and then make your "For Each" loop a sub-event of that. Then it will only run when the game first starts.

Your characters are being set up the way you want, but the info displayed on the screen is the same for each character because all your text fields have the same names - so each time it creates a new character it updates ALL the text fields on the screen.

To fix that you either need to give them unique names, or select the ones closest to the Spr_Adv_Border, or create the text boxes when you create the Spr_Adv1 charater...

I tweaked your capx to make it work. you can get it at: www.rieperts.com/games/forum/DPM-A1-fix.capx

The reason I suggested a sprite for variables and one for graphics is because the graphics will change based on how you generate your characters (male/femail, old/young, etc.) and as you will give them different animations. You need to have base objects that you know the names of to manipulate within your game. Then you apply the desired graphics you need on top of those...AllanR2014-01-24 05:02:22
B
99
S
35
G
20
Posts: 438
Reputation: 17,910

Post » Wed Jan 29, 2014 3:40 am

AllanR, thank you so much for taking a look at this and for your explanations. This information should be a huge leg-up for what I want to do.

I really really appreciate you taking the time to explain it all and even make changes to my .capx.
B
25
S
4
G
2
Posts: 11
Reputation: 1,630


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests