[SOLVED] Picking, for each loop, making things cleaner..

Get help using Construct 2

Post » Tue Jul 01, 2014 8:33 pm

I'm looking to make a game similar to this one: http://www.ferryhalim.com/orisinal/g3/wings.htm

I managed to make it work as intended as least for a starting point, I usually like to have an idea of how I'm gonna build the whole game before starting and since I'm not very familiar with Construct's picking system I came here ask for some help before going on in this game.

I've a programming background but I seem to get pretty lost with all this blocks structure, so any tips are also welcome.

Please have a look at the capx, mouse control main bird, click spawn follower bird at random position, you pass over a bird and it starts following you.

My question is "How do I 'maker it better/cleaner' ".
You do not have the required permissions to view the files attached to this post.
Last edited by caiorosisca on Wed Jul 02, 2014 12:34 pm, edited 1 time in total.
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Tue Jul 01, 2014 11:35 pm

Hey looks good. No time to go in depth but just some surface stuff.. You don't need the System:Every tick before the Mouse:Right button is down. You have a duplicate event (10 and 11). You could have 1 expression at event 16 like System:Pick GoodWing by evaluating GoodWing.lineNum = 0 & GoodWing.pickedUp (although that's personal preference). You could use groups to make it cleaner (as it gets bigger).

Apologies if that's too basic stuff that you already knew :) I think the title is misleading, you seem to know how to pick the right instance (at least to my basic knowledge) :?:
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Wed Jul 02, 2014 12:12 am

Ok looking at the bird following events: the first two things that stand out are what codah already mentioned. No need to have everything under an 'Every tick' condition because the events run every tick anyway by default. And events 10/11 I guess were a copy/paste error.

Then, there's no need to use the system pick conditions when there is a sprite picking condition that does the same thing. For example, you use both 'GoodWing: Is PickedUp' and 'System: Pick GoodWing by evaluating GoodWing.pickedUp' conditions that both do the same thing but the first is more readable. Also, 'System: Pick GoodWing where GoodWing.lineNum = 0' could be just 'GoodWing: lineNum = 0' (Sprite: Compare instance variable).

All the GoodWing picking events have an 'Is pickedUp' condition, so you can take that out and move it up the top below the 'else' as it applies to all sub-events.

And finally for the looping, instead of looping PickedCount times and keeping track of an index and so on, you could use 'System: For each (ordered)' to loop through each GoodWing ordered by lineNum.
You do not have the required permissions to view the files attached to this post.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,630

Post » Wed Jul 02, 2014 12:34 pm

@codah @ramones

Thanks so much for taking your time to have a look at it.

At first I didn't have the mouse clicks to group them all together, that's why the every tick event was there, I completely forgot to take that out though. Thanks for pointing that out.

10/11 were a copy paste error for sure. my bad.

About all the picking conditions, that capx was exactly what I was looking for, I didn't know I could use for loops ( although their pretty basic stuff in proggraming, I was like "how can the engine don't have it" ).

Now it looks clean and everything makes sense. About the topic, I messed around alot with the picking stuff while writing the topic and forgot to change the tile.

Thanks guys.
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 9 guests