random object placement

This forum is currently in read-only mode.
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi I am rather new to Construct and I wish to know how to make it so it creates explosions every 3 seconds at random between 1024 x 768 (the screen size, plus the scrolling so it follows the screen) is this possible to do and how?

    thanks in advance.

  • + Every 3000 milliseconds
    + System: Create object explosionSprite
        -> explosionSprite: Set X to random(1024)
        -> explosionSprite: Set Y to random(768)
    [/code:fgbsn79e]
    
    Don't know what you mean about making it scroll, though.  Objects scroll along with the screen automatically.
  • > + Every 3000 milliseconds
    + System: Create object explosionSprite
        -> explosionSprite: Set X to random(1024)
        -> explosionSprite: Set Y to random(768)
    [/code:3mcagpfl]
    
    Don't know what you mean about making it scroll, though.  Objects scroll along with the screen automatically.
    

    I'm thinking he wants the explosions on screen locked to the scrolling and to continue on as the play area scrolls (like flying through AA flak during the war, explosions all around you). In which case Aquadragon, just do what deadeye said, but change the random size to take into account your entire play area. But remember you'll have to increase the speed or you wont see them as often. That and maybe copy the action a couple of times (looks pretty good with lots on screen at once, just needs some smoking trails on missiles and it'll be like BSG!).

    Example

    Download Cap

  • An alternate (and, in my opinion, better) method to have them occur within the bounds of the current screen is to use...

    + System: Every 3000 milliseconds
    -> System: Create object Sprite on layer 1 at (ScrollXLeft+Random(1024), ScrollYTop+Random(768))
    [/code:1ag7n1xa]
    
    This will make sure the objects only spawn within the bounds of the screen. Lost My Keys' method will work, but it's not as efficient, and much less so as the layout gets larger. (Plus, there's no guarantee that the objects will actually spawn on the player's screen).
    
    The "create object" command is found in system, and "ScrollXLeft" and "ScrollYTop" are also found in the "system" properties.
    
    Edit: For a more pleasing effect where each explosion is also randomly offset in time, try something like... [code:1ag7n1xa]+ System: Every 2000 +Random(1000) milliseconds
    -> yada yada[/code:1ag7n1xa]
    
    This will have each explosion go off at not only a random part of the screen, but also a slightly random time.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Why don't you just use particles, and have the x, and y randomizer set to screen width, and screen height?

  • Why don't you just use particles, and have the x, and y randomizer set to screen width, and screen height?

    This is probably more efficient. Still, add the scroll offset as Stargoat (lol) said.

  • Why don't you just use particles, and have the x, and y randomizer set to screen width, and screen height?

    I guess it would depend on what you'd want to do with the explosions. If you wanted them to, say, interact with other objects in the game, particles wouldn't cut it. Also, I don't believe particles can have animations.

    Edit:

    This is probably more efficient. Still, add the scroll offset as Stargoat (lol) said.

    What's funny?

  • I don't think he meant any offense... and Stargoat is a pretty funny name

  • it's awesomely funny. How do you guys land on your nicknames? I could never grow out of the first one I ever used.

  • it's awesomely funny. How do you guys land on your nicknames? I could never grow out of the first one I ever used.

    I picked mine cause I'd lost my keys at the time. They were under my hat, but I don't think to look in obvious places like that, heh.

    You should start a where did your nickname come from thread

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