Help me to learn this code.

1 favourites
  • 4 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I found an example to make the player walk in front and backside of a tree, i hope it will work very well with my project. But my problem is i want to learn the code instead of just putting in my project. Anyone please help me.

    Player is walking between the tree from bottom to top and also from top to bottom. If the player goes to the top after passing a tree the player will become behind that tree he is just passed

    Question 1: If you can elaborate the code in detail it will be more helpful. Especially from the third line?

    Question 2: Here what is the use of pick bottom instance to move the player behind the tree? Which bottom instance is picking with this condition nearest tree below the player or the last tree?

    Question 3: After reaching the top when he return to bottom how he is becoming in front of the tree which he is passed.? I couldn't see any code for that.

  • Since it's my demo, I'll explain.

    Please download this updated file:

    Note, that all sprites have origin image point at the bottom.

    First, in event #1 all trees are z-sorted by their Y-position on the layout.

    On every tick I pick trees that are below the character on the layout. These trees will be green, all trees above will become grayscale.

    Then among the green trees I pick the bottom tree (on Z-axis). I may as well pick a tree with lowest Y-coordinate, it will be the same tree. This tree will start pulsating.

    And finally I move the character behind this tree.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That was very helpful. My doubt was how the player is becoming in front of the tree he is just passed when he is coming from top of layout to bottom. Now I got the idea, when he coming from top to bottom after passing a tree its y value will become lesser than the player y then picking the y of Tree which is just below the player then placing him behind that Tree which he is going to pass next, normally the player will be in front of the first tree.

    Thank you for your effort

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