ZuneHD: Snowflakes(With downloads)

Just a little thing playing around

Heres the main part of the code with comments. Download the source for the rest:

Vector3 accelerometer = Accelerometer.GetState().Acceleration;

            for (int i = 0; i < snowflakes.Count; i++)

            {

                //get the object out of the collection

                GameObjects go = (GameObjects)snowflakes[i];

 

                //work out the new acceleration. We add its random weight times the tilt to the current acc.

                //it has random weight so they all move seperately else they will all go into one big blob ;)

                float newXAcc = (go.acceleration.X + (accelerometer.X * (float)(go.weight)));

                float newYAcc = (go.acceleration.Y + (-(accelerometer.Y * (float)(go.weight))));

 

                //stop them speeding up too much

                newXAcc = MathHelper.Clamp(newXAcc, -5, 5);

                newYAcc = MathHelper.Clamp(newYAcc, -5, 5);

 

                //works out their new x and y positions

                float newX = go.position.X + newXAcc;

                float newY = go.position.Y + newYAcc;

 

                //does some bounds checking so they dont go off the screen.

                if (((newX > (viewportRect.Left + 1)))

                    && (newX < (viewportRect.Left + viewportRect.Width - go.rectangle.Width)))

                {

                    //if its still inside the screen, then give it the new acceleration(remember we factored in 

                    //its old acc above

                    go.acceleration.X = newXAcc;

                }

                else

                {

                    //else make it bounce, and lose some momentum. It should be lower than 0.9 but

                    //this looks nicer than if it was realistic

                    go.acceleration.X = -(go.acceleration.X * 0.9f);

                }

 

                //same for y

                if ((newY > (viewportRect.Top + 1))

                    && (newY < (viewportRect.Top + viewportRect.Height - go.rectangle.Height)))

                {

                    go.acceleration.Y = newYAcc;

                }

                else

                {

                    go.acceleration.Y = -(go.acceleration.Y * 0.9f);

                }

                go.UpdatePosition();

 

            }

SnowflakesCCGAME.rar (14.23 kb)

SnowflakesSource.rar (69.23 kb)

Tags:

Comments

Dallin
Dallin United States
10/12/2009 2:09:48 PM Permalink

That is Awesome Could you post the Download. I've been wanting something like that ever since I got the Zune HD And I have been trying to make something but I have never used XNA before.

Christopher
Christopher United Kingdom
10/29/2009 4:39:56 PM Permalink

Having just bought a ZuneHD and keen to get into XNA I'm really enjoying your site!  Nice to see another co.za rocking the Zune Laughing

James
James Australia
11/2/2009 10:23:32 AM Permalink

thanks you so much for making these apps. My zune HD is so boring since you can't get apps in Australia. Keep making awesome apps mate.

lose stomach fat
lose stomach fat United States
1/16/2010 1:25:49 AM Permalink

How-do-you-do, just needed you to know I have added your site to my Google bookmarks because of your extraordinary blog layout. But seriously, I think your site has one of the freshest theme I've came across. It really helps make reading your blog a lot easier.

instant personal loans
instant personal loans United States
1/18/2010 11:26:16 AM Permalink

All who have accomplished great things have had a great aim, have fixed their gaze on a goal which was high, one which sometimes seemed impossible.

same day loans
same day loans United States
1/18/2010 11:54:24 PM Permalink

Laugh at yourself first, before anyone else can.

PC support
PC support United States
1/19/2010 6:21:02 PM Permalink

Couldn?t be written any better. Reading this post reminds me of my old room mate! He always kept talking about this. I will forward this article to him. Pretty sure he will have a good read. Thanks for sharing!

roulette sniper
roulette sniper United States
1/24/2010 8:48:51 PM Permalink

This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work.

club penguin
club penguin United States
1/26/2010 12:57:25 PM Permalink

Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share.

Ajax
Ajax United States
1/30/2010 1:22:37 AM Permalink

This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.

contractor accountants
contractor accountants United States
1/30/2010 7:03:31 PM Permalink

I have been surfing online more than three hours today, yet I never found any interesting article like yours. It's pretty worth enough for me. In my opinion, if all webmasters and bloggers made good content as you did, the internet will be much more useful than ever before.

Well, this is my first visit to your blog! We are a group of volunteers and starting a new initiative in a community in the same niche. Your blog provided us valuable information to work on. You have done a marvellous job!

Loans in Arizona
Loans in Arizona United States
2/2/2010 4:17:18 PM Permalink

Work is not man's punishment. It is his reward and his strength and his pleasure.

hypothèque
hypothèque United States
2/5/2010 4:04:21 PM Permalink

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me.

real estate idx
real estate idx United States
2/7/2010 4:58:34 PM Permalink

The blog was absolutely fantastic! Lots of great information and inspiration, both of which we all need!

niche marketing
niche marketing United States
2/8/2010 6:12:23 PM Permalink

The blog was absolutely fantastic! Lots of great information and inspiration, both of which we all need!

home air conditioning
home air conditioning United States
2/10/2010 12:28:28 AM Permalink

The blog was absolutely fantastic! Lots of great information and inspiration, both of which we all need!

jvc kd-hdr50
jvc kd-hdr50 United States
2/15/2010 9:34:53 AM Permalink

Me and my friend were arguing about an issue similar to this! Now I know that I was right. lol! Thanks for the information you post.

cialis
cialis United States
2/16/2010 11:56:39 PM Permalink

CIALIS (tadalafil) Online : It's not an accident that while looking for the best Cialis deal you've been led here. It's all because you'll find very low prices on Cialis on our website.

Wealthy Affiliate Review
Wealthy Affiliate Review United States
2/26/2010 9:36:39 PM Permalink

Nice information, many thanks to the author. It is incomprehensible to me now, but in general, the usefulness and significance is overwhelming. Thanks again and good luck!

aion download
aion download United States
2/28/2010 9:34:40 PM Permalink

Excellent read, I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch because I found it for him smile So let me rephrase that: Thanks for lunch!

Washington Rock NJ HVAC
Washington Rock NJ HVAC United States
3/4/2010 7:32:12 PM Permalink

Couldn?t be written any better. Reading this post reminds me of my old room mate! He always kept talking about this. I will forward this article to him. Pretty sure he will have a good read. Thanks for sharing!

boards
boards United States
3/6/2010 8:55:17 PM Permalink

I personally have embraced the new technologies and the CMS platforms, I think the new tools only make the web designs better. I am glad that new technologies are coming out in web design that make things easier, improved, and better looking for design.

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading