This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-06-03 18:55:19

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

walking through walls

I made a game with the character moves to the door to gain points. On some harder levels, there is a wall to make it more difficult. The problem is that the character will just walk right through the wall. Any way to fix it?

Last edited by fg123 (2009-06-03 18:55:34)


Hai.

Offline

 

#2 2009-06-03 21:16:11

12three
Scratcher
Registered: 2008-06-12
Posts: 1000+

Re: walking through walls

If your character is moving to the right into the wall, do this.
<when green flag clicked>
<forever>
<if><touching[The wall]<<  <and>  >><key[ Right Arrow ]pressed?>
<change x by(-However many steps your sprite is moving.)

Offline

 

#3 2009-06-04 04:48:17

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: walking through walls

I like this method:

Non-rotating sprites
http://scratch.mit.edu/projects/Paddle2SeeFixIt/188825

Rotating sprites
http://scratch.mit.edu/projects/Paddle2SeeFixIt/188807


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#4 2009-06-04 13:04:52

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: walking through walls

One of my favorite solutions to this problem is to have a sort of box made of sensor sprites that surrounds the character at all times. Then, when the sensor in front of the sprite ("right sensor") comes in contact with a wall, it can set a variable that will prevent the sprite from moving. This works well because it prevents the user from having to back a sprite out of a corner as you would a car. It can work with all four sensors ("top", "bottom", "left") and you can vary the dynamics of how the sprite reacts when its sensors hit an obstacle. Personally, I like to make my sprites "bounce" off of the wall by throwing them backwards a few steps. Not only does it give a bit of realism if not overdone, but it prevents sprites from accidentally slipping through walls, which I find occurs when lots of scripts are running.

Last edited by fullmoon (2009-06-04 13:05:10)


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#5 2009-06-05 18:19:50

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: walking through walls

Thanks Paddle2see! I got it.


Hai.

Offline

 

#6 2009-07-22 17:59:50

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: walking through walls

Wait! I am making another project. And Paddle2See's way isn't working! heres the script.

http://img361.imageshack.us/img361/6850/script.gif


Hai.

Offline

 

#7 2009-07-22 21:54:39

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: walking through walls

hello???


Hai.

Offline

 

#8 2009-09-05 14:35:53

gametest
Scratcher
Registered: 2009-09-05
Posts: 3

Re: walking through walls

<when green flag clicked><forever><if><touching[ <set pen size to( <switch to costume[

Offline

 

#9 2009-09-05 14:37:20

gametest
Scratcher
Registered: 2009-09-05
Posts: 3

Re: walking through walls

<when green flag clicked>
<forever>
<if>
<key[ left ]pressed?>
<change{ score }by(

Offline

 

#10 2009-09-05 14:38:48

gametest
Scratcher
Registered: 2009-09-05
Posts: 3

Re: walking through walls

<when green flag clicked>
   <forever>
     <next costume>

Offline

 

#11 2009-09-05 16:03:00

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: walking through walls

huh?


Hai.

Offline

 

Board footer