Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx05.iad.POSTED!not-for-mail Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Newsgroups: comp.lang.javascript Subject: Re: dealing with multiple objects on Canvas References: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Archenoth Message-ID: User-Agent: Opera Mail/12.16 (Linux) Lines: 95 NNTP-Posting-Host: 96.51.223.95 X-Complaints-To: internet.abuse@sjrb.ca X-Trace: 1385384982 96.51.223.95 (Mon, 25 Nov 2013 13:09:42 UTC) NNTP-Posting-Date: Mon, 25 Nov 2013 13:09:42 UTC Date: Mon, 25 Nov 2013 06:09:36 -0600 X-Received-Bytes: 2911 X-Received-Body-CRC: 3123835282 Xref: csiph.com comp.lang.javascript:22180 On Thu, 21 Nov 2013 20:49:21 -0600, Kale wrote: > I am trying to make snow but when I try to add more than one flake to > the canvas with different variables it doesn't work. Can anyone figure > out why this is? Here is my code: > > > > > > > Snowy > > > > > no support >
> > > > > You are reassigning c to a number so you can't access your canvas object... Also you are sharing your pseudo-random numbers with all of your flakes, so when one gets a random number, they all get the same one making them all act the exact same. Also, as opposed to having 1001 different variables all incrementing one at a time, something that you could likely utilize well here is function scope; make a function to hold your snowflake code. That way you can have multiple flakes with their own values in a somewhat protected environment. All you would need to do to add another flake would be to call the function and be done with it. (Perhaps utilizing for loop for the amount you want.) -- The arch foe