Discuss Scratch

crystalbeastpikachu
Scratcher
36 posts

Sprite moving with another.

Let me cut to the chase; I want a sprite to move upwards/downwards with the other, but it's not working! Here are the scripts:

Bouncy ball (Thing that's moving):

when gf clicked
go to x:(0) y:(0)
repeat until (((y position) = [170]) or ((y position) > [170]))
change y by (3)
wait [1.0E-14] secs
end
forever
if (((y position) = [170]) or ((y position) > [170])) then
repeat until (((y position) = [-170]) or ((y position) < [-170]))
change y by (-3)
wait [1.0E-14] secs
end
end
if (((y position) = [-170]) or ((y position) < [-170])) then
repeat until (((y position) = [170]) or ((y position) > [170]))
change y by (3)
wait [1.0E-14] secs
end
end
end

when gf clicked
forever
set [bouncy ball position v] to (y position)
end

Thing that's moving with the Bouncy ball:

when gf clicked
forever
if ((([y position v] of [bouncy ball v]) = [170]) or (([y position v] of [bouncy ball v]) > [170])) then
repeat until ((([y position v] of [bouncy ball v]) = [-170]) or (([y position v] of [bouncy ball v]) < [-170]))
set y to ((bouncy ball position) - (50))
end
end
if ((([y position v] of [bouncy ball v]) = [-170]) or (([y position v] of [Sprite2 v]) < [-170])) then
repeat until ((([y position v] of [bouncy ball v]) = [170]) or (([y position v] of [bouncy ball v]) > [170]))
set y to ((bouncy ball position) + (50))
end
end
end



Someone please help!

Last edited by crystalbeastpikachu (Sept. 15, 2013 21:56:04)


when gf clicked
set [verb v] to [Eat/Dance/Game/Scratch]
say (join [Keep calm and ] (join (verb) [ On] ))
Splodgey
Scratcher
100+ posts

Sprite moving with another.

You put
if ((([y position v] of [bouncy ball v]) = [170]) or (([y position v] of [bouncy ball v]) = [170])) then
I think you mean
if ((([y position v] of [bouncy ball v]) = [170]) or (([y position v] of [bouncy ball v]) > [170])) then



Ever wondered why there's no text box? Or why you can make sprites “say” stuff, but not display pure text? Click here! Now v1.3, includes links!
Text Box, Calculator, AlphaSorter & Case Sensor
Have a large-scale Minecraft project and you want to know how much raw materials you need to craft the “ingredients”? Click here!

Minecraft PvP Weapon Vs Armour Calculator/Simulator
drmcw
Scratcher
1000+ posts

Sprite moving with another.

That seem so much unnecessary code. For the ball;

point in direction [0 v]
forever
move (3) steps
if on edge bounce
end

for the follower

forever
set y to ([y position v] of [ball sprite v])
end

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
ErnieParke
Scratcher
1000+ posts

Sprite moving with another.

Oh, this should be simple, and you're actually overcomplicating this. Just use this simple script:

when gf clicked
forever
set y to ((bouncy ball position) + (50))

That will move the bouncy ball above your first sprite. And if you want to move it to the left/right, you'll have to add in another variable, just like (bouncy ball position), but with the x Position now. Or are you wanting something else?

By the way, if you'd like to see a project in action, you could visit this project.

With regards,

ErnieParke

crystalbeastpikachu
Scratcher
36 posts

Sprite moving with another.

drmcw wrote:

That seem so much unnecessary code. For the ball;

point in direction [0 v]
forever
move (3) steps
if on edge bounce
end

for the follower

forever
set y to ([y position v] of [ball sprite v])
end

Then it would'n't work, after the sprites reach the top, they'll stay there.

ErnieParke wrote:

Oh, this should be simple, and you're actually overcomplicating this. Just use this simple script:

when gf clicked
forever
set y to ((bouncy ball position) + (50))

That will move the bouncy ball above your first sprite. And if you want to move it to the left/right, you'll have to add in another variable, just like (bouncy ball position), but with the x Position now. Or are you wanting something else?

By the way, if you'd like to see a project in action, you could visit this project.

With regards,

ErnieParke

I want the thing that follow's the bouncy ball to go lower when the ball is going down.

Splodgey wrote:

You put
if ((([y position v] of [bouncy ball v]) = [170]) or (([y position v] of [bouncy ball v]) = [170])) then
I think you mean
if ((([y position v] of [bouncy ball v]) = [170]) or (([y position v] of [bouncy ball v]) > [170])) then



Fixed it. Also, applied to my test, but it can only go down.

Last edited by crystalbeastpikachu (Sept. 15, 2013 21:57:25)


when gf clicked
set [verb v] to [Eat/Dance/Game/Scratch]
say (join [Keep calm and ] (join (verb) [ On] ))
drmcw
Scratcher
1000+ posts

Sprite moving with another.

crystalbeastpikachu wrote:

drmcw wrote:

That seem so much unnecessary code. For the ball;

point in direction [0 v]
forever
move (3) steps
if on edge bounce
end

for the follower

forever
set y to ([y position v] of [ball sprite v])
end

Then it would'n't work, after the sprites reach the top, they'll stay there.


have you tried it? I think you'll find it will bounce because of the if on edge bounce block!

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
crystalbeastpikachu
Scratcher
36 posts

Sprite moving with another.

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

That seem so much unnecessary code. For the ball;

point in direction [0 v]
forever
move (3) steps
if on edge bounce
end

for the follower

forever
set y to ([y position v] of [ball sprite v])
end

Then it would'n't work, after the sprites reach the top, they'll stay there.


have you tried it? I think you'll find it will bounce because of the if on edge bounce block!

Even though it bounces, it still points in direction 0

when gf clicked
set [verb v] to [Eat/Dance/Game/Scratch]
say (join [Keep calm and ] (join (verb) [ On] ))
drmcw
Scratcher
1000+ posts

Sprite moving with another.

crystalbeastpikachu wrote:

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

That seem so much unnecessary code. For the ball;

point in direction [0 v]
forever
move (3) steps
if on edge bounce
end

for the follower

forever
set y to ([y position v] of [ball sprite v])
end

Then it would'n't work, after the sprites reach the top, they'll stay there.


have you tried it? I think you'll find it will bounce because of the if on edge bounce block!

Even though it bounces, it still points in direction 0

No, the bounce block will change the direction otherwise it wouldn't bounce. It's not many blocks, why don't you try it?
If you want the follower to change its direction too then you can add to its loop;
point in direction  ([direction v] of [ball sprite v] )

Last edited by drmcw (Sept. 15, 2013 22:17:45)


10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
crystalbeastpikachu
Scratcher
36 posts

Sprite moving with another.

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

That seem so much unnecessary code. For the ball;

point in direction [0 v]
forever
move (3) steps
if on edge bounce
end

for the follower

forever
set y to ([y position v] of [ball sprite v])
end

Then it would'n't work, after the sprites reach the top, they'll stay there.


have you tried it? I think you'll find it will bounce because of the if on edge bounce block!

Even though it bounces, it still points in direction 0

No, the bounce block will change the direction otherwise it wouldn't bounce. It's not many blocks, why don't you try it?
If you want the follower to change its direction too then you can add to its loop;
point in direction  ([direction v] of [ball sprite v] )

I want to make go to the side, too, so that won't work.

when gf clicked
set [verb v] to [Eat/Dance/Game/Scratch]
say (join [Keep calm and ] (join (verb) [ On] ))
drmcw
Scratcher
1000+ posts

Sprite moving with another.

crystalbeastpikachu wrote:

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

That seem so much unnecessary code. For the ball;

point in direction [0 v]
forever
move (3) steps
if on edge bounce
end

for the follower

forever
set y to ([y position v] of [ball sprite v])
end

Then it would'n't work, after the sprites reach the top, they'll stay there.


have you tried it? I think you'll find it will bounce because of the if on edge bounce block!

Even though it bounces, it still points in direction 0

No, the bounce block will change the direction otherwise it wouldn't bounce. It's not many blocks, why don't you try it?
If you want the follower to change its direction too then you can add to its loop;
point in direction  ([direction v] of [ball sprite v] )

I want to make go to the side, too, so that won't work.
That's not what you asked initially, but It will if you point it in the right direction and you could just use go to ball sprite! .

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
crystalbeastpikachu
Scratcher
36 posts

Sprite moving with another.

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

That seem so much unnecessary code. For the ball;

point in direction [0 v]
forever
move (3) steps
if on edge bounce
end

for the follower

forever
set y to ([y position v] of [ball sprite v])
end

Then it would'n't work, after the sprites reach the top, they'll stay there.


have you tried it? I think you'll find it will bounce because of the if on edge bounce block!

Even though it bounces, it still points in direction 0

No, the bounce block will change the direction otherwise it wouldn't bounce. It's not many blocks, why don't you try it?
If you want the follower to change its direction too then you can add to its loop;
point in direction  ([direction v] of [ball sprite v] )

I want to make go to the side, too, so that won't work.
That's not what you asked initially, but It will if you point it in the right direction and you could just use go to ball sprite! .

I do'n't want the thing that follow's the bouncy ball to actually go to the ball either, I just want them to have the same y position. sorry for the tall order.

Last edited by crystalbeastpikachu (Sept. 15, 2013 22:42:49)


when gf clicked
set [verb v] to [Eat/Dance/Game/Scratch]
say (join [Keep calm and ] (join (verb) [ On] ))
drmcw
Scratcher
1000+ posts

Sprite moving with another.

crystalbeastpikachu wrote:

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

That seem so much unnecessary code. For the ball;

point in direction [0 v]
forever
move (3) steps
if on edge bounce
end

for the follower

forever
set y to ([y position v] of [ball sprite v])
end

Then it would'n't work, after the sprites reach the top, they'll stay there.


have you tried it? I think you'll find it will bounce because of the if on edge bounce block!

Even though it bounces, it still points in direction 0

No, the bounce block will change the direction otherwise it wouldn't bounce. It's not many blocks, why don't you try it?
If you want the follower to change its direction too then you can add to its loop;
point in direction  ([direction v] of [ball sprite v] )

I want to make go to the side, too, so that won't work.
That's not what you asked initially, but It will if you point it in the right direction and you could just use go to ball sprite! .

I do'n't want the thing that follow's the bouncy ball to actually go to the ball either, I just want them to have the same y position. sorry for the tall order.
Then just use the first script I wrote. You don't have to start the ball pointing straight up but can point it whatever direction you want, I only put that in because most sprites default to pointing right so there would be no up/down movement at all..

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
crystalbeastpikachu
Scratcher
36 posts

Sprite moving with another.

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

crystalbeastpikachu wrote:

drmcw wrote:

That seem so much unnecessary code. For the ball;

point in direction [0 v]
forever
move (3) steps
if on edge bounce
end

for the follower

forever
set y to ([y position v] of [ball sprite v])
end

Then it would'n't work, after the sprites reach the top, they'll stay there.


have you tried it? I think you'll find it will bounce because of the if on edge bounce block!

Even though it bounces, it still points in direction 0

No, the bounce block will change the direction otherwise it wouldn't bounce. It's not many blocks, why don't you try it?
If you want the follower to change its direction too then you can add to its loop;
point in direction  ([direction v] of [ball sprite v] )

I want to make go to the side, too, so that won't work.
That's not what you asked initially, but It will if you point it in the right direction and you could just use go to ball sprite! .

I do'n't want the thing that follow's the bouncy ball to actually go to the ball either, I just want them to have the same y position. sorry for the tall order.
Then just use the first script I wrote. You don't have to start the ball pointing straight up but can point it whatever direction you want, I only put that in because most sprites default to pointing right so there would be no up/down movement at all..

Your right, it worked! Sorry for not trying earlier.

when gf clicked
set [verb v] to [Eat/Dance/Game/Scratch]
say (join [Keep calm and ] (join (verb) [ On] ))

Powered by DjangoBB