The 'Real World Examples' Thread

This forum is currently in read-only mode.
From the Asset Store
Unlock platyers earning coins, and save it with Localstorage
  • Example 02:

    Portals

    Objective: What if you want to create a Castlevania-like layout/portal system where you exit a layout to the right and want the player to spawn in the next layout on the left?

    Info: If you go right or left to exit layouts, you run into an object that triggers a 'go to next layout' or a 'go to previous' layout command. Also, it sets a global variable that is being used for the upcoming spawn event.

    Also, nod to the developers: If you turn the Transition to 'Fade', it completely breaks the system so that the spawns ain't working anymore - I still haven't figured out a solution for this. How do transitions work exactly?

    Resource:

  • Request:

    Objective: How to make incremental and random variables.

    Info: By incremental I mean something happening more and more often the longer time goes on, for example making an enemy spawn faster and faster throughout a level.

    ---

    By random I mean giving something a random variable with upper and lower limits. For example an enemy spawns but you want it to have a constant walking speed of any number between 100 and 150.

    Resource: No Idea how to do this, so no .cap I'm afraid.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Request:

    Objective: How to make incremental and random variables.

    Info: By incremental I mean something happening more and more often the longer time goes on, for example making an enemy spawn faster and faster throughout a level.

    ---

    By random I mean giving something a random variable with upper and lower limits. For example an enemy spawns but you want it to have a constant walking speed of any number between 100 and 150.

    Resource: No Idea how to do this, so no .cap I'm afraid.

    For your first question, you could use the X coordinate of the player as part of the random generation equation. The further along the player is (assuimng completely that the player is travelling to the right) the higher his/her X coordinate will be.

    You could do something like:

    (pseudo code)

    +Every random(10000)+10000 milliseconds
    +Player X is less than 200
    +Player X is greater than 0
    -Create enemy at X,Y
    -Set enemy speed to random(100)+50
    [/code:3dzuw2ql]
    followed by
    [code:3dzuw2ql]
    +Every random(5000)+10000 milliseconds
    +Player X is less than 400
    +Player X is greater than 200
    -Create enemy at X,Y
    -Set enemy speed to random(200)+50
    [/code:3dzuw2ql]
    
    There are probably better ways to do this, as I'm quite sure people will point out... but I come from the "Quick and dirty and get it done" school, not the "Precise and correct and optimised" school.
    
    ~Sol
  • > +Every random(5000)+10000 milliseconds
    +Player X is less than 400
    +Player X is greater than 200
    -Create enemy at X,Y
    -Set enemy speed to random(200)+50
    [/code:2m601xij]
    ~Sol
    

    That sounds handy, what does the "random(x)+y" command do?

    I'm going to assume it chooses a random number between 0 and x, then the +y is to set a lower limit, is that right?

  • That's correct.

  • Edit: I had a look at the wiki again and Huzzah I did it!

    Objective: Make incremental variables.

    Info:-

    Resource:

    I've made a private variable on the object that is spawning the enemies (ZombieSpawner) and I've called it ZombieSpawnTime

    The private variable will have an initial value of say 10 seconds.

    In the first 10 seconds it will spawn a zombie, and times the variable by 0.9 (to stop the value going into negative numbers).

    Now 9 seconds later it will do the same thing again, and so on and so on...

    +Every ZombieSpawner('ZombieSpawnTime)' milliseconds
    -ZombieSpawner Spawn object Zombie on blablabla
    -ZombieSpawner set "ZombieSpawnTime" to 0.9*ZombieSpawner('ZombieSpawnTime')[/code:1gu8ckdk]
    
    *The first line is accessing the private variable set on the [b]ZombieSpawner[/b]
    *The second simply spawns the object
    *The third is trying to edit that value by multiplying it by 0.9
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)