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

#1 2012-09-04 12:15:45

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Grid+dragging?

I'm making an OS with an app store and recycle bin, and I need a script to have the apps be able to be dragged in a grid.  Is that possible?


Alt of Firedrake969.

Offline

 

#2 2012-09-04 12:23:13

BirdByte
Scratcher
Registered: 2012-07-07
Posts: 1000+

Re: Grid+dragging?

Yeah.

when [icon] clicked
set [offsetx v] to ((mouse x) - (x position))
set [offsety v] to ((mouse y) - (y position))
repeat until <not <mouse down?>>
 go to x: ((mouse x) + (offsetx)) y: ((mouse y) + (offsety))
end
go to x: ((round ((x position) / (grid cell width))) * (grid cell width)) y: ((round ((y position) / (grid cell height))) * (grid cell height))
That should work.  smile

Last edited by BirdByte (2012-09-04 12:23:34)


http://i50.tinypic.com/312u714.jpg

Offline

 

#3 2012-09-04 12:23:57

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: Grid+dragging?

BirdByte wrote:

Yeah.

when [icon] clicked
set [offsetx v] to ((mouse x) - (x position))
set [offsety v] to ((mouse y) - (y position))
repeat until <not <mouse down?>>
 go to x: ((mouse x) + (offsetx)) y: ((mouse y) + (offsety))
end
go to x: ((round ((x position) / (grid cell width)) * (grid cell width)) y: ((round ((y position) / (grid cell height)) * (grid cell height))
That should work.  smile

Hmmm... can you fix the go to x: block?  It doesn't seem to work...


Alt of Firedrake969.

Offline

 

#4 2012-09-04 12:25:44

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Grid+dragging?

Yes, that's possible.
Assuming you're using a 40pixel per box type of grid:

when gf clicked
forever
go to [mouse-pointer v]
go to x: ((round ((x position) / (40))) * (40)) y: ((round ((y position) / (40))) * (40))
end

Last edited by fg123 (2012-09-04 12:28:53)


Hai.

Offline

 

#5 2012-09-04 12:27:33

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: Grid+dragging?

Oh you fixed it just as I posted.  Too bad I can't edit.


Alt of Firedrake969.

Offline

 

#6 2012-09-04 12:29:15

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Grid+dragging?

Yea, sorry bout that, bit of trouble with Scratchblocks.


Hai.

Offline

 

#7 2012-09-04 12:30:47

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: Grid+dragging?

fg123 wrote:

Yes, that's possible.
Assuming you're using a 20pixel per box type of grid:

when gf clicked
forever
go to [mouse-pointer v]
go to x: (round((x position) / (20)) * (20) y:  (round((y position) / (20)) * (20)
end

I want it dragged, not going to the mouse.
And so many errors that I was going to fix.  Darn 180 second rule.
And it was at BirdByte.


Alt of Firedrake969.

Offline

 

#8 2012-09-04 12:40:49

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Grid+dragging?

Oh right, I didn't see BirdByte's post. Yea, his version will work. Just on a different principle. Mine is the super basic version, but yea.


Hai.

Offline

 

#9 2012-09-04 12:46:12

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: Grid+dragging?

fg123 wrote:

Oh right, I didn't see BirdByte's post. Yea, his version will work. Just on a different principle. Mine is the super basic version, but yea.

Yea, I made a quick, fail test on that.  It failed but worked.


Alt of Firedrake969.

Offline

 

#10 2012-09-04 14:52:20

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: Grid+dragging?

[offtopic]
@ firedrake: we must all have some sympathy for BirdByte about the new scratcher status.
[/offtopic]
Just done a test and fg123's script works.

Last edited by JH1010 (2012-09-04 14:55:39)

Offline

 

#11 2012-09-04 18:52:01

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Grid+dragging?

JH1010 wrote:

[offtopic]
@ firedrake: we must all have some sympathy for BirdByte about the new scratcher status.
[/offtopic]
Just done a test and fg123's script works.

I don't want it going to the mouse in a grid.  And BB isn't a New Scratcher anymore.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#12 2012-09-05 10:52:27

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Grid+dragging?

Firedrake969 wrote:

JH1010 wrote:

[offtopic]
@ firedrake: we must all have some sympathy for BirdByte about the new scratcher status.
[/offtopic]
Just done a test and fg123's script works.

I don't want it going to the mouse in a grid.  And BB isn't a New Scratcher anymore.

What do you want then?


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#13 2012-09-05 12:10:55

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: Grid+dragging?

zammer990 wrote:

Firedrake969 wrote:

JH1010 wrote:

[offtopic]
@ firedrake: we must all have some sympathy for BirdByte about the new scratcher status.
[/offtopic]
Just done a test and fg123's script works.

I don't want it going to the mouse in a grid.  And BB isn't a New Scratcher anymore.

What do you want then?

Nothing now.  I know what I need.


Alt of Firedrake969.

Offline

 

Board footer