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

#1 2011-04-08 14:52:51

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

the bounce block- finally revealed

okay, so I DON'T actually have the code up yet (well, I guess I do, kinda) and I will now post the spec. in a couple of weeks, I will post the code!!

Code:

('bounce' #- #bounce)

keep looking here  for updates!
(okay, so I think that all of you have the spec who have tried to make it)

Last edited by GP1 (2011-04-08 14:53:41)


I am currently http://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=imagehttp://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=text and I finally got over 1000 posts.

Offline

 

#2 2011-04-08 16:11:05

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: the bounce block- finally revealed

Is this going to be the standard turn 180 degrees type block, a bounce block that assumes that the  object it strikes is a circle or a true bounce block that accounts for the shape of both sprites?


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#3 2011-04-09 12:09:19

DarthPickley
Scratcher
Registered: 2008-06-13
Posts: 100+

Re: the bounce block- finally revealed

it just bounces off the edge even if it isn't touching.

Offline

 

#4 2011-04-09 13:44:18

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: the bounce block- finally revealed

GP1 wrote:

okay, so I DON'T actually have the code up yet (well, I guess I do, kinda) and I will now post the spec. in a couple of weeks, I will post the code!!

Code:

('bounce' #- #bounce)

keep looking here  for updates!
(okay, so I think that all of you have the spec who have tried to make it)

LOL. Thanks for the spec at least. Of course i could have made that but, well, anyways... when will you reveal the code? Is it a PRO one, or the usual ones; turn 2*direction, turn 180?


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#5 2011-04-10 18:25:23

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: the bounce block- finally revealed

Pecola1 wrote:

GP1 wrote:

okay, so I DON'T actually have the code up yet (well, I guess I do, kinda) and I will now post the spec. in a couple of weeks, I will post the code!!

Code:

('bounce' #- #bounce)

keep looking here  for updates!
(okay, so I think that all of you have the spec who have tried to make it)

LOL. Thanks for the spec at least. Of course i could have made that but, well, anyways... when will you reveal the code? Is it a PRO one, or the usual ones; turn 2*direction, turn 180?

yeah. at first, it will be a stupid, non-pro block. I am testing that one. it hasn't worked (suprising) and others will be the PRO ones. I know that you, in particular, made a project on it. If you put the stupid code in with the spec, then you can replace it later. I added the succi one in the BYOB, but it doesn't work in scratch (yet).


I am currently http://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=imagehttp://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=text and I finally got over 1000 posts.

Offline

 

#6 2011-04-11 10:00:32

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: the bounce block- finally revealed

I might attempt to make one in BYOB. It automatically sends itself to the edge, bounce, and come back.
EDIT:
[ Do make sure to tick atomic! ]
http://img163.imageshack.us/img163/2613/capture1a.png

Click for bigger image.

Last edited by rdococ (2011-04-11 10:15:28)

Offline

 

#7 2011-04-11 21:15:09

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: the bounce block- finally revealed

rdococ wrote:

I might attempt to make one in BYOB. It automatically sends itself to the edge, bounce, and come back.
EDIT:
[ Do make sure to tick atomic! ]
[img]http://img163.imageshack.us/img163/2613/capture1a.pnghttp://img163.imageshack.us/img163/2613/capture1a.png[/img]

Click for bigger image.

well, simaler. I could use that, too. one thing, though. what does the atomic button do?

Last edited by GP1 (2011-04-11 21:15:30)


I am currently http://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=imagehttp://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=text and I finally got over 1000 posts.

Offline

 

#8 2011-04-12 04:06:08

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: the bounce block- finally revealed

GP1 wrote:

rdococ wrote:

I might attempt to make one in BYOB. It automatically sends itself to the edge, bounce, and come back.
EDIT:
[ Do make sure to tick atomic! ]
[url]http://img163.imageshack.us/img163/2613/capture1a.pnghttp://img163.imageshack.us/img163/2613/capture1a.png[/url]

Click for bigger image.

well, simaler. I could use that, too. one thing, though. what does the atomic button do?

It makes the block do it automatically so you can't see it being done.

Offline

 

#9 2011-04-13 18:54:23

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: the bounce block- finally revealed

rdococ wrote:

GP1 wrote:

rdococ wrote:

I might attempt to make one in BYOB. It automatically sends itself to the edge, bounce, and come back.
EDIT:
[ Do make sure to tick atomic! ]
[url]http://img163.imageshack.us/img163/2613/capture1a.pnghttp://img163.imageshack.us/img163/2613/capture1a.png[/url]

Click for bigger image.

well, simaler. I could use that, too. one thing, though. what does the atomic button do?

It makes the block do it automatically so you can't see it being done.

oh. well, I can use that for my new and improved bounce block for BYOB


I am currently http://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=imagehttp://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=text and I finally got over 1000 posts.

Offline

 

#10 2011-04-14 22:52:05

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: the bounce block- finally revealed

here is the new and improved bounce block for BYOB
http://i55.tinypic.com/o586qr.gif


I am currently http://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=imagehttp://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=text and I finally got over 1000 posts.

Offline

 

#11 2011-04-15 16:33:09

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: the bounce block- finally revealed

Very clever!
I have a better way to do it with source code:

Code:

bounceIfTouching: t1 
    | otherPosition relativePosition oldPosition |
    oldPosition _ self referencePosition.
    t1 ifNil: [^ self].
    (self touching: (self coerceSpriteArg: t1))
        ifFalse: [^ self].
    t1 = #mouse
        ifTrue: [otherPosition _ self mouseX @ self mouseY]
        ifFalse: [otherPosition _ (self coerceSpriteArg: t1) referencePosition].
    otherPosition = self referencePosition ifTrue: [^ self].
    relativePosition _ self referencePosition - otherPosition.
    relativePosition x abs = relativePosition y abs ifTrue: [^ self turnLeft: 180].
    relativePosition x abs > relativePosition y abs
        ifTrue: 
            [self ypos: 1000 * relativePosition y sign.
            self bounceOffEdge]
        ifFalse: 
            [self xpos: 1000 * relativePosition x sign.
            self bounceOffEdge].
    self referencePosition: oldPosition

I hope this is relatively self-explanatory  smile

Basically, it finds the direction in which it is closest to the sprite, moves to 1000 of that position, bounces off edge, and goes back to its original position.

Last edited by rubiks_cube_guy238 (2011-04-15 16:33:44)


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#12 2011-04-15 18:53:09

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: the bounce block- finally revealed

rubiks_cube_guy238 wrote:

Very clever!
I have a better way to do it with source code:

Code:

bounceIfTouching: t1 
    | otherPosition relativePosition oldPosition |
    oldPosition _ self referencePosition.
    t1 ifNil: [^ self].
    (self touching: (self coerceSpriteArg: t1))
        ifFalse: [^ self].
    t1 = #mouse
        ifTrue: [otherPosition _ self mouseX @ self mouseY]
        ifFalse: [otherPosition _ (self coerceSpriteArg: t1) referencePosition].
    otherPosition = self referencePosition ifTrue: [^ self].
    relativePosition _ self referencePosition - otherPosition.
    relativePosition x abs = relativePosition y abs ifTrue: [^ self turnLeft: 180].
    relativePosition x abs > relativePosition y abs
        ifTrue: 
            [self ypos: 1000 * relativePosition y sign.
            self bounceOffEdge]
        ifFalse: 
            [self xpos: 1000 * relativePosition x sign.
            self bounceOffEdge].
    self referencePosition: oldPosition

I hope this is relatively self-explanatory  smile

Basically, it finds the direction in which it is closest to the sprite, moves to 1000 of that position, bounces off edge, and goes back to its original position.

thats what I was thinking


I am currently http://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=imagehttp://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=text and I finally got over 1000 posts.

Offline

 

#13 2011-04-17 12:27:08

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: the bounce block- finally revealed

Better bounce block:
[ Still, make sure atomic is ticked! ]
http://img852.imageshack.us/img852/7489/capturead.png
This one does not need a text input. Through, it basically does the same thing: brings the sprite to the edge, if on edge [it will be] bounce, then come back.

Offline

 

#14 2011-04-20 18:01:29

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: the bounce block- finally revealed

rdococ wrote:

Better bounce block:
[ Still, make sure atomic is ticked! ]
http://img852.imageshack.us/img852/7489/capturead.png
This one does not need a text input. Through, it basically does the same thing: brings the sprite to the edge, if on edge [it will be] bounce, then come back.

mine goes to a random edge


I am currently http://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=imagehttp://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=text and I finally got over 1000 posts.

Offline

 

#15 2011-04-20 23:41:50

Thugs4less
Scratcher
Registered: 2010-05-02
Posts: 16

Re: the bounce block- finally revealed

[blocks]<when green flag clicked><forever><if><touching[edge]<set{x velocity}to(((<((x velocity<->x velocity))><->x velocity))[/blocks]

Here's the script for a bounce. The object that is bouncing will need to have 2 variables - x & y velocity (see the example projects). I have only included the x velocity script but the y velocity script is the same except you chane the variable. Hope this Helps.

If you don't understand that, here's a written example:

Start clicked
Forever
If - touching [edge]
Set [x velocity] to...((x velocity - x vel.) - x velocity)

That's it. Copy for Y velocity

Last edited by Thugs4less (2011-04-20 23:46:42)


The only reason people get lost in thought is because it's unfamiliar territory.  tongue   cool

Offline

 

#16 2011-04-21 18:21:57

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: the bounce block- finally revealed

Thugs4less wrote:

[blocks]<when green flag clicked><forever><if><touching[edge]<set{x velocity}to(((<((x velocity<->x velocity))><->x velocity))[/blocks]

Here's the script for a bounce. The object that is bouncing will need to have 2 variables - x & y velocity (see the example projects). I have only included the x velocity script but the y velocity script is the same except you chane the variable. Hope this Helps.

If you don't understand that, here's a written example:

Start clicked
Forever
If - touching [edge]
Set [x velocity] to...((x velocity - x vel.) - x velocity)

That's it. Copy for Y velocity

I suppose that would be one if you didn't want to program the block


I am currently http://blocks.scratchr.org/API.php?user=GP1&amp;action=onlineStatus&amp;type=imagehttp://blocks.scratchr.org/API.php?user=GP1&amp;action=onlineStatus&amp;type=text and I finally got over 1000 posts.

Offline

 

#17 2013-01-23 15:56:21

Midevalknight100
Scratcher
Registered: 2013-01-23
Posts: 9

Re: the bounce block- finally revealed

bounceIfTouching: t1
    | otherPosition relativePosition oldPosition |
    oldPosition _ self referencePosition.
    t1 ifNil: [^ self].
    (self touching: (self coerceSpriteArg: t1))
        ifFalse: [^ self].
    t1 = #mouse
        ifTrue: [otherPosition _ self mouseX @ self mouseY]
        ifFalse: [otherPosition _ (self coerceSpriteArg: t1) referencePosition].
    otherPosition = self referencePosition ifTrue: [^ self].
    relativePosition _ self referencePosition - otherPosition.
    relativePosition x abs = relativePosition y abs ifTrue: [^ self turnLeft: 180].
    relativePosition x abs > relativePosition y abs
        ifTrue:
            [self ypos: 1000 * relativePosition y sign.
            self bounceOffEdge]
        ifFalse:
            [self xpos: 1000 * relativePosition x sign.
            self bounceOffEdge].
    self referencePosition: oldPosition

Offline

 

#18 2013-01-24 03:43:47

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: the bounce block- finally revealed

Midevalknight100 wrote:

bounceIfTouching: t1
    | otherPosition relativePosition oldPosition |
    oldPosition _ self referencePosition.
    t1 ifNil: [^ self].
    (self touching: (self coerceSpriteArg: t1))
        ifFalse: [^ self].
    t1 = #mouse
        ifTrue: [otherPosition _ self mouseX @ self mouseY]
        ifFalse: [otherPosition _ (self coerceSpriteArg: t1) referencePosition].
    otherPosition = self referencePosition ifTrue: [^ self].
    relativePosition _ self referencePosition - otherPosition.
    relativePosition x abs = relativePosition y abs ifTrue: [^ self turnLeft: 180].
    relativePosition x abs > relativePosition y abs
        ifTrue:
            [self ypos: 1000 * relativePosition y sign.
            self bounceOffEdge]
        ifFalse:
            [self xpos: 1000 * relativePosition x sign.
            self bounceOffEdge].
    self referencePosition: oldPosition

Necropost?  hmm  That's rubiks_cube_guy238's code.

Offline

 

#19 2013-01-31 13:51:47

Midevalknight100
Scratcher
Registered: 2013-01-23
Posts: 9

Re: the bounce block- finally revealed

bounceIfTouching: t1 
    | otherPosition relativePosition oldPosition |
    oldPosition _ self referencePosition.
    t1 ifNil: [^ self].
    (self touching: (self coerceSpriteArg: t1))
        ifFalse: [^ self].
    t1 = #mouse
        ifTrue: [otherPosition _ self mouseX @ self mouseY]
        ifFalse: [otherPosition _ (self coerceSpriteArg: t1) referencePosition].
    otherPosition = self referencePosition ifTrue: [^ self].
    relativePosition _ self referencePosition - otherPosition.
    relativePosition x abs = relativePosition y abs ifTrue: [^ self turnLeft: 180].
    relativePosition x abs > relativePosition y abs
        ifTrue: 
            [self ypos: 1000 * relativePosition y sign.
            self bounceOffEdge]
        ifFalse: 
            [self xpos: 1000 * relativePosition x sign.
            self bounceOffEdge].
    self referencePosition: oldPosition

Offline

 

Board footer