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

#1 2008-12-02 18:36:17

ctownnightrider
Scratcher
Registered: 2008-12-01
Posts: 3

Easy collision effects?

im working on a pacman clone for my first project, i can do all the movement and stuff, i will ask about the movement for ghosts later if i can't get it. the problem im having is with collision detection, i want the little dot to be hid when i touch it. i know i can do a broadcast thing for each one but that could get quite time consuming, plus i would need to make each dot its own sprite. is there a way i can get only the dot im touching to hide?

Offline

 

#2 2008-12-03 05:38:16

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

Re: Easy collision effects?

If the dots are part of the background and not a sprite, you could stamp over them with the background color.  This would work best if you had all the dots located on an evenly spaced grid of coordinates so that you could sense the approximate position with the pacman sprite, then compute the grid coordinates of the dot and then broadcast a message to a stamping sprite that would come over and "erase" the dot.  I hope that makes sense...let me know if you want a demo project uploaded.


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

Offline

 

#3 2008-12-03 12:35:56

adityasm9
Scratcher
Registered: 2008-03-12
Posts: 100+

Re: Easy collision effects?

Paddle2See wrote:

If the dots are part of the background and not a sprite, you could stamp over them with the background color.  This would work best if you had all the dots located on an evenly spaced grid of coordinates so that you could sense the approximate position with the pacman sprite, then compute the grid coordinates of the dot and then broadcast a message to a stamping sprite that would come over and "erase" the dot.  I hope that makes sense...let me know if you want a demo project uploaded.

or he could use dots of a specific colour

Offline

 

#4 2008-12-03 16:27:02

ctownnightrider
Scratcher
Registered: 2008-12-01
Posts: 3

Re: Easy collision effects?

well i figured out how to do it, i tried doing just hide if touching, that didnt work, but if you put a repeat around it then it does. so i ended up with 2 scripts for each sprite (every time i duplicated its a new sprite)
script 1
when flag clicked:
show

script 2
when flag clicked:
forever if (touching pacman):
hide

it worked perfectly

Offline

 

Board footer