Discuss Scratch

egashu
Scratcher
100+ posts

how to make clones spawn in different positions

I am making a scroller game and I am trying to make these little dots go to random position and stay there but keep making clones (with scroll x but I already am done with the scroll x part) I just need help with the clones staying in the same position please help!!!
2Dproductions
Scratcher
500+ posts

how to make clones spawn in different positions

in your main put
forevergotox:pickrandom-240to240y:pickrandom-180to180createcloneofmyselfwhenIstartasaclonedosomethinghere
egashu
Scratcher
100+ posts

how to make clones spawn in different positions

thanks!!! I'll see if that works
deck26
Scratcher
1000+ posts

how to make clones spawn in different positions

If it's a scroller each clone needs to know where it is in ‘real world’ terms. It can then apply scrollx/y to that position to give the current screen position.
egashu
Scratcher
100+ posts

how to make clones spawn in different positions

?
deck26
Scratcher
1000+ posts

how to make clones spawn in different positions

I assume you don't understand my last post. I'm assuming you're scrolling around a ‘real world’ so the Scratch screen is showing you one part of that world which changes as you move around. I'm also assuming the clones might be anywhere in that real world and you want them to maintain their real world position so they only appear when you happen to be in the right area.

So if the screen was 10 x 10 units and the world was 100 units by 100 units you're only seeing a small area of the world. When you move around you'd find clones which were positioned according to real world coordinates and are only shown on screen when the screen area includes that real world position. If the screen is centred at real world 25,35 you'd only see clones in the range x=20 to 30, y=30 to 40. I've simplified things here - you'd probably be working with pixels and the screen being 480 x 360 with the real world being scaled up in the same way.

If that is all correct.and the clones don't move then you can work out the screen coordinates by adjusting real world coordinates by scrollx/y. If the adjusted values fall within the normal screen range you show the clone in the adjusted position. In my example, the screen perhaps starts at 5, 5 with scrollx/y=0. As you move right scrollx becomes negative so when the screen is at 25,35 the scrollx/y values are -20 and -30. If you have a clone at 27, 35 the screen-x value would be 27 - 25 = 2 and screen-y would be 35 - 30 = 5 which would place the clone correctly relative to the screen centre - 2 units right of centre on the centre line vertically. Move the player another two pixels right and the screen would be at 27, 35 which matches the clone's position and the clone's adjusted position would be 0,0 as required.
IamNotlegend
Scratcher
3 posts

how to make clones spawn in different positions

move78steps
lol
IamNotlegend
Scratcher
3 posts

how to make clones spawn in different positions

Try this for a steady movement and not go off border you want



whenclickedforeverifkeyUp arrowpressed?andyposition< The Number you want it to not go pastthenmove-10stepsifkeydown arrowpressed?andyposition>The number you want it to not go pastthenmove10steps

Last edited by IamNotlegend (April 15, 2022 18:13:54)

The-Molten-Freddy
Scratcher
500+ posts

how to make clones spawn in different positions

egashu wrote:

I am making a scroller game and I am trying to make these little dots go to random position and stay there but keep making clones (with scroll x but I already am done with the scroll x part) I just need help with the clones staying in the same position please help!!!
If you want to spawn a clone in a different position every time, this is what you do.
whenIstartasaclonegotorandom position
IamNotlegend
Scratcher
3 posts

how to make clones spawn in different positions

The-Molten-Freddy wrote:

egashu wrote:

I am making a scroller game and I am trying to make these little dots go to random position and stay there but keep making clones (with scroll x but I already am done with the scroll x part) I just need help with the clones staying in the same position please help!!!
If you want to spawn a clone in a different position every time, this is what you do.
whenIstartasaclonegotorandom position
good
Zender_Pig
Scratcher
1 post

how to make clones spawn in different positions

.
ronnierooninja
Scratcher
1 post

how to make clones spawn in different positions

lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
_turtle64
Scratcher
100+ posts

how to make clones spawn in different positions

Zender_Pig wrote:

.
Dont necropost. This question is almost 4 years old.

Powered by DjangoBB