Discuss Scratch

hwers
New to Scratch
4 posts

I have the question

There is a sprit and it has 10 costumes.

The costumes are up,down,right,and left

I want make a game that pressed the same direction as the costumes.

switch costume to 1
wait untill key down arrow pressed
next costume
wait untill key up arrow pressed
next costume
wait untill key left arrow pressed
next costume
wait untill key right arrow pressed
next costume

Like this, and I don't know how do I let this game to stop when I pressed wrong direstion

plese anwer my question
hwers
New to Scratch
4 posts

I have the question

There is a sprit and it has 10 costumes.

The costumes are up,down,right,and left direstion.

I want make a game that pressed the same direction as the costumes.

switch costume to 1
wait untill (key down arrow pressed)
next costume
wait untill (key up arrow pressed)
next costume
wait untill (key left arrow pressed)
next costume
wait untill (key right arrow pressed)
next costume

Like this, and I don't know how do I let this game to stop when I pressed wrong direstion

Poosheku
Scratcher
72 posts

I have the question

Start with this:
when gf clicked
switch costume to [up]
forever
if <key [up arrow v] pressed ?> then
broadcast [down v]
stop [this script v]
else
stop all
end
end

Then use:
when i recive [down v] // Find this in the events tab, it will be brown and a different shape.
forever
if <key [down arrow v] pressed?> then
broadcast [down v]
stop [this script v]
else
stop all
end
end

and do the same for hte other directions. Hope I helped!




ErnieParke
Scratcher
1000+ posts

I have the question

Poosheku wrote:

Start with this:
when gf clicked
switch costume to [up v]
forever
if <key [up arrow v] pressed ?> then
broadcast [down v]
stop [this script v]
else
stop all
end
end

Then use:
when i receive [down v] // Find this in the events tab, it will be brown and a different shape.
forever
if <key [down arrow v] pressed?> then
broadcast [down v]
stop [this script v]
else
stop all
end
end

and do the same for hte other directions. Hope I helped!


I fixed a few errors. ;)

@hwers:
Anyway, I recommend this method instead:

when gf clicked
forever
if (key [up arrow v] pressed?) then
switch to costume [up v]
else
if (key [down arrow v] pressed?) then
switch to costume [down v]
end
end

If you have costumes for the four diagonals, then you'll need a bit more code. If you do, just say.

Pointing out,

ErnieParke

Last edited by ErnieParke (Oct. 31, 2013 19:25:04)


Powered by DjangoBB