create sprites randomly on 9 points

0 favourites
  • 6 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • hey you out there,

    i whonder how to do the following:

    within a certain time, i.e. 30 seconds, i wanna create a certain number of sprites (lets say 20) spread on 9 points.

    Imagine: 3 columns & 3 rows, so there are 9 objects in the grid .

    1. the sprites are to be created randomly on these 9 points

    2. the sprites shouldnt appear in a foreseeable intervall, so i guess it must be something like:

         "create the second item after the first was created (and so on), within a time of (i.e.)2 seconds",

         but it should be a random time-value, otherwise it`s boring.

    3. it`s not allowed to create more than 1 object at the same time (this would be unfair towards the player).

    4. it`s not allowed to create more than 1 object at the same time at the same position.

    My idea was to store 9 x&y coordinates with the sprites within an array.

    But as i read it`s not possible to store sprites in an array,right?

    So, i guess i have to store the 9 x/y values and connect them/ make a bridge to the sprite-instances?!

    This is a crucial point for me right now.(just one of plenty <img src="smileys/smiley2.gif" border="0" align="middle" /> )

    I think (maybe to simple):

    • i create an array with 9 values
    • each array-value [from 0-8] has specific x & y values-

    -choose randomly array-value

    ...but hell...how do i do this ?

    Thanks for reading, suggestions, hints....

  • it can be as easy as this

    random9sprites.capx

  • pffff....now this is amazing!

    but where are the grfx? sprite is set visible but i dont see any grafx???

    a lot to learn i have, i guess <img src="smileys/smiley3.gif" border="0" align="middle" />

    thnx Yann, this is great! <img src="smileys/smiley10.gif" border="0" align="middle" /> <img src="smileys/smiley10.gif" border="0" align="middle" /> <img src="smileys/smiley10.gif" border="0" align="middle" />

    though i dont understand right now, whats happening here...<img src="smileys/smiley5.gif" border="0" align="middle" />

    have a nice weekend!!

  • the first animation frame is just empty, and the nine sprites are already created and positionned (snap feature helps for that)

    Every 'next' seconds I just set the current sprite to frame 0 (empty) and randomly pick one sprite amongst the eight other sprites and set its animation frame to a random integer between 1 and 20.

  • the first animation frame is just empty, and the nine sprites are already created and positionned (snap feature helps for that)

    Every 'next' seconds I just set the current sprite to frame 0 (empty) and randomly pick one sprite amongst the eight other sprites and set its animation frame to a random integer between 1 and 20.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok,now i understand. This is clever.

    thnx a lot for your explanation <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)