Don't like ads? PRO users don't see any ads ;-)
Guest

isaac

By: a guest on May 18th, 2012  |  syntax: C#  |  size: 4.82 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.Xna.Framework;
  5. using Microsoft.Xna.Framework.Audio;
  6. using Microsoft.Xna.Framework.Content;
  7. using Microsoft.Xna.Framework.GamerServices;
  8. using Microsoft.Xna.Framework.Graphics;
  9. using Microsoft.Xna.Framework.Input;
  10. using Microsoft.Xna.Framework.Input.Touch;
  11. using Microsoft.Xna.Framework.Media;
  12.  
  13.  
  14. namespace BlockHunter
  15. {
  16.     /// <summary>
  17.     /// This is the main type for your game
  18.     /// </summary>
  19.     public class Game1 : Microsoft.Xna.Framework.Game
  20.     {
  21.         GraphicsDeviceManager graphics;
  22.         SpriteBatch spriteBatch;
  23.  
  24.  
  25.         Texture2D spr_Blue;
  26.         Texture2D spr_BlueBroken;
  27.         Texture2D spr_Green;
  28.         Texture2D spr_GreenBroken;
  29.         Texture2D spr_Purple;
  30.         Texture2D spr_PurpleBroken;
  31.         Texture2D spr_Finish;
  32.         int blah;
  33.  
  34.  
  35.         public Game1()
  36.         {
  37.             graphics = new GraphicsDeviceManager(this);
  38.             Content.RootDirectory = "Content";
  39.  
  40.             // Frame rate is 30 fps by default for Windows Phone.
  41.             TargetElapsedTime = TimeSpan.FromTicks(333333);
  42.  
  43.             // Extend battery life under lock.
  44.             InactiveSleepTime = TimeSpan.FromSeconds(1);
  45.         }
  46.  
  47.         /// <summary>
  48.         /// Allows the game to perform any initialization it needs to before starting to run.
  49.         /// This is where it can query for any required services and load any non-graphic
  50.         /// related content.  Calling base.Initialize will enumerate through any components
  51.         /// and initialize them as well.
  52.         /// </summary>
  53.         protected override void Initialize()
  54.         {
  55.             // TODO: Add your initialization logic here
  56.             //TouchPanel.EnabledGestures = GestureType.Hol
  57.  
  58.             base.Initialize();
  59.         }
  60.  
  61.         /// <summary>
  62.         /// LoadContent will be called once per game and is the place to load
  63.         /// all of your content.
  64.         /// </summary>
  65.         protected override void LoadContent()
  66.         {
  67.             // Create a new SpriteBatch, which can be used to draw textures.
  68.             spriteBatch = new SpriteBatch(GraphicsDevice);
  69.  
  70.  
  71.             // TODO: use this.Content to load your game content here
  72.  
  73.                 spr_Blue = Content.Load<Texture2D>("Images/blue");
  74.                 spr_BlueBroken = Content.Load<Texture2D>("Images/bluebroken");
  75.                 spr_Green = Content.Load<Texture2D>("Images/green");
  76.                 spr_GreenBroken = Content.Load<Texture2D>("Images/greenbroken");
  77.                 spr_Purple = Content.Load<Texture2D>("Images/purple");
  78.                 spr_PurpleBroken = Content.Load<Texture2D>("Images/purplebroken");
  79.                 spr_Finish = Content.Load<Texture2D>("Images/finish");
  80.                
  81.  
  82.         }
  83.  
  84.         /// <summary>
  85.         /// UnloadContent will be called once per game and is the place to unload
  86.         /// all content.
  87.         /// </summary>
  88.         protected override void UnloadContent()
  89.         {
  90.             // TODO: Unload any non ContentManager content here
  91.         }
  92.        
  93.         /// <summary>
  94.         /// Allows the game to run logic such as updating the world,
  95.         /// checking for collisions, gathering input, and playing audio.
  96.         /// </summary>
  97.         /// <param name="gameTime">Provides a snapshot of timing values.</param>
  98.         protected override void Update(GameTime gameTime)
  99.         {
  100.             // Allows the game to exit
  101.             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
  102.                 this.Exit();
  103.  
  104.  
  105.             // TODO: Add your update logic here
  106.  
  107.             // Process touch events
  108.             TouchCollection touchCollection = TouchPanel.GetState();
  109.  
  110.             foreach (TouchLocation tl in touchCollection)
  111.             {
  112.                 if ((tl.State == TouchLocationState.Pressed)
  113.                         || (tl.State == TouchLocationState.Moved))
  114.                 {
  115.                     blah = 1;
  116.                    
  117.  
  118.                    
  119.                 }
  120.             }
  121.  
  122.            
  123.  
  124.             base.Update(gameTime);
  125.         }
  126.  
  127.         /// <summary>
  128.         /// This is called when the game should draw itself.
  129.         /// </summary>
  130.         /// <param name="gameTime">Provides a snapshot of timing values.</param>
  131.  
  132.         protected override void Draw(GameTime gameTime)
  133.         {
  134.             GraphicsDevice.Clear(Color.CornflowerBlue);
  135.             spriteBatch.Begin();
  136.  
  137.            spriteBatch.Draw(spr_Purple, new Vector2(10, 10), Color.White);
  138.  
  139.            if (blah == 1)
  140.            {
  141.                spriteBatch.Draw(spr_Finish, new Vector2(100, 10), Color.White);
  142.            }
  143.             spriteBatch.End();
  144.             // TODO: Add your drawing code here
  145.  
  146.             base.Draw(gameTime);
  147.         }
  148.     }
  149. }