Does anybody here have a SIMPLE script that makes it so the payer can go along walls, but not through them?
KEYWORD: Simple (Or moderately simple, the minimum it takes to do it.)
What I would like:
I
(wall)--> I ^
I ^
IO <-- Little guy (Circle) can go up or down along the wall, or out of contact,
I but he can't go into it.
I
QUIZ:
What is the keyword?
a.) Simple
b.) IMPOSSIBLE TO UNDERSTAND!!
Thanx!
Offline
If you are using the move block to move, you can move -1 steps when you hit a wall.
Offline
archmage wrote:
If you are using the move block to move, you can move -1 steps when you hit a wall.
wouldnt it be move 1 step when you hit a wall? if you more -1 steps you are moving to the left and the wall is at the left i think
Offline
funkymonkey wrote:
archmage wrote:
If you are using the move block to move, you can move -1 steps when you hit a wall.
wouldnt it be move 1 step when you hit a wall? if you more -1 steps you are moving to the left and the wall is at the left i think
With the Move command, the sprite will go in whatever direction it is currently pointing; it could be left or right or something else entirely. So the -1 steps is correct, as it will move the sprite backwards.
Offline
The complication comes from the fact that if you allow your character to rotate, and it has non-circular shape, it can easily rotate into a wall such that going backwards (a simply move -1) doesn't always get you out in the way you expect. I think paddle2see mentioned elsewhere the most foolproof plan, which is to always keep a record (in variables) of the last "safe" x and y coordinates and direction. if the object touches a wall, make it go back to the safe x,y and face the safe direction.
The other way is to simply restrain your character to a grid and four directions.
Offline
Could you give me a script for that? Like, in a project I could download/understand?
-tanks!
-BC1
__ __ __
--(__) --(__) --(__)
OOO OOO OOO
Offline
I made up a couple of demos for you:
This one is for a sprite that can rotate
http://scratch.mit.edu/projects/Paddle2SeeFixIt/188807
And this one is for a sprite that doesn't rotate
http://scratch.mit.edu/projects/Paddle2SeeFixIt/188825
My projects above use some local variables. Deatheater has been working on simplifying my work even further by removing the use of variables at the cost of some code repetition. You might prefer this version for the rotating sprite:
http://scratch.mit.edu/projects/deatheater/188833
I hope you find them useful!
Offline
<say[ 2 ]for( 2 )secs>
Offline