Discuss Scratch

JereTheJuggler
Scratcher
100+ posts

Suggestion for a new way to clone.

I've been trying to make a “tower defense” style game and I have hit a major roadblock because I need a new way to make clones.

Since You can make many clones of the turrets and have them (almost) anywhere on the screen and they can all be firing at the same time, I need a way to create a clone of my bullet sprite at the turret that fires it.
My suggestion is to make a new
create clone of [Sprite v] at x: [0] y: [0]
block, so I could use it in my turret's script like this:
create clone of [Bullet v] at x: (x position) y: (y position)

I don't really know the nitty-gritty of how Scratch actually works, but I would imagine that when it creates a clone of a sprite, it tells it where to go on screen. If it actually does do that, then I don't see what would make it so hard to make it so you can input a starting x and y coordinate.

Thank you for taking the time to read my suggestion!

Last edited by JereTheJuggler (Nov. 29, 2013 23:00:03)


Check out the rather large library games I've created!
Aqueduct, The Blue Labyrinth, Bubble Breaker!, Glide, Lights Out!, Master of the Elements!, The Monster and Me, Pathmaker, Rope, SIMON, Speed Typing!, Splatformer, Tower Defense!, Video Poker!, Wishy Washy Water, Zombie Shootout!, and many more are on my profile!

Most recent: Aqueduct
Personal favorite: Aqueduct
ProdigyZeta7
Scratcher
1000+ posts

Suggestion for a new way to clone.

Interesting suggestion, but there's an obvious workaround:
//workaround 1
when sprite 1 clicked
go to x: (somewhere X) y: (somewhere Y)
create clone of [bullet v]

when I start as a clone
go to [sprite 1 v]
...

//workaround 2
when sprite 1 clicked
set [somewhere X v] to (somewhere)
set [somewhere Y v] to (somewhere)
create clone of [bullet v]

when I start as a clone
go to x: (somewhere X) y: (somewhere Y)



JereTheJuggler
Scratcher
100+ posts

Suggestion for a new way to clone.

ProdigyZeta7 wrote:

Interesting suggestion, but there's an obvious workaround:
//workaround 1
when sprite 1 clicked
go to x: (somewhere X) y: (somewhere Y)
create clone of [bullet v]

when I start as a clone
go to [sprite 1 v]
...

//workaround 2
when sprite 1 clicked
set [somewhere X v] to (somewhere)
set [somewhere Y v] to (somewhere)
create clone of [bullet v]

when I start as a clone
go to x: (somewhere X) y: (somewhere Y)
Well, you are right about that being an obvious solution; however, with many turrets firing at the same time and constantly changing the variables for the starting x and y positions, the odds of one turret overwriting the variable information from the last turret before its bullet gets shot increases as you add more turrets.

Workaround 1 also doesn't work because I would be telling the bullet to go to a clone of the turret.

Last edited by JereTheJuggler (Nov. 30, 2013 22:36:39)


Check out the rather large library games I've created!
Aqueduct, The Blue Labyrinth, Bubble Breaker!, Glide, Lights Out!, Master of the Elements!, The Monster and Me, Pathmaker, Rope, SIMON, Speed Typing!, Splatformer, Tower Defense!, Video Poker!, Wishy Washy Water, Zombie Shootout!, and many more are on my profile!

Most recent: Aqueduct
Personal favorite: Aqueduct
mathfreak231
Scratcher
1000+ posts

Suggestion for a new way to clone.

JeremiahMacDonald wrote:

Well, you are right about that being an obvious solution; however, with many turrets firing at the same time and constantly changing the variables for the starting x and y positions, the odds of one turret overwriting the variable information from the last turret before its bullet gets shot increases as you add more turrets.

Workaround 1 also doesn't work because I would be telling the bullet to go to a clone of the turret.
In that case use a list as a queue:

when I receive [stuff v]
add [55] to [x pos's v]
add [42] to [y pos's v] // just replace the numbers with whatever
create clone of [myself v]

when I start as a clone
go to x: (item (1 v) of [x pos's v]) y: (item (1 v) of [y pos's v])
delete (1 v) of [x pos's v]
delete (1 v) of [y pos's v]

i have grown as a person. and ive grown, literally. none of my posts from before 2022 represent me accurately.
JereTheJuggler
Scratcher
100+ posts

Suggestion for a new way to clone.

mathfreak231 wrote:

JeremiahMacDonald wrote:

Well, you are right about that being an obvious solution; however, with many turrets firing at the same time and constantly changing the variables for the starting x and y positions, the odds of one turret overwriting the variable information from the last turret before its bullet gets shot increases as you add more turrets.

Workaround 1 also doesn't work because I would be telling the bullet to go to a clone of the turret.
In that case use a list as a queue:

when I receive [stuff v]
add [55] to [x pos's v]
add [42] to [y pos's v] // just replace the numbers with whatever
create clone of [myself v]

when I start as a clone
go to x: (item (1 v) of [x pos's v]) y: (item (1 v) of [y pos's v])
delete (1 v) of [x pos's v]
delete (1 v) of [y pos's v]
Interesting… That probably could help, but I could see the same problem happening with it not deleting the items fast enough.

Check out the rather large library games I've created!
Aqueduct, The Blue Labyrinth, Bubble Breaker!, Glide, Lights Out!, Master of the Elements!, The Monster and Me, Pathmaker, Rope, SIMON, Speed Typing!, Splatformer, Tower Defense!, Video Poker!, Wishy Washy Water, Zombie Shootout!, and many more are on my profile!

Most recent: Aqueduct
Personal favorite: Aqueduct
mathfreak231
Scratcher
1000+ posts

Suggestion for a new way to clone.

JeremiahMacDonald wrote:

mathfreak231 wrote:

JeremiahMacDonald wrote:

Well, you are right about that being an obvious solution; however, with many turrets firing at the same time and constantly changing the variables for the starting x and y positions, the odds of one turret overwriting the variable information from the last turret before its bullet gets shot increases as you add more turrets.

Workaround 1 also doesn't work because I would be telling the bullet to go to a clone of the turret.
In that case use a list as a queue:

when I receive [stuff v]
add [55] to [x pos's v]
add [42] to [y pos's v] // just replace the numbers with whatever
create clone of [myself v]

when I start as a clone
go to x: (item (1 v) of [x pos's v]) y: (item (1 v) of [y pos's v])
delete (1 v) of [x pos's v]
delete (1 v) of [y pos's v]
Interesting… That probably could help, but I could see the same problem happening with it not deleting the items fast enough.
I foresaw that too…

I found this project that may help you.

Last edited by mathfreak231 (Dec. 1, 2013 02:02:05)


i have grown as a person. and ive grown, literally. none of my posts from before 2022 represent me accurately.

Powered by DjangoBB