Discuss Scratch

de-a-th
New Scratcher
4 posts

Drawing a shape by coordinates

im making a math game and i want to be able to enter the coordinates of a shape (up to 5 sides) into the game and then the game draw it, but i dont know how, i also need to be able to rotate, reflect and enlarge the shape, any help?
GameNoob
Scratcher
19 posts

Drawing a shape by coordinates

Make sure to have all your coordinates saved in variables.
Now when you make the shape, run this script:

penupgotox:x1y:y1pendowngotox:x2y:y2gotox:x3y:y3gotox:x4y:y4gotox:x1y:y1penup

And you can change the script depending on how many sides you want.
scubajerry
Scratcher
1000+ posts

Drawing a shape by coordinates

Is this a school project? Do you know trig?

Make 2 lists X Y
Put all the points X and Y values in the lists
clear
go to first entry in list
start drawing
de-a-th
New Scratcher
4 posts

Drawing a shape by coordinates

scubajerry wrote:

Is this a school project? Do you know trig?

Make 2 lists X Y
Put all the points X and Y values in the lists
clear
go to first entry in list
start drawing

it is, a very challanging one too since i know nothing about scratch, and i know basic trig
scubajerry
Scratcher
1000+ posts

Drawing a shape by coordinates

After you create your lists ( X and Y).
whenclickeddeleteallofXdeleteallofYuse this to add coordinates to the appropriate lists. This is where you can use a loop and trigsettheta to0repeat5calcuateXandYthis is yours to figure out. Ask if you get stuck.addxtoXaddytoYchangethetaby72
ProdigyZeta7
Scratcher
1000+ posts

Drawing a shape by coordinates

Well, you don't have to put it in lists, scubajerry. An easier, and generalized way to draw regular polygons is this:
definedrawpolygonatcenterxcenterywithnsidesandradiusrsetdirto0repeatn+1gotox:centerx+r*sinofdiry:centery+r*cosofdirpendownchangedirby360/nThe sum of the supplementary angles in a polygon equals 360 degreesthis is to go to all vertices and then back to the starting pointpenup
See the wikipedia page.

Last edited by ProdigyZeta7 (March 23, 2014 00:52:17)

de-a-th
New Scratcher
4 posts

Drawing a shape by coordinates

thank you for all the help but i really dont understand any of it :s
scratch_123450
New Scratcher
2 posts

Drawing a shape by coordinates

Hello all, could you please tell me where can i found a example about how to draw a shape: square, triangle or other by coordinates? thank you!
Paddle2See
Scratch Team
1000+ posts

Drawing a shape by coordinates

scratch_123450 wrote:

Hello all, could you please tell me where can i found a example about how to draw a shape: square, triangle or other by coordinates? thank you!
Use any sprite you want and put this script on it
whenclickedclearpenupgotox:0y:0pendowngotox:100y:0gotox:100y:100gotox:0y:100gotox:0y:0penup

It should draw you a square

Powered by DjangoBB