Browsing: xna

 

Texture Atlas (Sprite Sheet) Generator

March 20, 2010 by Rew

A texture atlas, or sprite sheet, is a single image containing a number of smaller textures or sprites. This is useful as it is more efficient for the graphics card to process (it doesn’t have to keep switching textures when drawing different textures, as it can just use the single texture and sample from different parts of it). It is also faster to load into RAM, as you are only loading in one image, as opposed to several smaller ones, so the loading can be done in one stage.

(more…)

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Twitter
  • Google Bookmarks
  • FriendFeed
  • LinkedIn
  • Mixx
  • Sphinn
  • Blogplay
 

Windows Phone 7 Flashlight (With SOS)

March 19, 2010 by Rew

I tried posting this as a comment in reply to this post, but the code got mangled, so I’m posting it here :)

            graphics.GraphicsDevice.Clear(
                /* Check for touch panel being pressed */
            TouchPanel.GetState().Count == 0 ?
                /* Touch panel released, so reset the timer. This is stored in the target elapsed time, so we don't have to create any variables :) We also turn off IsFixedTimeStep, so that TargetElapsedTime isn't used. */
                ((((this.IsFixedTimeStep = false) == false) && ((this.TargetElapsedTime = TimeSpan.FromMilliseconds(Math.Max(1.0f, gameTime.TotalGameTime.TotalMilliseconds))) == TimeSpan.Zero)) ? Color.Gray : Color.Gray) :
                /* Touch panel pressed, so do SOS */
                (gameTime.TotalGameTime - this.TargetElapsedTime).Seconds < 1 ? Color.White :
                (((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds >= 2) && ((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds < 3)) ? Color.White :
                (((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds >= 4) && ((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds < 5)) ? Color.White :
                (((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds >= 7) && ((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds < 9)) ? Color.White :
                (((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds >= 10) && ((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds < 12)) ? Color.White :
                (((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds >= 13) && ((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds < 15)) ? Color.White :
                (((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds >= 17) && ((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds < 18)) ? Color.White :
                (((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds >= 19) && ((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds < 20)) ? Color.White :
                (((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds >= 21) && ((gameTime.TotalGameTime - this.TargetElapsedTime).Seconds < 22)) ? Color.White :
                Color.Black);

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Twitter
  • Google Bookmarks
  • FriendFeed
  • LinkedIn
  • Mixx
  • Sphinn
  • Blogplay