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

#1 2009-08-30 11:58:02

snipper9
Scratcher
Registered: 2009-03-08
Posts: 11

how do i not make a figure go through another figure?

i have a tank game with a wall i just want to know how to not let the tanks go through the wall plz help thanks! smile

Offline

 

#2 2009-08-30 12:45:47

TimeFreeze
Scratcher
Registered: 2008-08-11
Posts: 500+

Re: how do i not make a figure go through another figure?

I guess there are two ways of doing this...

1. if <touching [wall]>
    move (-[how many ever steps it moves already]) steps

Example, if it moves 3 steps:

    if <touching [wall]>
    move (-3) steps

2. Create Sensors

Sensor script:

if <touching wall>
set hitTest to 1
else
set hitTest to 0

hitTest is a variable for THAT SPRITE ONLY.

Tank's script:

if <<Key [right arrow] is pressed> and <((hitTest of Sensor) = (1))>>
move (how many you want) steps.



I know, it's kind of hard to understand, if you still don't understand, tell me and I will create a project demonstration  smile .

Last edited by TimeFreeze (2009-08-30 12:46:18)


There are 10 types of people in this world: Those who understand binary, and those who don't. --[insert unrelated transition]-- GRANDILOQUENCE FTW!

Offline

 

#3 2009-08-30 12:51:31

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

Re: how do i not make a figure go through another figure?

Here's another approach you might try...

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


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

Offline

 

#4 2009-08-30 17:52:37

snipper9
Scratcher
Registered: 2009-03-08
Posts: 11

Re: how do i not make a figure go through another figure?

Thank you but it is a tank game where it is user verus computer and there are walls you can hide behind (i don't have a sesor board) and i know how to stop the bullet but i don't want to tanks to go through.

Offline

 

#5 2009-08-30 20:30:18

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

Re: how do i not make a figure go through another figure?

snipper9 wrote:

Thank you but it is a tank game where it is user verus computer and there are walls you can hide behind (i don't have a sesor board) and i know how to stop the bullet but i don't want to tanks to go through.

Sure, I understand.  That demo I pointed you towards would probably do the trick.  Replace the cat costume with a tank and you have a tank that won't go through walls.


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

Offline

 

#6 2011-04-15 18:37:42

aadil10
Scratcher
Registered: 2011-04-15
Posts: 1

Re: how do i not make a figure go through another figure?

I KNOW HOW TO DO IT
Put:
When Flag click
Forever if, touching ...sprite (e.g)...
point towards, direction
move -2(e.g) steps
Then it will move back the way it came however many steps you want!
DIAGRAMS BELOW:
[blocks]<when green flag clicked><when green flag clicked>[/blocks]
[blocks]<forever if><touching[  [/blocks]
[blocks] <point towards( <direction>[/blocks]
[blocks] <move(  )steps>[/blocks]

Offline

 

#7 2011-12-01 16:55:57

retrac910
Scratcher
Registered: 2010-10-02
Posts: 20

Re: how do i not make a figure go through another figure?

<when green flag clicked>
<{ wall }><touching[ <<  <not>  >><forever if>
<change x by( 3)

Offline

 

#8 2011-12-04 05:37:35

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: how do i not make a figure go through another figure?

Shouldn't this go in All About Scratch?


Why

Offline

 

Board footer