What is the best approach ?

0 favourites
  • 4 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • First I want to say that I had read the stuff about optimisation:

    scirra.com/blog/83/optimisation-dont-waste-your-time

    scirra.com/manual/34/best-practices

    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 ?

  • 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.

  • 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.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).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok, next is the PowerUp Timer

    Here is my code:

    <img src="http://s23.postimg.org/vk4218wvv/Power_Up_Timer.jpg" border="0" />

    Is there any way to include actions from the second condition inside the first condition ?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)