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

#1 2012-08-23 12:45:14

humhumgames
Scratcher
Registered: 2012-03-26
Posts: 1000+

Help...

I'm making a project, and I just want to know...

Is there a way to get the x and y position of ten sprites and put them all together in a code/variable and get it so when you enter the (code?), the 10 sprites change position to the coordinates in it? I know. Confusing. >.< I can't figure out how to.

I used BirdByte's scripts, but how can I make the second part?

Here's the link to the project. I need something to record the x and y position of each note sprite, and changes when their x and y position change.

Is it possible?

Last edited by humhumgames (2012-08-24 22:59:53)

Offline

 

#2 2012-08-23 12:48:18

Scratcher456
Scratcher
Registered: 2010-12-04
Posts: 58

Re: Help...

I suppose you could average them all together... it would get awkward if some of them were in negative coordinates, though. I'll see if I can come up with a basic project that would show that.

EDIT: Here you go: http://scratch.mit.edu/projects/Scratcher456/2743323

Last edited by Scratcher456 (2012-08-23 12:57:23)


Mining diamonds, mining diamonds, mining diamonds...

Offline

 

#3 2012-08-23 12:49:51

humhumgames
Scratcher
Registered: 2012-03-26
Posts: 1000+

Re: Help...

I don't think that will work... Averaging them won't help, because the sprites each go to their individual place, and the seperate x and y coordinates for each one should be intact.

I tried something, but it involved lots of variables (A variable for each coordinate XP), and I bet there's an easier way.

Last edited by humhumgames (2012-08-23 12:51:32)

Offline

 

#4 2012-08-23 12:58:51

Scratcher456
Scratcher
Registered: 2010-12-04
Posts: 58

Re: Help...

humhumgames wrote:

I don't think that will work... Averaging them won't help, because the sprites each go to their individual place, and the seperate x and y coordinates for each one should be intact.

I tried something, but it involved lots of variables (A variable for each coordinate XP), and I bet there's an easier way.

Well, I DO have a 'decompiler/ recompiler' that allows you to store all of that data in two lists, one of 'X' values and one of 'Y' values. I could upload that if you wanted. I'll put a link in here if I can get something that works.


Mining diamonds, mining diamonds, mining diamonds...

Offline

 

#5 2012-08-23 13:01:10

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

Re: Help...

A list?

when gf clicked
add <x position> to [co-ordinates list v]
add <y position> to [co-ordinates list v]
Do this for all 10 sprites.

EDIT: @humhumgames: You changed your sig while I was posting!
EDIT: Somebody posted while I was editing!

Last edited by JH1010 (2012-08-23 13:03:18)

Offline

 

#6 2012-08-23 13:02:24

Scratcher456
Scratcher
Registered: 2010-12-04
Posts: 58

Re: Help...

JH1010 wrote:

A list?

when gf clicked
add <x position> to [co-ordinates list v]
add <y position> to [co-ordinates list v]
Do this for all 20 sprites.

That's about what I was thinking, except with a little added scripting so that you could edit the list.


Mining diamonds, mining diamonds, mining diamonds...

Offline

 

#7 2012-08-23 14:40:51

humhumgames
Scratcher
Registered: 2012-03-26
Posts: 1000+

Re: Help...

10 sprites, and my sig changes automatically.  tongue

Anyways, what do you mean by added scripting?

Offline

 

#8 2012-08-24 11:42:13

humhumgames
Scratcher
Registered: 2012-03-26
Posts: 1000+

Re: Help...

Bump. Here's the link to the project. I need something to record the x and y position of each note sprite, and changes when their x and y position change.

Offline

 

#9 2012-08-24 11:47:59

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

Re: Help...

You can use this script...

when gf clicked
forever
 delete (all v) of [notex v]
 delete (all v) of [notey v]
 add ([x position v] of [note1 v]) to [notex v]
 add ([y position v] of [note1 v]) to [notey v]
 add ([x position v] of [note2 v]) to [notex v]
 add ([y position v] of [note2 v]) to [notey v]
 add ([x position v] of [note3 v]) to [notex v]
 add ([y position v] of [note3 v]) to [notey v]
 add ([x position v] of [note4 v]) to [notex v]
 add ([y position v] of [note4 v]) to [notey v]
 add ([x position v] of [note5 v]) to [notex v]
 add ([y position v] of [note5 v]) to [notey v]
 add ([x position v] of [note6 v]) to [notex v]
 add ([y position v] of [note6 v]) to [notey v]
 add ([x position v] of [note7 v]) to [notex v]
 add ([y position v] of [note7 v]) to [notey v]
 add ([x position v] of [note8 v]) to [notex v]
 add ([y position v] of [note8 v]) to [notey v]
 add ([x position v] of [note9 v]) to [notex v]
 add ([y position v] of [note9 v]) to [notey v]
 add ([x position v] of [note10 v]) to [notex v]
 add ([y position v] of [note10 v]) to [notey v]
