Discuss Scratch

Vlady_1
New Scratcher
4 posts

list of positions question

Hi guys!
I'm trying to find the solution for my task, which is to move objects from on position to another. I have used exact coordinates for every single object in a starting position, then tried to move objects with steps and direction, but it didn't work well. I prefer to have a list of coordinates each of it has to be connected to a number or a letter so I can write just a letter and object will move there.
I have looked into DATA–list, think it is not relevant.
Does anyone know a solution?
tnx
gor-dee
Scratcher
1000+ posts

list of positions question

There's always
glide () secs to x: (0) y: (0)
footsocktoe
Scratcher
1000+ posts

list of positions question

Vlady_1 wrote:

Hi guys!
I'm trying to find the solution for my task, which is to move objects from on position to another. I have used exact coordinates for every single object in a starting position, then tried to move objects with steps and direction, but it didn't work well. I prefer to have a list of coordinates each of it has to be connected to a number or a letter so I can write just a letter and object will move there.
I have looked into DATA–list, think it is not relevant.
Does anyone know a solution?
tnx

If you prefer to have a list of coordinates then the list type of data is very relevant. You could either have one list or two lists or four lists.

With four lists, each list would handle either the x or the y coordinate for either position 1 or position 2.

With 2 lists you have two options, a list of position 1 the x and y coordinates and a list of position 2 the x and y coordinates OR a list of x coordinates for position 1 and 2 and a list of y coordinates for positions 1 and 2.

And 1 list would of course combine everything into 1 list. Each item of the list would contain the x and y coordinates for both position 1 and position 2.
Vlady_1
New Scratcher
4 posts

list of positions question

Thanks footsocktoe, I think two lists with x and y coordinates would be perfect. Can you explain of show example how to use these lists with glide to or similar block?

Last edited by Vlady_1 (Jan. 22, 2017 11:59:08)

footsocktoe
Scratcher
1000+ posts

list of positions question

Vlady_1 wrote:

Thanks footsocktoe, I think two lists with x and y coordinate
s would be perfect. Can you explain of show example how to use these lists with glide to or similar block?


I'll demo one list. The idea can be extended to more lists.

Call the x position you are gliding to “xglide” and the list of x coordinate “xglides list” and the index that moves through the list is “xglides list index”

set [xglides list index v] to [1]
repeat until<(xglides list index) > (length of [xglides list v] :: list)>
glide () secs to x: (item ( xglides list index) of [xglides list v] :: list) y: ()
change [xglides list index v] by (1)
end

Or you can call up any particular glide by using the xglides list index number for that glide.

Last edited by footsocktoe (Jan. 22, 2017 13:11:26)

asivi
Scratcher
1000+ posts

list of positions question

Hi, i think https://scratch.mit.edu/projects/141244633 could helps you.
Vlady_1
New Scratcher
4 posts

list of positions question

Thanks a lot!
I got it, but more questions appeared
For example, what have I done wrong in script below:
Sprite 2
when green flag clicked
repeat until <not <touching [ sprite 1] ?>>
glide (1) secs to x: (pick random (1) to (4 of the list x)) y: (pick random (1) to (4 of the list y))
end

hope this will look like blocks

Last edited by Vlady_1 (Jan. 22, 2017 15:18:06)

Vlady_1
New Scratcher
4 posts

list of positions question

Vlady_1 wrote:

Thanks a lot!
I got it, but more questions appeared
For example, what have I done wrong in script below:
Sprite 2
when green flag clicked
repeat until <not <touching [ sprite 1] ?>>
glide (1) secs to x: (pick random (1) to (4 of the list x)) y: (pick random (1) to (4 of the list y))
end

hope this will look like blocks

I have two lists for two axis , 4 points in each
footsocktoe
Scratcher
1000+ posts

list of positions question

Vlady_1 wrote:

Vlady_1 wrote:

Thanks a lot!
I got it, but more questions appeared
For example, what have I done wrong in script below:
Sprite 2
when green flag clicked
repeat until <not <touching [ sprite 1] ?>>
glide (1) secs to x: (pick random (1) to (4 of the list x)) y: (pick random (1) to (4 of the list y))
end

hope this will look like blocks

I have two lists for two axis , 4 points in each

Incorrect use of the item selector for the list.
First pick a random number, THEN pick the item with that number.
Romial2012
Scratcher
7 posts

list of positions question

when green flag clicked
forever
add [cool dude] to [list v]
say []
end
Infinity-Studios5674
Scratcher
100+ posts

list of positions question

Romial2012 wrote:

when green flag clicked
forever
add [cool dude] to [list v]
say []
end

Necropost
VilladeOnScratch
Scratcher
51 posts

list of positions question

Infinity-Studios5674 wrote:

Romial2012 wrote:

when green flag clicked
forever
add [cool dude] to [list v]
say []
end

Necropost
Necropost
medians
Scratcher
1000+ posts

list of positions question

VilladeOnScratch wrote:

Infinity-Studios5674 wrote:

Romial2012 wrote:

when green flag clicked
forever
add [cool dude] to [list v]
say []
end

Necropost
Necropost
Please do not do that. Also, if you want it to randomize through all items, you can use item (random v) of [list v] instead of the above. If you want it to do the closest or farthest, I have a project to get the min and max of a list, and you can just use this with the distance formula.

Last edited by medians (July 29, 2023 13:13:14)

cosmosaura
Scratch Team
1000+ posts

list of positions question

Topic closed to prevent future necroposts.

Powered by DjangoBB