How do I generate a random parallax background?

0 favourites
  • 4 posts
From the Asset Store
Project File of my C3 Tutorial Random Tree Generator
  • Hello everyone,

    I'm trying to make a simple doodle jump like game and I have a problem about my background.

    I have several different images for it and I want to create a new object with a random image each time my view reach the top of the actual background. So it will scroll to a non identique background each time.

    I join my c3p file here so maybe someone know who to do this…https://drive.google.com/file/d/1nIWwMrhVr7YyDEltI03Nnr_r__By9rqR/view?usp=sharing

    Thanks!

  • For now this is my code:

    + System: Trigger once

    + System: Pick BG1 where BG1.BBoxBottom ≥ LayerParallaxY("LayerBG")-640

    -> System: Create object BG1 on layer "LayerBG" at (360, BG1.Y-1280), create hierarchy: False

    It works for the first background but it stop at the second one…

  • Here is the solution:

    + System: Pick BG1 where BG1.BBoxBottom ≥ ViewportBottom("LayerBG")

    + BG1: Variable1 = 0

    + BG1: Pick instance with UID BG1.UID

    -> BG1: Set Variable1 to 1

    -> System: Create object BG1 on layer "LayerBG" at (360, BG1.Y-1280), create hierarchy: False

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm actually doing this for my current main project, which is a vertical scrolling SHMUP for mobile. The way I have my project setup, is I have two separate background sprites that alternate randomly("Background1", and "Background2"). Each of these sprites, have multiple animation frames(three in total with "Loop" turned off). Screenshot Here

    Then in the GameSettings Event Sheet that runs during the main Layout for the gameplay, I have a Global Variable named "Background", which is a number. Each time the Play Button on my Title screen is clicked, I have a group of Events in the same GameSettings Event Sheet, to control the background frame it chooses for that play through. It looks like this

    So the player will see one of three of the backgrounds, which alternates between two separate sprite objects by placing one in the Game Layout's Viewport, and the other directly above it so they are touching. Then they just move down the screen by 5 in the Every tick Event/Actions.

    Not sure if this helps it all. It sounds like you've already found your own method, which looks like it would definitely do the trick. This is just another method to accomplish basically the same thing.

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