Discuss Scratch

Growdigi
New to Scratch
7 posts

how to avoid a stamp going over a previous stamp?

Hi
My project is giving the wrong results, when a stamp goes over a previous position x and y of another stamp.
How could I make this concept work, by stamping only in positions of x and Y, that have not yet been stamped previously?
I made a position of the X and of the Y each 60 and 80 steps.

See my project:
https://scratch.mit.edu/projects/114875512/
Thank you!

footsocktoe
Scratcher
1000+ posts

how to avoid a stamp going over a previous stamp?

There are several ways. One way is to use lists to keep track of the positions and which have already been used.


SHOOT THE SPACE MONSTERS! ….. A game everyone can play! Bright colors, bonky sounds!
THE 12 BALLS OF CRAZY AL ……. New scrolling adventure game!

ScratchMatrix
Scratcher
100+ posts

how to avoid a stamp going over a previous stamp?

Growdigi wrote:

Hi
My project is giving the wrong results, when a stamp goes over a previous position x and y of another stamp.
How could I make this concept work, by stamping only in positions of x and Y, that have not yet been stamped previously?
I made a position of the X and of the Y each 60 and 80 steps.

See my project:
https://scratch.mit.edu/projects/114875512/
Thank you!

Make list ‘previous positions ’and variable ‘position’.
when I start as a clone
go to [ random position]
set [ position] to [(join (x position) (y position)) ]
if <[ previous positions] contains [(position) ]> then

delete this clone
end
if <<not <[ previous positions] contains [(position) ]>>> then

add [positions] to [previous positions]
end
end
Replace the 2 ifs with if else condition.Hope it helps.Sorry for horrible script.I'm not good with scratchblocks on the forum.


Scratch Matrix
Currently learning 한글

“ On the side of a milk carton: Allergy advice - May Contain Traces of Milk ”

Scratch TutorsLearning Other LanguagesMy Profile
Growdigi
New to Scratch
7 posts

how to avoid a stamp going over a previous stamp?

Hi Thank you!
Seems I'm not ready yet for the lists… need to work further on it. I've changed it to work instead with Clones.
I will see if If I can improve it later with the suggestion above for the position, to be able to use a random place in the play field.


Kr,

Powered by DjangoBB