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!!
('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)
Offline
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?
Offline
it just bounces off the edge even if it isn't touching.
Offline
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?
Offline
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).
Offline
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)
Offline
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
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
Offline
Very clever!
I have a better way to do it with source 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
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)
Offline
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: oldPositionI hope this is relatively self-explanatory
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
Offline
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
Offline
[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)
Offline
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
Offline
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
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? That's rubiks_cube_guy238's code.
Offline
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