Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 2nd, 2012  |  syntax: C#  |  size: 10.61 KB  |  views: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. using System;
  3. using System.Runtime.InteropServices;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using Microsoft.Xna.Framework;
  7. using Microsoft.Xna.Framework.Audio;
  8. using Microsoft.Xna.Framework.Content;
  9. using Microsoft.Xna.Framework.GamerServices;
  10. using Microsoft.Xna.Framework.Graphics;
  11. using Microsoft.Xna.Framework.Input;
  12. using Microsoft.Xna.Framework.Media;
  13.  
  14. namespace Breakout
  15. {
  16.     public class Game1 : Microsoft.Xna.Framework.Game
  17.     {
  18.         [DllImport("user32.dll", CharSet = CharSet.Auto)]
  19.         public static extern uint MessageBox(IntPtr hWnd, String text, String caption, uint type);
  20.  
  21.  
  22.         GraphicsDeviceManager graphics;
  23.         SpriteBatch spriteBatch;
  24.  
  25.         Texture2D verticalLinesIcon;
  26.         Vector2 verticalLinesPosition = Vector2.Zero;
  27.  
  28.         Texture2D horizontalLinesIcon;
  29.         Vector2 horizontalLinesPosition = Vector2.Zero;
  30.  
  31.         Texture2D squareIcon;
  32.         Vector2 squarePosition = Vector2.Zero;
  33.         Texture2D circleIcon;
  34.         Vector2 circlePosition = Vector2.Zero;
  35.        
  36.         Texture2D infinityIcon;
  37.         Vector2 infinityPosition = Vector2.Zero;
  38.  
  39.         Texture2D DiamondIcon;
  40.         Vector2 DiamondPosition = Vector2.Zero;
  41.  
  42.  
  43.         Texture2D ball1;
  44.         Vector2 ball1Position = Vector2.Zero;
  45.  
  46.         Texture2D ball2;
  47.         Vector2 ball2Position = Vector2.Zero;
  48.         Texture2D ball3;
  49.         Vector2 ball3Position = Vector2.Zero;
  50.         Texture2D ball4;
  51.         Vector2 ball4Position = Vector2.Zero;
  52.         Texture2D ball5;
  53.         Vector2 ball5Position = Vector2.Zero;
  54.         Texture2D ball6;
  55.         Vector2 ball6Position = Vector2.Zero;
  56.  
  57.         Texture2D ball7;
  58.         Vector2 ball7Position = Vector2.Zero;
  59.  
  60.         Texture2D ball8;
  61.         Vector2 ball8Position = Vector2.Zero;
  62.  
  63.  
  64.         Texture2D ball9;
  65.         Vector2 ball9Position = Vector2.Zero;
  66.  
  67.         Texture2D ball10;
  68.         Vector2 ball10Position = Vector2.Zero;
  69.         Texture2D ball11;
  70.         Vector2 ball11Position = Vector2.Zero;
  71.         Texture2D ball12;
  72.         Vector2 ball12Position = Vector2.Zero;
  73.         Texture2D ball13;
  74.         Vector2 ball13Position = Vector2.Zero;
  75.         Texture2D ball14;
  76.         Vector2 ball14Position = Vector2.Zero;
  77.  
  78.         Texture2D ball15;
  79.         Vector2 ball15Position = Vector2.Zero;
  80.  
  81.         Texture2D ball16;
  82.         Vector2 ball16Position = Vector2.Zero;
  83.         Color backColor = Color.CornflowerBlue;
  84.  
  85.         public Game1()
  86.         {
  87.             graphics = new GraphicsDeviceManager(this);
  88.             Content.RootDirectory = "Content";
  89.         }
  90.  
  91.  
  92.         protected override void Initialize()
  93.         {
  94.  
  95.            
  96.             base.Initialize();
  97.             this.IsMouseVisible = true;
  98.  
  99.           //  MessageBox(new IntPtr(0), string.Format("graphics.GraphicsDevice.Viewport.Width"), "MessageBox title", 0);
  100.         }
  101.  
  102.  
  103.         protected override void LoadContent()
  104.         {
  105.  
  106.             spriteBatch = new SpriteBatch(GraphicsDevice);
  107.  
  108.  
  109.  
  110.             verticalLinesIcon = Content.Load<Texture2D>("verticalLinesIcon");
  111.             verticalLinesPosition = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((verticalLinesIcon.Width / 2) - 150), graphics.GraphicsDevice.Viewport.Height - 60);
  112.  
  113.             horizontalLinesIcon = Content.Load<Texture2D>("horizontalLinesIcon");
  114.             horizontalLinesPosition = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((horizontalLinesIcon.Width / 2) - 50), graphics.GraphicsDevice.Viewport.Height - 60);
  115.  
  116.  
  117.             squareIcon = Content.Load<Texture2D>("squareIcon");
  118.             squarePosition = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((squareIcon.Width / 2) + 50), graphics.GraphicsDevice.Viewport.Height - 60);
  119.  
  120.             circleIcon = Content.Load<Texture2D>("circleIcon");
  121.             circlePosition = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((circleIcon.Width / 2)+350), graphics.GraphicsDevice.Viewport.Height -60);
  122.  
  123.             DiamondIcon = Content.Load<Texture2D>("DiamondIcon");
  124.             DiamondPosition = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((DiamondIcon.Width / 2) + 250), graphics.GraphicsDevice.Viewport.Height - 60);
  125.  
  126.             infinityIcon = Content.Load<Texture2D>("infinityIcon");
  127.             infinityPosition = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((infinityIcon.Width / 2) + 150), graphics.GraphicsDevice.Viewport.Height - 60);
  128.  
  129.             ball1 = Content.Load<Texture2D>("ball");
  130.             ball1Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - (ball1.Width / 2), graphics.GraphicsDevice.Viewport.Height - 115);
  131.            
  132.             ball2 = Content.Load<Texture2D>("ball");
  133.             ball2Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 250), graphics.GraphicsDevice.Viewport.Height - 115);
  134.  
  135.             ball3 = Content.Load<Texture2D>("ball");
  136.             ball3Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 300), graphics.GraphicsDevice.Viewport.Height - 115);
  137.  
  138.             ball4 = Content.Load<Texture2D>("ball");
  139.             ball4Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 350), graphics.GraphicsDevice.Viewport.Height - 115);
  140.  
  141.             ball5 = Content.Load<Texture2D>("ball");
  142.             ball5Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 200), graphics.GraphicsDevice.Viewport.Height - 115);
  143.  
  144.             ball6 = Content.Load<Texture2D>("ball");
  145.             ball6Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 150), graphics.GraphicsDevice.Viewport.Height - 115);
  146.  
  147.             ball7 = Content.Load<Texture2D>("ball");
  148.             ball7Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 100), graphics.GraphicsDevice.Viewport.Height - 115);
  149.  
  150.             ball8 = Content.Load<Texture2D>("ball");
  151.             ball8Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 50), graphics.GraphicsDevice.Viewport.Height - 115);
  152.  
  153.  
  154.  
  155.             ball9 = Content.Load<Texture2D>("ball");
  156.             ball9Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - (ball1.Width / 2), graphics.GraphicsDevice.Viewport.Height - 215);
  157.  
  158.             ball10 = Content.Load<Texture2D>("ball");
  159.             ball10Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 250), graphics.GraphicsDevice.Viewport.Height - 215);
  160.  
  161.             ball11 = Content.Load<Texture2D>("ball");
  162.             ball11Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 300), graphics.GraphicsDevice.Viewport.Height - 215);
  163.  
  164.             ball12 = Content.Load<Texture2D>("ball");
  165.             ball12Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 350), graphics.GraphicsDevice.Viewport.Height - 215);
  166.  
  167.             ball13 = Content.Load<Texture2D>("ball");
  168.             ball13Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 200), graphics.GraphicsDevice.Viewport.Height - 215);
  169.  
  170.             ball14 = Content.Load<Texture2D>("ball");
  171.             ball14Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 150), graphics.GraphicsDevice.Viewport.Height - 215);
  172.  
  173.             ball15 = Content.Load<Texture2D>("ball");
  174.             ball15Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 100), graphics.GraphicsDevice.Viewport.Height - 215);
  175.  
  176.             ball16 = Content.Load<Texture2D>("ball");
  177.             ball16Position = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - ((ball2.Width / 2) + 50), graphics.GraphicsDevice.Viewport.Height - 215);
  178.  
  179.         }
  180.  
  181.  
  182.         protected override void UnloadContent()
  183.         {
  184.  
  185.         }
  186.  
  187.         protected override void Update(GameTime gameTime)
  188.         {
  189.  
  190.             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
  191.                 this.Exit();
  192.  
  193.             UpdateMouse();
  194.  
  195.             base.Update(gameTime);
  196.         }
  197.  
  198.         protected void UpdateMouse()
  199.         {
  200.             MouseState current_mouse = Mouse.GetState();
  201.  
  202.             // The mouse x and y positions are returned relative to the
  203.             // upper-left corner of the game window.
  204.             int mouseX = current_mouse.X;
  205.             int mouseY = current_mouse.Y;
  206.  
  207.             // Change background color based on mouse position.
  208.  
  209.             if (current_mouse.LeftButton == ButtonState.Pressed)
  210.             {
  211.                 backColor = new Color((byte)(mouseX / 3), (byte)(mouseY / 2), 0);
  212.             }
  213.            
  214.         }
  215.  
  216.         protected override void Draw(GameTime gameTime)
  217.         {
  218.             GraphicsDevice.Clear(backColor);
  219.  
  220.             spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
  221.  
  222.  
  223.  
  224.             spriteBatch.Draw(verticalLinesIcon, verticalLinesPosition, Color.White);
  225.             spriteBatch.Draw(horizontalLinesIcon, horizontalLinesPosition, Color.White);
  226.             spriteBatch.Draw(squareIcon, squarePosition, Color.White);
  227.             spriteBatch.Draw(infinityIcon, infinityPosition, Color.White);
  228.             spriteBatch.Draw(DiamondIcon, DiamondPosition, Color.White);
  229.             spriteBatch.Draw(circleIcon, circlePosition, Color.White);
  230.             spriteBatch.Draw(ball1, ball1Position, Color.White);
  231.             spriteBatch.Draw(ball2, ball2Position, Color.White);
  232.             spriteBatch.Draw(ball3, ball3Position, Color.White);
  233.             spriteBatch.Draw(ball4, ball4Position, Color.White);
  234.             spriteBatch.Draw(ball5, ball5Position, Color.White);
  235.             spriteBatch.Draw(ball6, ball6Position, Color.White);
  236.             spriteBatch.Draw(ball7, ball7Position, Color.White);
  237.             spriteBatch.Draw(ball8, ball8Position, Color.White);
  238.             spriteBatch.Draw(ball9, ball9Position, Color.White);
  239.             spriteBatch.Draw(ball10, ball10Position, Color.White);
  240.             spriteBatch.Draw(ball11, ball11Position, Color.White);
  241.             spriteBatch.Draw(ball12, ball12Position, Color.White);
  242.             spriteBatch.Draw(ball13, ball13Position, Color.White);
  243.             spriteBatch.Draw(ball14, ball14Position, Color.White);
  244.             spriteBatch.Draw(ball15, ball15Position, Color.White);
  245.             spriteBatch.Draw(ball16, ball16Position, Color.White);
  246.            
  247.  
  248.             spriteBatch.End();
  249.             base.Draw(gameTime);
  250.         }
  251.  
  252.     }
  253. }