Discuss Scratch

shoresbeep
Scratcher
1000+ posts

What the if on edge, bounce block should be replaced with

no support because:
if <touching [edge v] ?> then

point in direction ((180) - (direction))
end

Last edited by shoresbeep (Nov. 16, 2014 02:46:53)

ShamelessSnores
Scratcher
100+ posts

What the if on edge, bounce block should be replaced with

Diamond_Projects wrote:

ShamelessSnores wrote:

3sal2 wrote:

There's no way you could bounce off a general shape without calculus. And, as A-no-meep said, there would be an issue with diagonal bitmap surfaces.

Let 0 be the surface, 1 be the impactor, and represent all other pixels. It will look like this before impact:

0
00 1
000 111
0000 1
00000
000000
0000000
00000000
000000000

If the impactor continues to move, say, southwest, it will look like this:

0
00
000
0000 1
00000111
0000001
0000000
00000000
000000000

But what will it do? It can't determine an orientation. If it had to randomly choose from up or right, it would look wonky regardless of the outcome:

0 1
00 111
000 1
0000
00000
000000
0000000
00000000
000000000

This violates the laws of reflection! If it was a bigger diamond-shape or octagon, it would get stuck. If it touched the surface by the corners, it wouldn't be able to find an orientation. If it decides to reflect back, it will again violate the laws of reflection for any surface that is not “perpendicular” to the impactor's “direction”.

The only way to determine the “angle” of the bitmap surface is to analyze the surrounding pixels and estimate the reflection angle, which, again, requires the use of calculus.

However, this is not an issue with vectors, as you can design a program with an extra sprite that measures the orientation and tells the shape which way to go.

Diamond_Projects wrote:

(bounce :: motion)
Whaaaa? Bounce of what angle? What edge? And what if it is touching two things?
Please do not necropost.

I'm telling you why the “bounce” block won't work! How is that a necropost?
It wasn't you exactly, it was the other guy… Also it's a good idea to read through the thread before you post… That way you could've had seen that he had necroposted
scottpease
New Scratcher
4 posts

What the if on edge, bounce block should be replaced with

I want to add support for a more generalized “bounce” block.

We would like to be able to “bounce” our sprites off of other sprites or colors.

Thanks,
SP
stickfiregames
Scratcher
1000+ posts

What the if on edge, bounce block should be replaced with

shoresbeep wrote:

if <touching [edge v] ?> then
point in direction ((180) - (direction))
end
That only works if you are bouncing off a horizontal line.


No support.
There is a way to bounce off a straight line with a known angle, or a circle with a known centre. The reason why there will never be a generic “bounce” block is because there is no way to calculate the angle to bounce off without complex calculations that would slow down the project.
ijohn007
Scratcher
100+ posts

What the if on edge, bounce block should be replaced with

Just do this:

...
if <touching [Thing v] ?> then

turn ccw (180) degrees
end
...
Braeden5454
Scratcher
500+ posts

What the if on edge, bounce block should be replaced with

shoresbeep wrote:

no support because:
if <touching [edge v] ?> then

point in direction ((180) - (direction))
end

That doesn't work very well.
ijohn007
Scratcher
100+ posts

What the if on edge, bounce block should be replaced with

Braeden5454 wrote:

shoresbeep wrote:

no support because:
if <touching [edge v] ?> then

point in direction ((180) - (direction))
end

That doesn't work very well.

ijohn007 (Edited) wrote:

Just do this:

...
if <touching [Thing v] ?> then

turn ccw (180) degrees
move (10) steps
end
...
danielhal
Scratcher
100+ posts

What the if on edge, bounce block should be replaced with

Bounce is basically turn 180 degrees…
__init__
Scratcher
1000+ posts

What the if on edge, bounce block should be replaced with

Whoops, I did NOT mean to support this. Stupid MSU.

Last edited by __init__ (Nov. 30, 2014 22:14:48)

donotforgetmycode
Scratcher
1000+ posts

What the if on edge, bounce block should be replaced with

spgame05 wrote:

I think there should be an
if touching [edge v], bounce :: motion
block instead. You can't bounce off of nothing!
I agree.
We also need these blocks:
if touching colour [#ccccff], bounce :: motion
if colour [#ff0000] touching [#aaaaaa], bounce :: motion
if on mouse, bounce :: motion

Last edited by donotforgetmycode (April 8, 2018 13:47:45)

-ShadowOfTheFuture-
Scratcher
1000+ posts

What the if on edge, bounce block should be replaced with

How would this bounce block work? If there was an
if on [sprite1 v], bounce :: motion
block, what would happen if the sprite was completely within the sprite it was supposed to bounce off of?
DaEpikDude
Scratcher
1000+ posts

What the if on edge, bounce block should be replaced with

donotforgetmycode wrote:

spgame05 wrote:

I think there should be an
if touching [edge v], bounce :: motion
block instead. You can't bounce off of nothing!
I agree.
We also need these blocks:
if touching colour [#ccccff], bounce :: motion
if colour [#ff0000] touching [#aaaaaa], bounce :: motion
if on mouse, bounce :: motion
meganecro, much?

also it's semi-rejected

Last edited by DaEpikDude (April 8, 2018 21:11:40)

ihgfedcba
Scratcher
100+ posts

What the if on edge, bounce block should be replaced with

-ShadowOfTheFuture- wrote:

How would this bounce block work? If there was an
if on [sprite1 v], bounce :: motion
block, what would happen if the sprite was completely within the sprite it was supposed to bounce off of?
Also, as someone said, diagonal angles cannot be reliably recognized on bitmap pictures, as edges are only either horizontal or vertical. It's not going to work. No support.

Powered by DjangoBB