Discuss Scratch

Lightswitch1
New to Scratch
5 posts

Help! Script problems! ARGH!

I want this little guy to walk around and when he touches a wall, he can't walk through the wall, but the problem is:
when green flag clicked
forever

if <key [ v] pressed?> then
change x by (1)

end

end

The problem is that the guy once he touches the wall he no longer moves, because he is touching the wall, and he can't move through walls, and sadly stays in one place. For anyone wondering the wall is multicoloured, so colour detection is eliminated.

Somebody please help!

-Lightswitch1
Theprodigy
Scratcher
100+ posts

Help! Script problems! ARGH!

use sensor sprites, that is, 4 sprites that surround this character and “sense” if the character is touching anything by determining if they themselves are touching something. With this method when a sensor goes off you'll know where from, and can stop movement in that direction.

Last edited by Theprodigy (Aug. 5, 2014 16:43:44)

joespray
Scratcher
100+ posts

Help! Script problems! ARGH!

Lightswitch1 wrote:

I want this little guy to walk around and when he touches a wall, he can't walk through the wall, but the problem is:
when green flag clicked
forever

if <key [ v] pressed?> then
change x by (1)

end

end

The problem is that the guy once he touches the wall he no longer moves, because he is touching the wall, and he can't move through walls, and sadly stays in one place. For anyone wondering the wall is multicoloured, so colour detection is eliminated.

Somebody please help!

-Lightswitch1

Your problem is that since he is touching the wall, no scripts occur. Can you give me the project/ scratch blocks so I can see into it?
joespray
Scratcher
100+ posts

Help! Script problems! ARGH!

Theprodigy wrote:

use sensor sprites, that is, 4 sprites that surround this character and “sense” if the character is touching anything by determining if they themselves are touching something. With this method when a sensor goes off you'll know where from, and can stop movement in that direction.
Sensors are great, but unnecessary. Look here to see what I did- http://scratch.mit.edu/projects/25304926/
Theprodigy
Scratcher
100+ posts

Help! Script problems! ARGH!

joespray wrote:

Sensors are great, but unnecessary. Look here to see what I did- http://scratch.mit.edu/projects/25304926/
That would be true if you had no obstacle otherwise it gets very complicated creating if statements to block out complex areas.

Also there is a glitch in your (joespray) game, you can walk into the bottom right corner, then walk down and out of the map.

Sensors work globally in any area with any kind of boundary, and with as many obstacles as are needed for the project.
joespray
Scratcher
100+ posts

Help! Script problems! ARGH!

Theprodigy wrote:

joespray wrote:

Sensors are great, but unnecessary. Look here to see what I did- http://scratch.mit.edu/projects/25304926/
That would be true if you had no obstacle otherwise it gets very complicated creating if statements to block out complex areas.

Also there is a glitch in your (joespray) game, you can walk into the bottom right corner, then walk down and out of the map.

Sensors work globally in any area with any kind of boundary, and with as many obstacles as are needed for the project.

THanks for telling me, I will fix it.
djgamer98
Scratcher
12 posts

Help! Script problems! ARGH!

it's easy,just use other script,like this.
when green flag clicked
forever

if <key [ v] pressed?> then

change x by (10)
end
if <touching [edge v] ?> then

hide

end
if <not <touching [edge v] ?>> then

show
end

end

Last edited by djgamer98 (Aug. 8, 2014 04:30:07)

Powered by DjangoBB