Discuss Scratch

baldchicken
New to Scratch
7 posts

Stopping sprite2 routine based on the position of sprite 1

So I have the cat walking through different backgrounds. When a flag is met (background = nights) it calls lightning. This lightning routine works, but I only want the lightning to work on this particular background.

So how do stop this sprite2 routine when the background changes / the cat reaches 240 on the X axis.

I tried inserting a broadcast called “check sprite1 pos”, and set a switch in it to where if X > 239 changes a flag to 1 (or true). Then the loop of lighting continues until the var = 1.

The var never changes..

Any help would be awesome!

Here is a link.

http://scratch.mit.edu/projects/16675154/
baldchicken
New to Scratch
7 posts

Stopping sprite2 routine based on the position of sprite 1

I think I figured it out… and/or why it is not working. Because there is a pause of .5 and 1 second… it will sometimes miss the X position of the Sprite1. So now I need to figure out how consistantly check. Or make a check like… background <> night with streets.

I dont see any options to validate the background.

So my help now, is how to evaluate what background is being used.

I would have deleted my previous message, but didnt see an option to delete or modify it… so I am just appending to it.
drmcw
Scratcher
1000+ posts

Stopping sprite2 routine based on the position of sprite 1

if <(backdrop name) = [moon]> then
say [It's getting dark!] for (2) secs
end

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
baldchicken
New to Scratch
7 posts

Stopping sprite2 routine based on the position of sprite 1

I think I got it working… the only issues that I have with my scripts… they are all static based.

So for example, instead of looping until (backdrop = Moon and X = 200), I just have it set to loop 500 times.

But here it is.
Thanks again for your participation in the community.

Nothing to write home about, but my first one… none the less.

http://scratch.mit.edu/projects/16675154/
scubajerry
Scratcher
1000+ posts

Stopping sprite2 routine based on the position of sprite 1

baldchicken wrote:

I think I got it working… the only issues that I have with my scripts… they are all static based.

So for example, instead of looping until (backdrop = Moon and X = 200), I just have it set to loop 500 times.

But here it is.
Thanks again for your participation in the community.

Nothing to write home about, but my first one… none the less.

http://scratch.mit.edu/projects/16675154/
It is a GREAT first project. It is well written and extremely well documented. There are many ways to accomplish the same thing in programming and the way you did it is fine. If you didn't want to use static, a way to do it is
repeat until <(backdrop name) = [flower bed]>
repeat until <touching [edge v]?>
change x by (4)
end
set x to (-170)//you can't go to -240 or you will be immediately touching the edge again.
switch backdrop to [next backdrop v]
end
repeat until <touching [edge v]?>
change x by (4)
end
say [You shouldn't run with scissors] for (2) secs
say [Unless] for (2) secs
switch backdrop to [next backdrop v]

Last edited by scubajerry (Jan. 19, 2014 13:08:01)

Powered by DjangoBB