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

#1 2009-08-30 16:52:22

KidProgrammer
Scratcher
Registered: 2008-01-03
Posts: 56

Terrain barriers/ objects.

Ok.. I know how to scroll, I can do it but what I dont know what to do is this:
Program the character so when he hits the buildings - he doesnt walk over them, he just bumps into them.

Offline

 

#2 2009-08-30 16:58:56

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

Re: Terrain barriers/ objects.

Just use the code from this project http://scratch.mit.edu/projects/archmage/635312


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 2009-08-30 18:30:53

weswesrock
Scratcher
Registered: 2009-06-25
Posts: 500+

Re: Terrain barriers/ objects.

You can program hit tests. Here's how
Make a new sprite and paint it like a small black line.
Make a green flag forever script with "go to sprite (character)".
Paint it correctly, and it will go to the desired region.
Then make a variable called "hit".
Using the If/else block, put "If touching (terrain)" in the if block, and under if put "set variable hit to 1"
Under else, put "set variable hit to 0".
Now, go to the character's scripts and put "if hit equals 1" and under that if, put an opposing movement.

Hope that wasn't too confusing  smile

Offline

 

Board footer