How do I create repeated object on platform - infinite jump

0 favourites
  • 10 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi,

    I have started working on infinte jumping project...i want to create a object that should be on platform like this apple on platform

    It Should be repeated randomly when player goes up by jumping..

    I know how to create object at x seconds but this time i want the apple to be ON platform (above platform)...and same should be repeated when game goes on..

    Please let me know the solution

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You need to create a formula for it.

    System -> Spawn the x object at x layer with the x and y as below:

    (I assume you have your origin points at the centre of the platform and of the object.)

    X = floor(random(Platform.X-(Platform.Width+Object.Width)/2 , Platform.X+(Platform.Width+Object.Width)/2))

    This function randomizes a number between the edges of the platform on the x axis.

    Y = floor(Platform.Y+(Platform.Height+Object.Height)/2)

    This function places an object on the top of the platform.

  • itzathis

    Thanks for the reply

    I tried this ..its working..i have created object every 1 sec so its creating that randomly thats good..but when player goes up..object creates under that...can u please check this file

    File Attached

    Waiting for your reply

  • Since I don't understand your problem and what you try to achieve completely, I assume that you want every platform to spawn a single or some amount of coins, lets stick with a single one and being able to change that amount easily.

    I've added an instance variable to the Platform object to check how many coins have been added to it.

    And I've modified the loop to perform an action on each platform object which spawns a coin if Coins On Platform is less than an amount to spawn per platform.

    Also I've centred origin points for Object and Platform + I've deleted the transparency from their sprites.

    Also I fixed the formula for X and Y of coin spawn so it now shows properly : ).

    X = floor(random(Platform.X-Platform.Width/2+Object.Width/2,Platform.X+Platform.Width/2-Object.Width/2))

    Y = floor(Platform.Y-Platform.Height/2-Object.Height/2)

  • Thanku so much i just wanted this thing...i dont want the coin on all platforms so i removed system> for each platform and system every 1 second to 3 second so its working absolutely fine....

    There jus a simple prb that when i play when player goes up... the coin generates that time i mean when am jumping going up coin generates that time side by side.....so we can see when the coin is generating...is it possible that coin would be already generated that means when player goes up by jumping we can the see the coins there already.... is it possible??

    thanks for the reply

  • itzathis

    Waiting for your rep my frnd..

    thanks again

  • Okay, I deleted statements X Is on screen at platform and coin delete event, cause they are not needed(if the other condition is true, X is on screen has to be true so it doesn't matter).

    First lets fix the bug where coins appear after a while when the game starts so we actually can see them spawn.

    So what I'll do, is to create On start of layout + for each platform event and copy the create coin action.

    So this one is fixed, ok.

    Now, the problem you asked for, when we move up, we can see spawning the coins on newly created platforms. There are 2 problems with it. We spawn coins every 3 seconds, so if a platform spawns at time 0, a coin will appear after 3 seconds have passed, so delete this condition. Ok it seems to solve the problem, but I've mentioned 2 problems right? The other one is this:

    http://screencloud.net/v/FWW2

    Your code spawns the red platforms, so they are spawned at the top of the window and move down, but not above it like the blue platforms. To solve the problem you could move the creation point up a little bit so you can be sure the coins will always spawn on them outside the visible area : ).

    Sorry for the long reply but I didnt got a notification that you replied.

  • itzathis

    Thanks Again for your help its really helpful for me...

    Actually last time when i uploaded the file i deleted coin on each platform coz i want the coin to be random not on all platform.....when player goes up coin should be on some of the platforms i mean randomly...it should not be on all platforms...

    is it possible itzathis??

    thanks again

    will wait for the reply

  • Sure it's possible, + it's easy!

    All I had to do is:

    Add a global variable "PlaceACoin" - this variable randomizes if a platform should have a coin placed.

    Then I have modified platform spawn event to be like this:

    http://screencloud.net/v/nhft

    PS: I deleted the On start of the layout event as it worked the same way the event under it : ).

    : )

  • itzathis

    thanks a lot atzathis it really helped me a lot...

    i cant send u pm coz my reputation is less than 300 would like talk to u...add me on skype aashcool07 whenever u r free...

    thanks again man

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