Advertisement
Guest User

C# error

a guest
Feb 27th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. namespace Flappy_Bird.Entites
  2. {
  3. class Bird
  4.  
  5. {
  6.  
  7. public Texture2D[] Textures;
  8. public float Rotation;
  9. public float YSpeed;
  10. public int texturePosition;
  11. public Vector2 Position;
  12.  
  13.  
  14.  
  15.  
  16. public Bird()
  17. {
  18. Textures = new Texture2D[3];
  19. this.Textures[0] = Statics.CONTENT.Load<Texture2D>("Textures/bird1");
  20. this.Textures[1] = Statics.CONTENT.Load<Texture2D>("Textures/bird2");
  21. this.Textures[2] = Statics.CONTENT.Load<Texture2D>("Textures/bird3");
  22. YSpeed = 0;
  23. this.Position = new Vector2(150, 300);
  24. }
  25.  
  26.  
  27. public void Update()
  28. {
  29. YSpeed += 0.2f;
  30.  
  31. if (YSpeed > 0.5)
  32. Rotation = 1f;
  33. else
  34. Rotation = -1f;
  35. }
  36.  
  37. public void Draw()
  38. {
  39. Statics.SPRITEBATCH.Draw(this.Textures[this.texturePosition], this.Position, null, Color.White, this.Rotation, new Vector2(20, 20),1f, SpriteEffects.None, 0f);
  40. }
  41. }
  42. }
  43. namespace Flappy_Bird.Screens
  44. {
  45. public abstract class Screen
  46. {
  47. public virtual void LoadContent() { }
  48.  
  49. public virtual void Update() { }
  50.  
  51. public virtual void Draw() { }
  52.  
  53. }
  54. }
  55.  
  56. namespace Flappy_Bird.Screens
  57. {
  58. public class GameScreen : Screen
  59. {
  60.  
  61. public Texture2D background;
  62. public Entites.Bird Bird;
  63.  
  64. public GameScreen()
  65. {
  66.  
  67. }
  68. public override void LoadContent()
  69. {
  70. background = Statics.CONTENT.Load<Texture2D>("Textures/background");
  71. Bird = new Entites.Bird();
  72.  
  73. base.LoadContent();
  74. }
  75.  
  76.  
  77. public override void Update()
  78. {
  79. Bird.Update();
  80. base.Update();
  81. }
  82.  
  83.  
  84. public override void Draw()
  85. {
  86. Statics.SPRITEBATCH.Begin();
  87.  
  88. Statics.SPRITEBATCH.Draw(this.background, Vector2.Zero, Color.White);
  89.  
  90. Bird.Draw();
  91.  
  92. Statics.SPRITEBATCH.End();
  93. base.Draw();
  94. }
  95. }
  96. }
  97. namespace Flappy_Bird
  98. {
  99. public class FlappyGame : Microsoft.Xna.Framework.Game
  100. {
  101. GraphicsDeviceManager graphics;
  102. SpriteBatch spriteBatch;
  103.  
  104.  
  105. Screens.Screen currentScreen;
  106. public FlappyGame()
  107. {
  108. graphics = new GraphicsDeviceManager(this);
  109. Content.RootDirectory = "Content";
  110.  
  111. Statics.CONTENT = Content;
  112.  
  113. Managers.InputManager input = new Managers.InputManager();
  114.  
  115. }
  116.  
  117. public override void Initialize()
  118. {
  119. base.Initialize();
  120. }
  121.  
  122.  
  123. public override void LoadContent()
  124. {
  125. spriteBatch = new SpriteBatch(GraphicsDevice);
  126. Statics.SPRITEBATCH = spriteBatch;
  127.  
  128. currentScreen = new Screens.GameScreen();
  129.  
  130. currentScreen.LoadContent();
  131. }
  132. public override void Update(GameTime gameTime)
  133. {
  134. Statics.GAMETIME = gameTime;
  135. Statics.INPUT.update();
  136.  
  137. currentScreen.Update();
  138.  
  139. base.Update(gameTime);
  140. }
  141. public override void Draw(GameTime gameTime)
  142. {
  143. GraphicsDevice.Clear(Color.CornflowerBlue);
  144.  
  145. currentScreen.Draw();
  146. base.Draw(gameTime);
  147. }
  148.  
  149. }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement