This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-09-25 15:57:16

cpumaster930
Scratcher
Registered: 2009-02-23
Posts: 100+

If on edge, bounce?

Yes, I know what it does. That's fairly obvious.  tongue

Is there a way to reconstruct that block by using other blocks, except using sprite or color sensing?  So in other words, it'd be like "if touching color [ ], bounce".

I've tried it but Scratch has a weird angle system xP


http://i.imgur.com/Qd0lu.png

Offline

 

#2 2011-09-25 15:58:36

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: If on edge, bounce?

Not that I know of. You could maybe make one with touching [edge] block though.

Offline

 

#3 2011-09-25 16:04:00

cpumaster930
Scratcher
Registered: 2009-02-23
Posts: 100+

Re: If on edge, bounce?

laptop97 wrote:

Not that I know of. You could maybe make one with touching [edge] block though.

I don't want it to bounce if it's touching the edge though  tongue

I want it to bounce if it's touching a certain color  wink


http://i.imgur.com/Qd0lu.png

Offline

 

#4 2011-09-25 16:07:41

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: If on edge, bounce?

cpumaster930 wrote:

laptop97 wrote:

Not that I know of. You could maybe make one with touching [edge] block though.

I don't want it to bounce if it's touching the edge though  tongue

I want it to bounce if it's touching a certain color  wink

Wow I didn't think that through.

If <Touching [Color]>
//Some really hard script most likely using the point in direction () block \\
Wait until <Not<Touching [Color]> >
{End of If}

Maybe that would work?

Offline

 

#5 2011-09-25 16:08:52

cpumaster930
Scratcher
Registered: 2009-02-23
Posts: 100+

Re: If on edge, bounce?

laptop97 wrote:

cpumaster930 wrote:

laptop97 wrote:

Not that I know of. You could maybe make one with touching [edge] block though.

I don't want it to bounce if it's touching the edge though  tongue

I want it to bounce if it's touching a certain color  wink

Wow I didn't think that through.

If <Touching [Color]>
//Some really hard script most likely using the point in direction () block \\
Wait until <Not<Touching [Color]> >
{End of If}

Maybe that would work?

Yes, I have that already.  tongue

I just don't know what direction to make it point in--I've tried direction + 180, direction x -1, 180 - direction, and 360 - direction, and none of those have worked.  sad


http://i.imgur.com/Qd0lu.png

Offline

 

#6 2011-09-25 16:19:47

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: If on edge, bounce?

This script isn't the best but;

Start
Forever If <Touching [Color]>
  Point in Direction ((Direction ) + (180))
  Move (//Number of steps sprite moves\\) steps
{End of Forever If}

Last edited by laptop97 (2011-09-25 16:20:11)

Offline

 

#7 2011-09-25 16:24:32

cpumaster930
Scratcher
Registered: 2009-02-23
Posts: 100+

Re: If on edge, bounce?

okay so I figured out this:
http://i.imgur.com/JMSSi.gif
where the side walls are black and the top/bottom walls are light gray.

Is there any way to get this to work with one color?

(Don't ask what the move 0 steps blocks are there for, I have no idea  tongue )

Last edited by cpumaster930 (2011-09-25 16:28:29)


http://i.imgur.com/Qd0lu.png

Offline

 

#8 2011-09-25 16:28:59

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: If on edge, bounce?

This should be fairly easy to figure out: just sit down with a piece of paper and do some maths  smile

Offline

 

#9 2011-09-25 16:31:41

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: If on edge, bounce?

cpumaster930 wrote:

okay so I figured out this:
http://i.imgur.com/JMSSi.gif
where the side walls are black and the top/bottom walls are light gray.

Is there any way to get this to work with one color?

(Don't ask what the move 0 steps blocks are there for, I have no idea  tongue )

Give me a second to improve this one; this seems correct, and you can judge whether you've hit a wall or ceiling by its direction and some unrendered checks.

EDIT:  Got it:
http://img26.imageshack.us/img26/7430/ifonedgebounce.gif

Last edited by Kileymeister (2011-09-25 16:39:58)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#10 2011-09-25 16:33:03

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: If on edge, bounce?

cpumaster930 wrote:

okay so I figured out this:
http://i.imgur.com/JMSSi.gif
where the side walls are black and the top/bottom walls are light gray.

Is there any way to get this to work with one color?

(Don't ask what the move 0 steps blocks are there for, I have no idea  tongue )

Sensing seems like the easiest solution for this.

Offline

 

#11 2011-09-25 16:34:43

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: If on edge, bounce?

I just noticed that it's impossible to use plain arithmetic to figure out the angles. Maybe some trig?  hmm

Offline

 

#12 2011-09-25 16:43:17

cpumaster930
Scratcher
Registered: 2009-02-23
Posts: 100+

Re: If on edge, bounce?

Kileymeister wrote:

cpumaster930 wrote:

okay so I figured out this:
http://i.imgur.com/JMSSi.gif
where the side walls are black and the top/bottom walls are light gray.

Is there any way to get this to work with one color?

(Don't ask what the move 0 steps blocks are there for, I have no idea  tongue )

Give me a second to improve this one; this seems correct, and you can judge whether you've hit a wall or ceiling by its direction and some unrendered checks.

EDIT:  Got it:
http://img26.imageshack.us/img26/7430/ifonedgebounce.gif

YESSSSSSSSSSSSSSSSSSSSS

You, sir, are a genius.  Thank you muchly  big_smile

Now I can proceed with my game ^^


http://i.imgur.com/Qd0lu.png

Offline

 

#13 2011-09-25 16:46:36

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: If on edge, bounce?

cpumaster930 wrote:

YESSSSSSSSSSSSSSSSSSSSS

You, sir, are a genius.  Thank you muchly  big_smile

Now I can proceed with my game ^^

Happy to help.  I hope I get to see your finished masterpiece.   smile

Last edited by Kileymeister (2011-09-25 16:46:52)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#14 2011-09-25 18:56:30

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: If on edge, bounce?

I know Kileymeister already figured it out, but would this work?

For your moving scripts (if there are any) add point in direction 90 for right arrow and -90 for left. Then say if touching color and direction = 90 point in direction - 90 and do the same thing but switch the direction = to direction = -90 and point in direction 90.


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

Board footer