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 clicked
add
x position
to
co-ordinates list
add
y position
to
co-ordinates list

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 clicked
add
x position
to
co-ordinates list
add
y position
to
co-ordinates list

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 clicked
forever
delete
all
of
notex
delete
all
of
notey
add
x position
of
note1
to
notex
add
y position
of
note1
to
notey
add
x position
of
note2
to
notex
add
y position
of
note2
to
notey
add
x position
of
note3
to
notex
add
y position
of
note3
to
notey
add
x position
of
note4
to
notex
add
y position
of
note4
to
notey
add
x position
of
note5
to
notex
add
y position
of
note5
to
notey
add
x position
of
note6
to
notex
add
y position
of
note6
to
notey
add
x position
of
note7
to
notex
add
y position
of
note7
to
notey
add
x position
of
note8
to
notex
add
y position
of
note8
to
notey
add
x position
of
note9
to
notex
add
y position
of
note9
to
notey
add
x position
of
note10
to
notex
add
y position
of
note10
to
notey

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
of
list
add
join
(abs ([x position v] of [note 1 v]))
abs ([y position v] of [note 1 v])
*
-1
to
list
if
letter
1
of
x position
=
-
replace
item
last
of
list
with
join
item
last
of
list
-
else
replace
item
last
of
list
with
join
item
last
of
list
0
if
letter
1
of
y position
=
-
replace
item
last
of
list
with
join
item
last
of
list
-
else
replace
item
last
of
list
with
join
item
last
of
list
0

Then to get the values back:
set
counter
to
1
repeat
length of
list
set
letter
to
1
repeat until
set
x
to
change
letter
by
1
change
letter
by
1
repeat until
set
y
to
join
y
letter
letter
of
item
counter
of
list
change
letter
by
1
set
x
to
join
letter (length of (item (counter) of [list v])) - (1)
x
)
set
y
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
of
list
add
join
abs
of
x position
of
note 1
abs
of
y position
of
note 1
*
-1
to
list
if
letter
1
of
x position
=
-
replace item
last
of
list
with
join
item
last
of
list
-
else
replace item
last
of
list
with
join
item
last
of
list
0
if
letter
1
of
y position
=
-
replace item
last
of
list
with
join
item
last
of
list
-
else
replace item
last
of
list
with
join
item
last
of
list
0

Then to get the values back:
set
counter
to
1
repeat
length of
list
set
letter
to
1
repeat until
letter
letter
of
item
counter
of
list
=
-
set
x
to
join
x
letter
letter
of
item
counter
of
list
change
letter
by
1
change
letter
by
1
repeat until
letter
>
length of
item
counter
of
list
set
y
to
join
y
letter
letter
of
item
counter
of
list
change
letter
by
1
set
x
to
join
letter
length of
item
counter
of
list
of
1
x
set
y
to
join
letter
length of
item
counter
of
list
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