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

#1 2013-04-09 17:43:31

anchoill
New Scratcher
Registered: 2013-04-09
Posts: 1

changing pen color of a line that is drawn

Hi,

I've trying to create a game with my son similar to a game qix (http://www.scratch.mit.edu/ext/youtube/?v=NEq-mxFDuHM) I used to play when I was young. What I need to do is, using the arrows move a sprite around the screen, using pen this sprite draws a red line, when you hit the edge which has a boundary of a black line, the red line I’ve drawn changes color to black. I've a ball randomly moving around the screen when it hits black it bounces back. The idea of the game is to try and fill in as much of the stage with black lines thus reducing the amount of space the ball has to move around in. The catch is, if this ball hits the red line I’m drawing, I’m dead.  If I make it to another black line or the boundary black line the pen line I’ve drawn changes to black and if the ball hits it now, it bounces off and I’m safe. My problem is,  is there any way to change the pen line I’ve drawn to black like I’ve described above.

Thanks.

Offline

 

#2 2013-04-09 17:49:32

NoxSpooth
Scratcher
Registered: 2013-03-19
Posts: 500+

Re: changing pen color of a line that is drawn

I might be wrong, but... Once the line is drawn, you can't change its color...


http://i1244.photobucket.com/albums/gg572/BLU_Spy/Best-Cry-Ever_zps3b2b857a.gif Goodbye, 1.4... We'll miss you...

Offline

 

#3 2013-04-09 22:12:38

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: changing pen color of a line that is drawn

NoxSpooth wrote:

I might be wrong, but... Once the line is drawn, you can't change its color...

This is correct, but what you can do is draw over it in black.  I know the game you're talking about and used to enjoy it a lot too  smile

I guess the easiest way to make this work would be to record where the mouse was clicked to start the lines and then run something like this once the drawing sprite hits black:

if<touching color [black]?>
  set pen color to [black]
  go to x: (click x) y: (click y)
  pen up
end


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#4 2013-04-09 22:18:38

OverPowered
Scratcher
Registered: 2012-07-27
Posts: 100+

Re: changing pen color of a line that is drawn

Though you can't change stuff that's already been "penned," you can create a sprite that would go over all of your printed lines with black. Create a sprite, shaped like your ball but +1 pixel larger in all directions and give it this script:

when greenflag clicked
pen up
clear
delete (all v) of [PennedX v]
delete (all v) of [PennedY v]
set pen color to [black]
forever
go to [Ball v]
add (x position) to [PennedX v]
add (y position) to [PennedY v]
if <touching color [black]?>
repeat (length of [PennedX v])
go to x: (item (1) of [PennedX v]) y: (item (1) of [PennedY v])
delete (1) of [PennedX v]
delete (1) of [PennedY v]
end
end


Newest project: Tunnel TEST ~http://blocks.scratchr.org/API.php?user=OverPowered&amp;action=onlineStatus~ On my mind: Unicameralism

Offline

 

Board footer