Randomize two tiles and fill the screen

Get help using Construct 2

Post » Sun Dec 08, 2013 9:35 pm

Hi, I'm making a 1942 clone and I need to randomize two tiles, fill the whole screen with them, and then make a vertical scrolling.

Shouldn't be too hard, right?

I could use the Vertical Shooter example but it only uses one "tile" and placement is random.

--- Specific data ---

Let's assume each tile is 32 x 32 pixels and I need to fill a 480 x 640 screen size.
Honestly I can't imagine how to make them spawn both randomly across the screen.
Maybe I can fill the screen with one, then randomly place the other on top? That would be more resource intensive, I think.

And then the scrolling, which I have also no idea how to make it work, since the example is a bit different from what I want to make.notnsane2013-12-08 21:36:43
B
33
S
9
G
1
Posts: 156
Reputation: 3,024

Post » Wed Dec 11, 2013 1:45 am

pimbadumba bump

This is the finished version =P

http://www.youtube.com/watch?v=bupAR6Rbn3Inotnsane2013-12-11 01:48:17
B
33
S
9
G
1
Posts: 156
Reputation: 3,024

Post » Wed Jan 08, 2014 3:29 am

This is one way you could do it. In case anyone else has this question. And keep in mind that my way isn't usually the best way to do it. :-D

First you create your Sprite object. Give it (x) animations. 2 in your case. One for each of the ground tiles you want to move. Make sure to set their hot spot to 0,0 and set the animation speed to 0.

Then you can either create the initial screen full of tiles manually, or run two loops at startup that create tiles on the X and Y axis and then randomize the animation frame. That will fill your screen with tiles. The example I included does this.

Next, you make the tiles move. I use Every 0.05 ms move Tiles 1 pixel at 90 degrees. You can manipulate that later.

Next, in your case, your window height is 640. So... make an event that checks the tile Y position. That same event will need another event called "For Each Object" to make sure every tile creates this action, not just the first one. If the Y position is below 640, delete the tile, and create a new tile at X coordinate(tile.x), Y coordinate(-32), then set that tile's animation frame to random(2)

That should do it. And since I suck Raptor-turds at explaining, I included a capx. You'll need C2 version 146 or higher. (I think)

Capx: https://db.tt/N7S3i683
B
6
S
1
Posts: 21
Reputation: 617

Post » Wed Jan 08, 2014 4:42 am

Thanks!

I worked a bit more on this and could make it work with the Wrap behaviour. It's not 100% random but it really does the job for this game.

If someone wants to replicate it:

- Enable Wrap Behavior on the "Stars" sprite.
- Disable or Delete the whole "Destroying Bottom Stars..." Group Event.
- Change the Repeat of the first loop to one more (22 + 1)
B
33
S
9
G
1
Posts: 156
Reputation: 3,024


Return to How do I....?

Who is online

Users browsing this forum: ksiads, MathewHarrison, mtnboy22 and 1 guest