Discuss Scratch

CodeKing_11
Scratcher
100+ posts

touching edge of sprite

So if you use this boolean on an “if” or “repeat until” block ,it will wait until one sprite is touching the edge of another sprite. This could be used for bouncing on sprites easier if a sprite is moving consistently. it would be in the sensing category as a boolean. it would look something like this:
repeat until <touching edge of [ v] ?>
change y by (-1)
end

Last edited by CodeKing_11 (Oct. 3, 2024 21:08:28)

happywaffle0
Scratcher
100+ posts

touching edge of sprite

CodeKing_11 wrote:

So if you use this boolean on an “if” or “repeat until” block ,it will wait until one sprite is touching the edge of another sprite. This could be used for bouncing on sprites easier if a sprite is moving consistently. it would be in the sensing category as a boolean. it would look something like this:
repeat until <touching edge of [ v] ?>
change y by (-1)
end

The question(s) is, what will define as a “edge” of a sprite be? What about the curves and such? Will those be counted as edges? How will this be coded?
CodeKing_11
Scratcher
100+ posts

touching edge of sprite

happywaffle0 wrote:

CodeKing_11 wrote:

So if you use this boolean on an “if” or “repeat until” block ,it will wait until one sprite is touching the edge of another sprite. This could be used for bouncing on sprites easier if a sprite is moving consistently. it would be in the sensing category as a boolean. it would look something like this:
repeat until <touching edge of [ v] ?>
change y by (-1)
end

The question(s) is, what will define as a “edge” of a sprite be? What about the curves and such? Will those be counted as edges? How will this be coded?
It would be the last x coordinate before it is no longer touching the art of the sprite. Lets say I had a circle, and a dot in it. If I wanted the dot to move until it's at the edge of the circle, it would be a repeat with this new boolean, and once it cannot go anymore unless it isn't touching the sprite, it stops.

Last edited by CodeKing_11 (Oct. 3, 2024 21:16:59)

happywaffle0
Scratcher
100+ posts

touching edge of sprite

CodeKing_11 wrote:

happywaffle0 wrote:

CodeKing_11 wrote:

So if you use this boolean on an “if” or “repeat until” block ,it will wait until one sprite is touching the edge of another sprite. This could be used for bouncing on sprites easier if a sprite is moving consistently. it would be in the sensing category as a boolean. it would look something like this:
repeat until <touching edge of [ v] ?::sensing>
change y by (-1)
end

The question(s) is, what will define as a “edge” of a sprite be? What about the curves and such? Will those be counted as edges? How will this be coded?
It would be the last x coordinate before it is no longer touching the art of the sprite. Lets say I had a circle, and a dot in it. If I wanted the dot to move until it's at the edge of the circle, it would be a repeat with this new boolean, and once it cannot go anymore unless it isn't touching the sprite, it stops.


what about the y coordinate?

Last edited by happywaffle0 (Oct. 3, 2024 21:19:47)

CodeKing_11
Scratcher
100+ posts

touching edge of sprite

happywaffle0 wrote:

CodeKing_11 wrote:

happywaffle0 wrote:

CodeKing_11 wrote:

So if you use this boolean on an “if” or “repeat until” block ,it will wait until one sprite is touching the edge of another sprite. This could be used for bouncing on sprites easier if a sprite is moving consistently. it would be in the sensing category as a boolean. it would look something like this:
repeat until <touching edge of [ v] ?::sensing>
change y by (-1)
end

The question(s) is, what will define as a “edge” of a sprite be? What about the curves and such? Will those be counted as edges? How will this be coded?
It would be the last x coordinate before it is no longer touching the art of the sprite. Lets say I had a circle, and a dot in it. If I wanted the dot to move until it's at the edge of the circle, it would be a repeat with this new boolean, and once it cannot go anymore unless it isn't touching the sprite, it stops.


what about the y coordinate?
Same thing
han614698
Scratcher
1000+ posts

touching edge of sprite

but what's wrong with just doing this

repeat until <touching [ v] ?::sensing>
change y by (-1)
end
instead of
repeat until <touching edge of [ v] ?::sensing>
change y by (-1)
end
CodeKing_11
Scratcher
100+ posts

touching edge of sprite

han614698 wrote:

but what's wrong with just doing this

repeat until <touching [ v] ?::sensing>
change y by (-1)
end
instead of
repeat until <touching edge of [ v] ?::sensing>
change y by (-1)
end
what if the middle is colored? That would be part of the sprite, making it just stay put
cookieclickerer33
Scratcher
1000+ posts

touching edge of sprite

CodeKing_11 wrote:

han614698 wrote:

but what's wrong with just doing this

repeat until <touching [ v] ?::sensing>
change y by (-1)
end
instead of
repeat until <touching edge of [ v] ?::sensing>
change y by (-1)
end
what if the middle is empty? That wouldnt be part of the sprite, making it just stay put

I think I fixed your question.

If the meddle of a sprite is transparent this method won’t work because the sprite would think the transparent area is the edge
CodeKing_11
Scratcher
100+ posts

touching edge of sprite

cookieclickerer33 wrote:

CodeKing_11 wrote:

han614698 wrote:

but what's wrong with just doing this

repeat until <touching [ v] ?::sensing>
change y by (-1)
end
instead of
repeat until <touching edge of [ v] ?::sensing>
change y by (-1)
end
what if the middle is empty? That wouldnt be part of the sprite, making it just stay put

I think I fixed your question.

If the meddle of a sprite is transparent this method won’t work because the sprite would think the transparent area is the edge
I said the last x before it is touching outside of the sprite. For example:
(vertical line = edge, horizontal line = sprite)
| – : False
|– : True

Last edited by CodeKing_11 (Oct. 8, 2024 15:07:17)

Powered by DjangoBB