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

#1 2010-07-24 07:24:32

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

calculation help :S

I'm working on a project where people can snap certain objects to a grid, and the grid point is indicated by a stamped dot (square sprite with a dot drawn on it). At the beginning, the user chooses their canvas size (height and width) so they could have 20 dots by 50 dots.

What I want to do is that if the user chooses a 4X4 square, the dot sprite will stamp 16 very large dots on the screen, making it as big as possible on the screen so it can easily be seen. However, if the user were to choose a 100X100 grid, the sprite would draw smaller dots and scale it again so that the dots spread as far a possible across the stage...

The calculation for this stumps me. Any discussion and help would be good  smile

let us assume the dot stamping sprite is normally 10X10 pixils in size.

Last edited by sparks (2010-07-24 07:26:14)


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#2 2010-07-24 07:27:35

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: calculation help :S

Let me try some things out  big_smile


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#3 2010-07-24 07:30:08

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: calculation help :S

I'm experimenting too  hmm  I know how to make things snap to a grid, it's making the grid the right size and stamping the right times onto it that is the problem  smile


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#4 2010-07-24 07:47:46

colorfusion
Scratcher
Registered: 2009-10-03
Posts: 500+

Re: calculation help :S

Here is a snap to grid script:

http://i29.tinypic.com/24wxeab.jpg

Not sure what you mean by the other part though.
Change all the 20s to what you want.

Offline

 

#5 2010-07-24 07:48:55

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: calculation help :S

Ok, this is what I came up with.
http://scratch.mit.edu/projects/JSOlabs/1210204

I it's not what you're looking for, then I probably just misunderstood your problem xD Just tell me


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#6 2010-07-24 08:15:27

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: calculation help :S

Look at my game on advance wars. It has a sensing script and may come in handy...
Link:
http://scratch.mit.edu/projects/johnnydean1/1092100

Last edited by johnnydean1 (2010-07-24 08:16:00)


You can now reach me on Twitter @johnnydean1_

Offline

 

#7 2010-07-24 08:16:50

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: calculation help :S

That is almost exatly what I need, the one problem is that as it's supposed to be simulating a stripboard, the gap between each hole needs to be the same distance from it's neighbors as the others, wheras in the case of your project, if you do something like 10X2, the gaps between the rows and the gap between the columns are different...

Last edited by sparks (2010-07-24 08:23:54)


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#8 2010-07-24 08:38:03

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: calculation help :S

Oh, so it should not always fill the whole screen? It's an easy fix actually.
http://scratch.mit.edu/projects/JSOlabs/1210255

Is this better?


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#9 2010-07-24 08:40:33

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: calculation help :S

that's a lot better  smile  thank you very much! Is it ok if I use that with credit?


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#10 2010-07-24 08:42:34

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: calculation help :S

Of course you can use that xDxD I wouldn't have made it otherwise, right? But thanks for asking  wink


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

Board footer