Step 5: Overflowing apples onto the next line

If we have a really large numerator or denominator, the apples will keep getting created and will move outside our view of the game.

To prevent this, we can check the position of the latest apple, and if it is too far across we can bump its y position down and reset its x position so that it appears on a new line (as shown below).

To check how far along the apple is, grab the "if" block (from Control Flow) and drag it above the "create new instance" block. Connect a ">" block to the "if" block.

The game screen is 768 pixels wide, so we'll check if the x position of the first apple is greater than 700.

Then we'll reposition the first apple to have an x position of 50 pixels across, and a y position of its current y position increased by 50. This will bump it down and back to the left.

Next we'll repeat the previous two steps for the denominator, and display the denominator apples semi-transparently.

results matching ""

    No results matching ""