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

#1 2007-08-14 18:08:13

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

Touching at x_y_ blocks

I think this would be very useful for people who want their sprite to react differently when touched at different points. Many people have tried making a sprite that follows another sprite to determine where a sprite has been touched but the results are often inaccurate as the sprites can't follow another sprite well enough.

Example of how these blocks could be used:

///On player sprite
when flag pressed
wait until touching "platform" at x("x position") y(y position+20)
say "ow I hit my head"

If you added sprite length and sprite width blocks as well you could make the code work regardless of a sprites hight.

///On player sprite
when flag pressed
wait until touching "platform" at x("x position") y(y position+("sprite's lenght"/2))
say "ow I hit my head"

Last edited by archmage (2007-08-14 18:08:54)


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

 

#2 2007-08-14 18:17:01

AlveKatt
Scratcher
Registered: 2007-08-12
Posts: 100+

Re: Touching at x_y_ blocks

Can't you just use more than one sprite and tie them together?

Offline

 

#3 2007-08-14 18:39:12

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

Re: Touching at x_y_ blocks

AlveKatt wrote:

Can't you just use more than one sprite and tie them together?

Many people have tried doing this but even if you set one sprite to forever go to the x and y coordinates of another sprite it won't follow it perfectly. Also these blocks would remove them need for such tedious tasks.


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

 

#4 2007-08-15 04:20:20

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Touching at x_y_ blocks

instead of making one sprite follow the other, create variables X and Y and use those variables to move both sprites.  That way they stick together better.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#5 2007-08-15 12:25:19

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Touching at x_y_ blocks

Moving sprites independently, even to the same locations, can cause them to get out of sync.  The problem is worse on slower machines, as the overhead of interpreting the code is larger and the time between the moves is larger. 

Is "touching at x y" a good solution though?  If so, should the x,y be in absolute coordinates as suggested, or in sprite relative coordinates?  The example given showed doing a translation to get sprite-relative coordinates, but that did not take into account rotation of the sprite.

The other way people seem to handle the problem is to color the sensor area specially, and use color over color.  Perhaps what people want is to be able to add sensor areas to a sprite (perhaps invisibly) and detect "sensor area 3 touching sprite" or "sensor area 3 touching color".

Offline

 

#6 2007-08-15 12:39:36

AlveKatt
Scratcher
Registered: 2007-08-12
Posts: 100+

Re: Touching at x_y_ blocks

Does that mean that my plan of making a sprite capital ship with other sprites as turrets will make it look all wonky no matter what?

Offline

 

#7 2012-05-09 22:26:00

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Touching at x_y_ blocks

*bump* Great idea!


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#8 2012-05-09 22:35:17

Andres-Vander
Scratcher
Registered: 2010-09-16
Posts: 1000+

Re: Touching at x_y_ blocks

Can't you do this with variables now? This topic is seriously old


http://www.gifsoup.com/view1/2260823/flugelhorn-feline-o.gif

Offline

 

#9 2012-05-10 00:43:15

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

Re: Touching at x_y_ blocks

MathWizz wrote:

*bump* Great idea!

this can also be replicated with variables, like this:

when gf clicked
set [x pos v] to <x pos you want>
set [y pos v] to <y pos you want>
wait until<<<x position> = (x pos)> and <<y position> = (y pos)>>
do stuff
Please, next time you post, look at the time of the post before you.

Last edited by TorbyFork234 (2012-05-10 00:44:16)

Offline

 

Board footer