Well, something that my professor said while I was coding "C" at class made me think I might be doing many bad coding habits in Construct 2.
I wanted to know whether these bad habits of mine do significant impact on my game's performance.
My game is a rpg type of game & any performance gain means a lot to me since the mechanics of the game is quite big, if you are wondering why I bothered to ask this.
1)One thing that my professor told me about my bad habits is that I use 2 or more loops when I can just make a nested loop out of all of those.
For example (In C2's event system):
My way:
*For Each AI_Characters:
, ------> AI Behaviors....
*For Each AI_Characters:
, -------> AI Animations...
Professor's Way:
*For Each AI_Characters:
, --------> AI Behaviors
, ---------> AI Animations
I do that style because it looks neat on the eventsheet, also that the events are so long that I need to organize & especially that I am grouping it to avoid confusion.
So does separating conditions doubles the cpu computation & affect performance?
2) Also another thing, it is about the Else... In C2, I use the "invert condition" more times the "else condition" since I am not sure if the "else" will always work.
So in class, I did the same & my professor said that it will slow down the CPU...
At that moment, I thought about my game and concluded my game is wasting too much CPU... since I was using "Invert condition" more times than the "else condition".
So does it still matter in C2? Does it significantly affect performance?
My way:
*If Variable = 1
, move()
*If Variable is not = 1
, stop()
Professor's Way:
*If Variable = 1
, move()
*Else
, stop
Thanks for giving time answering my questions.