This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-10-01 07:34:26

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

Perfect square rotation on a "solid" platform

This is for enginenumber9.

NOTE THAT THIS IS FOR A SQUARE WITH A SIZE OF 20 PIXELS, YOU WILL NEED ALL NEW CODE FOR ONES OTHER THAN 2O PIXELS.

First, you need a list. Go to the variables section and click the [make a list] button. Title the list "turn". Add these values to it:

1
1
2
2
3
3
4
4
4
4
4
4
4
3
3
2
2
1
1
0

You also need variables called:
y
iterator

Here's the code:

Code:

[set [y] to (y position)]          This sets the variable "y" to the square's y position.
[set [iterator] to [0]]          This sets "iterator" to 0.
[repeat (20)]          This repeats the blocks inside of the repeat 20 times.
[][change [iterator] by (1)]          This changes "iterator" by 1.
[][turn ↴ (4.5) degrees]          This turns the square 4.5 degrees clockwise.
[][change x by (1)]          This changes the square's x position by 1.
[][set y to ((y) + (item (iterator) of [turn]))]          This is the most important part - It elevates the square off the platform exactly the right amount to make it appear as if it is standing on it corner, or side, etc.
[           ]
[point in direction (90)]          This resets it to the right direction.

Offline

 

#2 2009-10-01 07:38:34

deatheater
Scratcher
Registered: 2008-04-11
Posts: 1000+

Re: Perfect square rotation on a "solid" platform

and what does this do?

Offline

 

Board footer