Grouping and Random Generations of Groups?

Forum Home Forum Home > Construct 2 General > How do I....?
 Post Reply Post Reply
Author
673 Rep
Post Options Post Options   Quote ColPhilBilko Quote  Post ReplyReply Direct Link To This Post 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?

Thanks in advance for your time.
Back to Top
11,725 Rep
Post Options Post Options   Quote Yann Quote  Post ReplyReply Direct Link To This Post 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,1
0,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)
Back to Top
779 Rep
Post Options Post Options   Quote exertia Quote  Post ReplyReply Direct Link To This Post Posted: 11 Aug 2012 at 4:40pm
Originally posted by Yann 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,1
0,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!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down