Bowie

Untitled

Apr 3rd, 2016
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.Xna.Framework;
  6. using Microsoft.Xna.Framework.Graphics;
  7. using Microsoft.Xna.Framework.Input;
  8. namespace Caleb_FraserPE15
  9. {
  10. /// <summary>
  11. /// This is the main type for your game.
  12. /// </summary>
  13. public class Game1 : Game
  14. {
  15. GraphicsDeviceManager graphics;
  16. SpriteBatch spriteBatch;
  17. Texture2D Jerry;
  18. Rectangle xy;
  19. SpriteFont text;
  20. Vector2 loc;
  21. int Count = 0;
  22. public Game1()
  23. {
  24. graphics = new GraphicsDeviceManager(this);
  25. Content.RootDirectory = "Content";
  26. }
  27.  
  28. /// <summary>
  29. /// Allows the game to perform any initialization it needs to before starting to run.
  30. /// This is where it can query for any required services and load any non-graphic
  31. /// related content. Calling base.Initialize will enumerate through any components
  32. /// and initialize them as well.
  33. /// </summary>
  34. protected override void Initialize()
  35. {
  36. // TODO: Add your initialization logic here
  37. loc = new Vector2(20.8f, 100);
  38. xy = new Rectangle(400, 200, 250, 260);
  39. base.Initialize();
  40. }
  41.  
  42. /// <summary>
  43. /// LoadContent will be called once per game and is the place to load
  44. /// all of your content.
  45. /// </summary>
  46. protected override void LoadContent()
  47. {
  48. // Create a new SpriteBatch, which can be used to draw textures.
  49. spriteBatch = new SpriteBatch(GraphicsDevice);
  50. Jerry = this.Content.Load<Texture2D>("Jerry");
  51. text = this.Content.Load<SpriteFont>("SpriteFont1");
  52. Console.WriteLine(text);
  53.  
  54. // TODO: use this.Content to load your game content here
  55. }
  56.  
  57. /// <summary>
  58. /// UnloadContent will be called once per game and is the place to unload
  59. /// game-specific content.
  60. /// </summary>
  61. protected override void UnloadContent()
  62. {
  63. // TODO: Unload any non ContentManager content here
  64. }
  65.  
  66. /// <summary>
  67. /// Allows the game to run logic such as updating the world,
  68. /// checking for collisions, gathering input, and playing audio.
  69. /// </summary>
  70. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  71. protected override void Update(GameTime gameTime)
  72. {
  73. if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
  74. Exit();
  75.  
  76. // TODO: Add your update logic here
  77.  
  78. base.Update(gameTime);
  79. }
  80. public void DrawNeatRecursiveThing(int x, int y, int width, int height, Color color)
  81. {
  82. xy = new Rectangle(x, y, width, height);
  83. spriteBatch.Draw(Jerry, xy, color);
  84. //spriteBatch.DrawString(text, "" + Count, loc, Color.White);
  85. Count++;
  86. if (width > 250 && height > 260)
  87. {
  88. if (color == Color.Red)
  89. {
  90. color = Color.White;
  91. }
  92. else
  93. {
  94. color = Color.Red;
  95. }
  96. width = width / 2;
  97. height = height / 2;
  98. DrawNeatRecursiveThing(x, y, width, height, color);
  99. DrawNeatRecursiveThing(x + width, y + height, width, height, color);
  100. }
  101. spriteBatch.DrawString(text, "" + Count, loc, Color.White);
  102. }
  103.  
  104. /// <summary>
  105. /// This is called when the game should draw itself.
  106. /// </summary>
  107. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  108. protected override void Draw(GameTime gameTime)
  109. {
  110. GraphicsDevice.Clear(Color.CornflowerBlue);
  111. Game1 draw = new Game1();
  112. spriteBatch.Begin();
  113. draw.DrawNeatRecursiveThing(400, 200, 610, 250,Color.White);
  114. spriteBatch.End();
  115. //spriteBatch.Draw(Jerry, xy, Color.White);
  116.  
  117. // TODO: Add your drawing code here
  118.  
  119. base.Draw(gameTime);
  120. }
  121. }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment