0 Reputation

# Grouping and Random Generations of Groups?

Forum Home > Construct 2 General > How do I....?
Author
Topic Search   Topic Options
673 Rep
Post Options    Quote  Reply Topic: Grouping and Random Generations of Groups?
Posted: 18 Mar 2012 at 12:05pm
Hello all;

Ok I have a bit of a question, I am new to this product and I am still feeling around in the dark a little. So I thought I would post here for help.

What I need to do is have a group of sprites placed together in a couple different shapes, kinda like Tetris shapes. However each block in the shape is its own color, and this is where the random colors part needs to take over. So say for arguments sake, it is a "L" shaped tetris piece, mine would have 5 colored blocks making up that same shape. which would be randomly generated before it comes onto the scene. Each color block would also have its own behaviors attached to it for color matching e.t.c But first I want to get the movement and random block generation completed. They need to be grouped together because the player will have the option to move left to right or rotate said objects.

Where do I start to get this working?

11,725 Rep
Post Options    Quote  Reply Posted: 18 Mar 2012 at 1:14pm
I did a tetris game some weeks ago, and to get the shape I simply wrote down some relative coordinates.

It looked like
 `-2,0|-1,0|0,0|1,0#0,-2|0,-1|0,0|0,10,0|1,0|0,-1|1,1-1,0|0,0|1,0|0,-1#0,-1|0,0|0,1|1,0#-1,0|0,0|1,0|0,1#0,-1|0,0|0,1|-1,0-1,0|0,0|0,-1|1,-1#-1,-1|-1,0|0,0|0,1-1,-1|0,-1|0,0|1,0#0,1|0,0|1,0|1,-1-1,0|0,0|1,0|1,1#0,1|0,0|0,-1|1,-1#-1,0|-1,1|0,1|1,1#-1,1|0,1|0,0|0,-1-1,1|-1,0|0,0|1,0#1,1|0,1|0,0|0,-1#-1,1|0,1|1,1|1,0#0,1|0,0|0,-1|-1,-1`

With 4 levels of token:
a line break (newline) separates each shapes
a # separates each possible rotation
a | separates each block coordinates
a , separates X and Y coordinates.
Then I just had to select a random line, and to make it simple I just used the first rotation on spawn.
Also note that in tetris all shapes are made of 4 blocks that made things easier too.
Then I just had to know the current shape and move the blocks accordingly.
Tetris always have one shape moving at a time so it made things easy to. I just had to flag the blocks as moving or not (boolean)
779 Rep
Post Options    Quote  Reply Posted: 11 Aug 2012 at 4:40pm
Yann wrote:

I did a tetris game some weeks ago, and to get the shape I simply wrote down some relative coordinates.

It looked like
 `-2,0|-1,0|0,0|1,0#0,-2|0,-1|0,0|0,10,0|1,0|0,-1|1,1-1,0|0,0|1,0|0,-1#0,-1|0,0|0,1|1,0#-1,0|0,0|1,0|0,1#0,-1|0,0|0,1|-1,0-1,0|0,0|0,-1|1,-1#-1,-1|-1,0|0,0|0,1-1,-1|0,-1|0,0|1,0#0,1|0,0|1,0|1,-1-1,0|0,0|1,0|1,1#0,1|0,0|0,-1|1,-1#-1,0|-1,1|0,1|1,1#-1,1|0,1|0,0|0,-1-1,1|-1,0|0,0|1,0#1,1|0,1|0,0|0,-1#-1,1|0,1|1,1|1,0#0,1|0,0|0,-1|-1,-1`

With 4 levels of token:
a line break (newline) separates each shapes
a # separates each possible rotation
a | separates each block coordinates
a , separates X and Y coordinates.
Then I just had to select a random line, and to make it simple I just used the first rotation on spawn.

Can you please elaborate further or provide a sample capx. Thanks!

 Forum Jump -- Select Forum --  Arcade  Construct 2 general  How do I....?  Your Creations  Education  Bugs   - Closed bugs  Plugins for Construct 2  Javascript SDK development  Open Topic  General game design  Tools/resources  Website issues  Help Wanted  Construct Classic Discussion   - Help & Support using Construct Classic   - Your tutorials & example files   - Your Creations   - Completed addons   - Work-in-progress addons   - Construct engineering Forum Permissions You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot delete your posts in this forumYou cannot edit your posts in this forumYou cannot create polls in this forumYou cannot vote in polls in this forum