How do I make it so these squares do the following?

0 favourites
  • 5 posts
From the Asset Store
2 Squares
$2.40 USD
60% off
Turn the center squares so it matches the other.
  • Basically I have the following:

    https://i.gyazo.com/07c313a27d3f61722634569ea87a6c26.png

    1. Firstly I am trying to stop the squares overlapping as per number 7 in my event sheet, with this as it is currently squares randomly disappear as they do that but I don't want them to do that but I dunno how to stop it
    2. Secondly I am trying to make it so up to 4 squares appear along side each other kinda like making a tetris shape but only up to 4 blocks horizontally or vertically but sometimes it will do 1 block or 2 blocks or 3 blocks, how do I achieve this?

    I have also tried it like so:

    https://i.gyazo.com/45fc840e3f069f50457e05ce149f218e.png

    However it resulted in:

    https://i.gyazo.com/fb94d6bcf8dc5a3a7579ef552d188f12.gif

    Where there is only so many places the pink square can go before it runs out of places. It seems better to destroy on any collision or overlap but then I am left with the issue that it randomly destroys it without doing neither a collision or overla.

  • The first problem: When 'Pink' overlaps with 'Pink' it destroys 'Pink'. So it destroys both of them.

    You need to specify in the condition by saying: Pink: Pick Top Instance, then it will destroy the recently created one.

    Yes you can instead just randomly relocate it, instead of destroying.

    I assume you'd want them to be created on a grid-like pattern, instead of randomly scattered? You can make use of the modulo operator % to achieve that. for example:

    PinkSquare Set position: random(192,896) % 64, random(192,896) % 64

    ----

    Second question: So you're trying to make only Tetris-type shapes? In that case, you would 'Pick' a pink square (let's say: Top instance), then 'Spawn' pink. (This will create another Pink on top of it), then just move it Either x by 64 (or -64) or y by 64 (or -64). You can use the choose expression for that. If the squares are symmetrical and square, then this might work nicely:

    PinkSquare Rotate clock-wise: choose(90,-90)

    PinkSquare Move forward: choose(64,-64)

    But make sure to remove the 'destroy' on overlapping, that can cause more problems later, especially when you'll want to actually check for overlapping two different tetris blocks, etc. They'll just destroy.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I just posted the game file at this point: https://www.dropbox.com/t/JDehfgpGpHCHaVul (Expires in 24 hours)

    So I tried using modulo with varying increments up to 512 and this did not solve the issue of overlaps, I also disabled the destroy on overlap part.

    I am not sure what you mean by the second part, so do I create then rotate? I can't see how this makes them into blocks like tetris, although its only vertical and horizontal lines up to a maximum of 4 pink squares and a minimum of 1.

    I also put my overall design here to show better what I am aiming for more clearly:

    https://www.dropbox.com/t/vDAFJn1x56ly1q04

  • Alright so I made a slight mistake in % x,y grid arrangement. What needs to be done is first create it randomly, then adjust it so it's on a grid using: Set Position: Self.X - (Self.X % 128) etc.

    I included a Function called: "checkOverlap", this can be called whenever there is a chance for overlaps, for example: (1) after it has moved to get aligned to grid, or (2) rotate and moved.

    The rotate and moved was only to make it either go LEFT or RIGHT if it's overlap. I was thinking you're trying to make a Tetris like shape (like L or T shape as well). If it's only going to be straight horizontal / vertical lines, then you don't need this. You can remove the 'rotate and move' lines.

    Here are the two items implemented: https://drive.google.com/file/d/1uDhLlU-DI9VUgdJYwYAaROXYTiH9m1Pw/view?usp=sharing

    But I highly recommend re-thinking the strategy on making a pile of blocks, otherwise, wouldn't the blocks just randomly appear adjacent to another pile of blocks? I don't quite understand (even from that pdf) how the game would work really.

  • Thats solved some of my issues at least so thanks. It only needs to be an actual straight line, not actual tetris shapes.

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