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

#1 2008-04-08 18:52:25

BlueClayman1
Scratcher
Registered: 2007-11-15
Posts: 6

Bounce/Stay Script?

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

 

#2 2008-04-08 20:06:37

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Bounce/Stay Script?

If you are using the move block to move, you can move -1 steps when you hit a wall.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#3 2008-04-09 16:43:49

stevii
Scratcher
Registered: 2008-01-19
Posts: 10

Re: Bounce/Stay Script?

I ♥ that saying !!!!!!!!! its soooooo funny!=]

Offline

 

#4 2008-04-09 19:57:30

zerkes
Scratcher
Registered: 2008-04-09
Posts: 2

Re: Bounce/Stay Script?

<move( -1 )steps>

Offline

 

#5 2008-04-09 19:59:10

zerkes
Scratcher
Registered: 2008-04-09
Posts: 2

Re: Bounce/Stay Script?

how do u MACK SIMPEL PLATFORMING!!!!!!!!!!!!!!!!!!!!!!!!!




             SIMPEL NOT TO COMPLACATED!!!!!!!

Offline

 

#6 2008-04-09 20:25:09

Zelda123
Scratcher
Registered: 2007-11-21
Posts: 1000+

Re: Bounce/Stay Script?

Forever
     If on edge, bounce.

Put the rotating/turning on "don't rotate.

Offline

 

#7 2008-04-10 07:51:43

funkymonkey
Scratcher
Registered: 2007-06-03
Posts: 1000+

Re: Bounce/Stay Script?

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


http://i243.photobucket.com/albums/ff67/hprules_photos/banner2.jpg
Kuzimu: Dawn of a New Age                                                                                                  Coming May 2010

Offline

 

#8 2008-04-10 07:58:22

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

Re: Bounce/Stay Script?

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.


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

Offline

 

#9 2008-04-11 15:56:42

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Bounce/Stay Script?

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

 

#10 2008-06-14 17:07:41

BlueClayman1
Scratcher
Registered: 2007-11-15
Posts: 6

Re: Bounce/Stay Script?

Could you give me a script for that? Like, in a project I could download/understand?

-tanks!
                  -BC1
                             __      __      __
                          --(__)  --(__)  --(__)
                           OOO   OOO   OOO

Offline

 

#11 2008-06-14 21:41:30

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

Re: Bounce/Stay Script?

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!


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

Offline

 

#12 2010-05-09 10:40:29

arman2003ahmadi
Scratcher
Registered: 2010-01-06
Posts: 4

Re: Bounce/Stay Script?

<say[ 2 ]for( 2 )secs>

Offline

 

#13 2010-05-09 12:01:28

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Bounce/Stay Script?

arman2003ahmadi wrote:

<say[ 2 ]for( 2 )secs>

I'm sorry, but this topics appears to be quite old. Please try not to post on old topics unless you have something helpful to say.

Offline

 

Board footer