Discuss Scratch

Necrochancer
Scratcher
53 posts

I use too much code for the most simple scripts

take this for example https://scratch.mit.edu/projects/570689495/ this took three hours to make (probably more but I stopped counting after three) and all it is is press enter to start the animation (originally press enter to continue to the animation after you start it), add the time it took to photoshop the spider kangaroo, draw with no mouse, and change up the coding when I realized 3 hours in I couldnt do it. Remix the project with more compact code that does the exact same thing (maybe even the original idea) and explain what I did wrong.

If this helped, check out my project! —> https://scratch.mit.edu/projects/853255381/ (A Meta Achievement Collection game in beta! any ideas for achievements no matter how hard to code or whatever will be appreciated.)
Or Check out my profile! —> https://scratch.mit.edu/users/Necrochancer/
The_Imaginarium
Scratcher
1000+ posts

I use too much code for the most simple scripts

All right let's break this down.

Let's begin with the human sprite:

when green flag clicked
go to x: (140) y: (-33)
wait until <key [enter v] pressed?>
broadcast [message1 v] and wait
if <key [enter v] pressed?> then
say [oh wow a kangaroo] for (2) secs
wait(1)secs
end
broadcast [message2 v] and wait

when I receive [message2 v]
say [wait what] for (2) secs
wait(2)secs
broadcast [message3 v] and wait

We can remove the if statement because we already know the boolean is true and since broadcasts are better used for communication between sprites and not within sprites, we can remove the broadcast message2 and combine the two scripts. We can also get rid of ‘message1’ because it is never used:

when green flag clicked
go to x: (140) y: (-33)
wait until <key [enter v] pressed?>
say [oh wow a kangaroo] for (2) secs
wait(1)secs
say [wait what] for (2) secs
wait(2)secs
broadcast [message3 v] and wait

Much better. Now let's move to the kangaroo sprite:

when green flag clicked
go to x: (-183) y: (-31)

when I receive [message3 v]
play sound [Run! - sound effect ] :: sound
say [gimme ur toes] for (6.5) secs
glide (1) secs to x: (21) y: (-41)
if <(x position) = [21]> then
forever
glide (0.01) secs to x: (7) y: (-41)
glide (0.01) secs to x: (21) y: (-41)
start sound [bonk v] :: sound
end
end

We can remove the if statement testing the x position because we know that will always return true:

when green flag clicked
go to x: (-183) y: (-31)

when I receive [message3 v]
play sound [Run! - sound effect ] :: sound
say [gimme ur toes] for (6.5) secs
glide (1) secs to x: (21) y: (-41)
forever
glide (0.01) secs to x: (7) y: (-41)
glide (0.01) secs to x: (21) y: (-41)
start sound [bonk v] :: sound
end

Looks good!

Last edited by The_Imaginarium (Sept. 15, 2021 20:29:08)

LG125
Scratcher
500+ posts

I use too much code for the most simple scripts

You don’t need so many broadcasts.

The only one u need is message3

Do this in human sprite:

when green flag clicked
go to x: (140) y: (33)
wait until <key [enter v] pressed?>
say [Oh wow a kangaroo] for (2) secs
wait (1) secs
say [Wait what] for (2) secs
wait (2) secs
broadcast [Message3 v]



Necrochancer
Scratcher
53 posts

I use too much code for the most simple scripts

thank you so much I will put you in the credits

If this helped, check out my project! —> https://scratch.mit.edu/projects/853255381/ (A Meta Achievement Collection game in beta! any ideas for achievements no matter how hard to code or whatever will be appreciated.)
Or Check out my profile! —> https://scratch.mit.edu/users/Necrochancer/
Necrochancer
Scratcher
53 posts

I use too much code for the most simple scripts

I have the 21 x position so when the kangaroo is touching the guy it starts the sound

If this helped, check out my project! —> https://scratch.mit.edu/projects/853255381/ (A Meta Achievement Collection game in beta! any ideas for achievements no matter how hard to code or whatever will be appreciated.)
Or Check out my profile! —> https://scratch.mit.edu/users/Necrochancer/

Powered by DjangoBB