Generate objects in shapes

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi,

    I was wondering if anyone here have any examples or samples on how to create objects and have them appear in certain shapes.

    Like for an example, a bunch of coins appearing in the shape of squares or pyramids.

    <img src="http://i44.tinypic.com/i4pks5.jpg" border="0" />

    I tried playing around with 2 For loops but results were disastrous.

    Any help is very much appreciated. Thank you.

  • An array is what you are after! Are you comfortable with arrays? If not, you should read the tutorial 'arrays for beginners'.

  • I just took a quick look at the Arrays for Beginners and I think I get the idea.

    Will give it a try later on. Thanks!

  • I'm still having trouble with 2D array, even after following the example from the 'Arrays for Beginners'.

    Does anyone have any other examples I can follow?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No need to use an array just use two for loops. In fact the array wouldn't help in the case of the triangle.

    For a 3x3 square whose top left is at x,y do this:

    Global number x=100

    Global number y=30

    Start of layout

    For "row" from 0 to 2

    For "col" from 0 to 2

    --- create sprite at 32*loopindex("col")+x, 32*loopindex("row")+y

    And for a triangle do this:

    Start of layout

    For "row" from 0 to 2

    For "col" from 0 to loopindex("row")

    --- create sprite at 32*loopindex("col")+x, 32*loopindex("row")+y

  • No need to use an array just use two for loops. In fact the array wouldn't help in the case of the triangle.

    For a 3x3 square whose top left is at x,y do this:

    Global number x=100

    Global number y=30

    Start of layout

    For "row" from 0 to 2

    For "col" from 0 to 2

    --- create sprite at 32*loopindex("col")+x, 32*loopindex("row")+y

    And for a triangle do this:

    Start of layout

    For "row" from 0 to 2

    For "col" from 0 to loopindex("row")

    --- create sprite at 32*loopindex("col")+x, 32*loopindex("row")+y

    Thanks! Will try it out.

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