end
There you go!


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

Offline

 

#10 2012-08-26 12:55:01

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

Re: Help...

What he said.


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

Offline

 

#11 2012-08-26 13:36:53

Prestige
Scratcher
Registered: 2008-12-15
Posts: 100+

Re: Help...

*scripts are too long and complicated for me to fix and they look incorrect in visual mode. You'll have to quote this and read the text to try and understand what's going on. Sorry about that..

____________

How about:

delete [all v] of [list v]

add (join ((abs ([x position v] of [note 1 v]))) ((abs ([y position v] of [note 1 v])) * (-1))) to [list v]
if <(letter (1) of (x position)) = (-)>
replace (item [last v] of [list v]) with (join (item [last v] of [list v]) (-))
else
replace (item [last v] of [list v]) with (join (item [last v] of [list v]) (0))
end
if <(letter (1) of (y position)) = (-)>
replace (item [last v] of [list v]) with (join (item [last v] of [list v]) (-))
else
replace (item [last v] of [list v]) with (join (item [last v] of [list v]) (0))
end
Then to get the values back:
set [counter v] to (1)
repeat (length of [list v])
set [letter v] to (1)
repeat until <(letter (letter) of (item (counter) of [list v]) = (-)>
set [x v] to (join (x) (letter (letter) of (item (counter) of [list v]))
change [letter v] by (1)
end
change [letter v] by (1)
repeat until <(letter) > (length of (item (counter) of [list v]))
set [y v] to (join (y) (letter (letter) of (item (counter) of [list v])))
change [letter v] by (1)
end
end 
set [x v] to (join (letter (length of (item (counter) of [list v])) - (1))) (x))
set [y v] to (join (letter (length of (item (counter) of [list v])) - (0))) (x))
Then set x and y to the x and y variables. This combines both x and y values in 1 item, instead of 2 to save space  smile

Last edited by Prestige (2012-08-26 13:38:28)


"Don't insult someone until you've walked a mile in their shoes. That way, if they don't like what you have to say, you'll be a mile away and still have their shoes  smile  "

Offline

 

#12 2012-08-26 15:25:40

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Help...

Prestige wrote:

*scripts are too long and complicated for me to fix and they look incorrect in visual mode. You'll have to quote this and read the text to try and understand what's going on. Sorry about that..

____________

How about:

delete [all v] of [list v]

add (join ([abs v] of ([x position v] of [note 1 v])) (([abs v] of ([y position v] of [note 1 v])) * (-1))) to [list v]
if <(letter (1) of (x position)) = (-)>
replace item [last v] of [list v] with (join (item [last v] of [list v]) (-))
else
replace item [last v] of [list v] with (join (item [last v] of [list v]) (0))
end
if <(letter (1) of (y position)) = (-)>
replace item [last v] of [list v] with (join (item [last v] of [list v]) (-))
else
replace item [last v] of [list v] with (join (item [last v] of [list v]) (0))
end
Then to get the values back:
set [counter v] to (1)
repeat (length of [list v])
set [letter v] to (1)
repeat until <(letter (letter) of (item (counter) of [list v])) = (-)>
set [x v] to (join (x) (letter (letter) of (item (counter) of [list v])))
change [letter v] by (1)
end
change [letter v] by (1)
repeat until <(letter) > (length of (item (counter) of [list v]))>
set [y v] to (join (y) (letter (letter) of (item (counter) of [list v])))
change [letter v] by (1)
end
end 
set [x v] to (join (letter (length of (item (counter) of [list v])) of (1)) (x))
set [y v] to (join (letter (length of (item (counter) of [list v])) of (0)) (x))
Then set x and y to the x and y variables. This combines both x and y values in 1 item, instead of 2 to save space  smile

Fixed!

Last edited by ErnieParke (2012-08-26 15:34:19)


http://i46.tinypic.com/35ismmc.png

Offline

 

Board footer