Spawn random at exact increments?

0 favourites
  • 11 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • I was wondering if anyone knows of a system expression to spawn a sprite randomly at 32 pixel increments?

    Like this:

    <img src="http://i49.tinypic.com/ixa353.png" border="0" />

    I thought I had this figured out sometime last year but I cant find my old .capx, and for the life of me I just cant figure it out again.

    On start of layout --> System create object Sprite random(?), ?

    Any help would be greatly appreciated.

  • LightResponse !

    First of all ... Set your object origin to 0,0

    Then ...

    Just add ;

    Create object (floor((wantedX)/32),floor((wantedY)/32))

    Here we go ,

    You are pretty lucky I'm currently making a grid-pased proceduraly generated dungeon crawler :P

    Cheers...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Whiteclaws Thank you but I cant seem to get those expressions to work with what I am trying to accomplish.

    Perhaps I haven't properly explained what I am trying to do. On the start of my layout I will be destroying the sprite. Then I want to spawn just one sprite randomly on my layout at specific 32 pixel grid based distances.

    Here is a simple .capx with the sprite set to be destroyed on start of layout in case you or someone else has an idea on how I can accomplish this with system expressions:

    https://dl.dropbox.com/u/43763487/examples/random.capx

  • Ahh, I see what I was doing wrong now.

    Thank you very much Whiteclaws <img src="smileys/smiley1.gif" border="0" align="middle" /> that's exactly what I wanted.

    It works perfect <img src="smileys/smiley4.gif" border="0" align="middle" />

  • Always happy to help people who helped me when I was a n00b <img src="smileys/smiley2.gif" border="0" align="middle" />

  • Whiteclaws I think I might have spoke to soon.

    It seems that your code only randomly spawns the sprite inside of the first 32 pixels. I was hoping it would spawn randomly across to whole layout at 32 pixel increments. Maybe this just isn't possible.

    Thanks anyway for trying to help me.

  • Well , Just remplace the "/32" by "/16" , and that'll do the job !

  • Here is another example:

    Random grid spawn

  • Here we go , Updated the capx. !

  • vee41 Thank you very much it works great! <img src="smileys/smiley4.gif" border="0" align="middle" />

    4 global variables, and a few events. Brilliant!

    Whiteclaws It has the same problem as before it only randomly spawns the sprite inside of the first 32 pixels in the top left corner of the layout.

    That's ok though vee41's solution works just fine with my game project.

    Thank you both for your help <img src="smileys/smiley1.gif" border="0" align="middle" />

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