Programming best (and worst) practices

Discussion and feedback on Construct 2

Post » Mon Feb 25, 2013 10:27 pm

Exacly the kind of topic i was looking for. I asked a similar question. You nailed some very good practice and confirmed my approachs as good ones.

I also believe this topic, maybe as a tutorial, should be sticked somewhere.
I found myself coding in similar fashion as Yann :)
I see many "big names" here. Hopely some absent respected members could throw their two cents.
B
31
S
4
G
4
Posts: 110
Reputation: 4,588

Post » Sun Apr 28, 2013 4:14 am

Personally I've found a way that works well for me (I think it's very similar to others mentioned here). I have a folder called "Common" where I put the event sheets shared across multiple Layouts, and another folder for each layout where I put layout specific stuff. In the "Common" folder, I put event sheets such as "HUD", "HUD - Minimap", "Weapon - Hits", "Weapon - Selection", and so on. I name it this way so that related event sheets stick together when sorted alphabetically. The name also reflects the inheritance: The "HUD" event sheet includes all the "HUD - ????" sheets, "Weapons" contains all the "Weapon - ???" sheets, and so on. In each event sheet for each layout, I just have to include 2-3 main event sheets, which in turn include all the rest. ;) I find breaking down the sheets this way keeps them all very small and manageable. In addition, it helps to easily and quickly find the sheets I need.JoyfulDreamer2013-04-28 04:18:34
Jack of all trades, and master of some.
B
29
S
9
G
7
Posts: 174
Reputation: 7,601

Post » Sun Apr 28, 2013 4:57 am

[QUOTE=JoyfulDreamer] In each event sheet for each layout, I just have to include 2-3 main event sheets, which in turn include all the rest. ;)[/QUOTE]

@JoyfulDreamer You could even include all your "levels" layout event sheets into one "global" event sheet and then you would not have to include anything for each layout/"level" ;)
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Sun Apr 28, 2013 12:36 pm

This is all very interesting.
[QUOTE=sqiddster]In my opinion, it's best to use a small amount of object types. For example, there's no need to have a 'tree' and 'rock' object if they have an identical function.[/QUOTE]
I'm interested in the alternatives for this? Isn't it easier, when building scenes, to have semantic objects for greater clarity? Don't families serve the purpose of grouping functionality?
[QUOTE=sqiddster]Have your layer setup fleshed out before making the first level of a game with many layouts. It's incredibly boring to mirror layer changes across 50+ levels.[/QUOTE]
Totally agree with this. It would be great if we could add/remove and loop through layers at runtime and if inheritance layers made an appearance!
[QUOTE=Yann]As far as I'm concerned, after working on some big projects, I noticed that I was losing tonnes of time looking for pieces of code in all my event sheets.[/QUOTE]
I agree with @Jeff Skyrunner regarding event sheets. I too find the integrated search poor, so when wanting to search across multiple event sheets I use a text editor to search all xml files in the 'Event Sheets' folder. @Ashley perhaps this highlights some potential search improvements :)

Most has already been covered but I'll add this:

I use families for any functionality. If I have an enemy, I create an enemy family, if I have a button, I create a button family. On a large project, functionality always ends up being duplicated at some point and upgrading the logic from objects to families is a pain and sometimes dangerous (despite being made easier recently).thehen2013-04-28 12:40:10
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Post » Sun Apr 28, 2013 1:33 pm

[QUOTE=thehen] This is all very interesting.
[QUOTE=sqiddster]In my opinion, it's best to use a small amount of object types. For example, there's no need to have a 'tree' and 'rock' object if they have an identical function.[/QUOTE]
I'm interested in the alternatives for this? Isn't it easier, when building scenes, to have semantic objects for greater clarity? Don't [/QUOTE]

I suppose it depends heavily on the game - but object clutter is often a problem in beginner projects.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sun Apr 28, 2013 7:16 pm

[QUOTE=shinkan] [QUOTE=JoyfulDreamer] In each event sheet for each layout, I just have to include 2-3 main event sheets, which in turn include all the rest. ;)[/QUOTE]

@JoyfulDreamer You could even include all your "levels" layout event sheets into one "global" event sheet and then you would not have to include anything for each layout/"level" ;)[/QUOTE]

As long as all layouts are the same thing. In my case, not all layouts function the same. ;) The common event parts have a global event sheet for a specific subject which can be "inherited" into layouts as I need them. I think, other than families, this is one of the best things C2 has done thus far towards modular development. :) You can almost think of sheets like plugins as well, for example, to have a few sheets for different enemy behaviors, then include whatever sheet you need for a layout (for example, better AI logic for higher levels), or include all sheets, each one wrapped in a group so you can enable/disable as needed.JoyfulDreamer2013-04-28 20:43:05
Jack of all trades, and master of some.
B
29
S
9
G
7
Posts: 174
Reputation: 7,601

Post » Mon Apr 29, 2013 8:21 am

I just love creating own event sheets for stuff that requires lot of code and I use functions for the smaller stuff. I usually create level event sheet like Level_1_Code that's empty. I will then choose from my library of event sheets what that level requires, like Timer_Code, Night_Code, Rain_Code, Fog_Code. To me it's easier to find and modify things that I can easily locate with obvious names.
B
40
S
5
G
5
Posts: 405
Reputation: 5,657

Post » Wed Aug 28, 2013 2:53 am

[QUOTE=Whiteclaws] Yup ! Some of mine ... are !
......
- Dump all your objects on a layout so they won't interfere with the main layout
........

Cheers ![/QUOTE]


Can you elaborate on that?   Will it help with performance?

TY,
Ed
B
16
S
2
G
1
Posts: 35
Reputation: 1,033

Post » Wed Aug 28, 2013 2:57 am

@Squirrely1

It's a good idea to do this, not for performance reasons, but because C2 requires at least one instance of every object to be on some layout, so that it can use its initial parameters when spawning the object. Putting the objects on an unused layout is a nice way to go about this.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Wed Aug 28, 2013 1:43 pm

@Sqiddster
TY

So it's more for clean development and will not render a performance issue.

Still it's cool. I can just create a blank layout and place all the flotsam object instances on that. And C2 will spawn/generate on the active layout as needed?
Ah, I can already feel the mental relaxation I'll get from not having to look at a junkpile of objects while trying to create an asthetic.
I'll try it.

TY
B
16
S
2
G
1
Posts: 35
Reputation: 1,033

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: Zonacas and 15 guests