What is the best approach ?

Get help using Construct 2

Post » Fri Oct 04, 2013 12:57 am

First I want to say that I had read the stuff about optimisation:

https://www.scirra.com/blog/83/optimisation-dont-waste-your-time
https://www.scirra.com/manual/34/best-practices
http://www.scirra.com/manual/134/performance-tips

But I want to make my "ode as "clean" as I can.

So I have the following questions:

1. Health, lifes and Game Over screen:

Every Tick:
-Update the HUD information about Health
-Check if the Health is 0 -> restart the layout and place the Player at SavePoint
-Check if Lifes is 0 -> go to Game Over layout

or

To make a function that will be used every time the player is hit by the enemy
- Substract 1 from Health
- Update the HUD information about Health
- Check if the Health is 0 -> restart the layout and place the Player at SavePoint
- Check if Lifes is 0 -> go to Game Over layout

or

Have the previous instructions in every collision with an enemy (sounds kind of dumb but is still an option)


2. Player collide with object or the object collide with the player

Should I check if the Player has the collision with the Object/Enemy and then execute the actions ?

or

Should I check if the Object/Enemy has the collision with the Player and then execute the action ?


3. Pop-up Menu

For Pop-up Menu (like the About Menu or Pause Menu) I made a layer above all layers and made it invisible by default. When About or Pause is activated, the layer becomes visible.
Is this the recommended way or is there a better method ?TGeorgeMihai2013-10-04 01:02:34
B
49
S
15
G
6
Posts: 535
Reputation: 7,197

Post » Fri Oct 04, 2013 1:27 am

For #1 I think the second one is best - having a function that handles the subtracting of health and the HUD stuff and calling that function when health should be subtracted. This way you aren't constantly polling a variable, but only checking it when you know it has changed.

For #2 I'm actually not sure of the performance implications of the two different options, but would love to hear the answer :)

For #3 I'm doing something similar with my HUD, using the "global HUD" tutorial. Seems like the easiest approach.
B
11
S
2
Posts: 87
Reputation: 1,112

Post » Fri Oct 04, 2013 4:53 am

[QUOTE=TGeorgeMihai] First I want to say that I had read the stuff about optimisation:

https://www.scirra.com/blog/83/optimisation-dont-waste-your-time
https://www.scirra.com/manual/34/best-practices
http://www.scirra.com/manual/134/performance-tips

But I want to make my "ode as "clean" as I can.[/QUOTE] Regarding that you already read these, keeping the code clean should just focus on the human readable aspect: Arrange your events, so that it is most easily maintainable.

1) For repeating the same actions all over your code, a function is optimal. If you only use those actions once in your event sheets, it might be better not to use a function and to keep all events together that affect a certain object.

2) For better maintaining do the collision check based on logic. If that check is done in a block of events that refer to the player, check if player has collision and vice versa for enemies.

3) Again there is no better ways, as all are acceptable. If you fr example want to display the game behind your menu, there is no other way (besides using no layer at all).
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Sun Oct 06, 2013 10:10 pm

Ok, next is the PowerUp Timer

Here is my code:



Is there any way to include actions from the second condition inside the first condition ?
B
49
S
15
G
6
Posts: 535
Reputation: 7,197


Return to How do I....?

Who is online

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