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

#1 2012-04-17 13:50:08

jad-123
New Scratcher
Registered: 2011-12-24
Posts: 1

sprite reacting background

How can i get the nackground of my project to change colour depending on the distance of the point on the stage and a sprite that moves during the simulation or game etc.? I thought of creating about 200 square sprites and placing them all over the stage acting as a background but this looks pixelated and takes along time to place to get it looking good. Is there a more efficent way os doing this?

Offline

 

#2 2012-04-17 13:52:33

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: sprite reacting background

Try using the color effect:

change [color v] effect by (25)
set [color v] effect to (25)

Offline

 

#3 2012-04-17 20:46:58

chanmanpartyman
Scratcher
Registered: 2011-05-30
Posts: 500+

Re: sprite reacting background

If you are trying distance to x: y:

([sqrt v] of ((((x position) - (position on screen x)) * ((x position) - (position on screen x))) + (((y position) - (position on screen y)) * ((y position) - (position on screen y)))))

Last edited by chanmanpartyman (2012-04-17 20:47:46)

Offline

 

#4 2012-04-17 22:53:32

scmb1
Scratch Team
Registered: 2009-03-19
Posts: 1000+

Re: sprite reacting background

Well, unfortunately there's not a super fast way to do it, but I thought of a way that might be less tedious than your current solution. Instead of changing the colors of sprites, you could have one sprite that uses pen to draw the background. In turbo-mode, it works pretty quickly. Maybe this or a variation could do the trick.  smile

when I receive [Change Background v] //this can be whatever triggers your background change
clear
go to x: (-240) y: (180) //start in the upper left-hand corner
repeat (360) //the 2 repeats cycle through every x,y position on the stage. Outer is going down, inner is across
 repeat (480) //go across until it gets to the end
  set pen color to (distance to [Sprite1 v])
  pen down //color the pixel
  pen up 
  change x by (1) //move 1 to the right
 end
 set x to (-240) //now go back to the left end 
 change y by (-1) //and down 1 row
end

Last edited by scmb1 (2012-04-17 22:55:51)


http://i48.tinypic.com/2z5pqad.png

Offline

 

Board footer