Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Flappy_Bird.Entites
- {
- class Bird
- {
- public Texture2D[] Textures;
- public float Rotation;
- public float YSpeed;
- public int texturePosition;
- public Vector2 Position;
- public Bird()
- {
- Textures = new Texture2D[3];
- this.Textures[0] = Statics.CONTENT.Load<Texture2D>("Textures/bird1");
- this.Textures[1] = Statics.CONTENT.Load<Texture2D>("Textures/bird2");
- this.Textures[2] = Statics.CONTENT.Load<Texture2D>("Textures/bird3");
- YSpeed = 0;
- this.Position = new Vector2(150, 300);
- }
- public void Update()
- {
- YSpeed += 0.2f;
- if (YSpeed > 0.5)
- Rotation = 1f;
- else
- Rotation = -1f;
- }
- public void Draw()
- {
- Statics.SPRITEBATCH.Draw(this.Textures[this.texturePosition], this.Position, null, Color.White, this.Rotation, new Vector2(20, 20),1f, SpriteEffects.None, 0f);
- }
- }
- }
- namespace Flappy_Bird.Screens
- {
- public abstract class Screen
- {
- public virtual void LoadContent() { }
- public virtual void Update() { }
- public virtual void Draw() { }
- }
- }
- namespace Flappy_Bird.Screens
- {
- public class GameScreen : Screen
- {
- public Texture2D background;
- public Entites.Bird Bird;
- public GameScreen()
- {
- }
- public override void LoadContent()
- {
- background = Statics.CONTENT.Load<Texture2D>("Textures/background");
- Bird = new Entites.Bird();
- base.LoadContent();
- }
- public override void Update()
- {
- Bird.Update();
- base.Update();
- }
- public override void Draw()
- {
- Statics.SPRITEBATCH.Begin();
- Statics.SPRITEBATCH.Draw(this.background, Vector2.Zero, Color.White);
- Bird.Draw();
- Statics.SPRITEBATCH.End();
- base.Draw();
- }
- }
- }
- namespace Flappy_Bird
- {
- public class FlappyGame : Microsoft.Xna.Framework.Game
- {
- GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
- Screens.Screen currentScreen;
- public FlappyGame()
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- Statics.CONTENT = Content;
- Managers.InputManager input = new Managers.InputManager();
- }
- public override void Initialize()
- {
- base.Initialize();
- }
- public override void LoadContent()
- {
- spriteBatch = new SpriteBatch(GraphicsDevice);
- Statics.SPRITEBATCH = spriteBatch;
- currentScreen = new Screens.GameScreen();
- currentScreen.LoadContent();
- }
- public override void Update(GameTime gameTime)
- {
- Statics.GAMETIME = gameTime;
- Statics.INPUT.update();
- currentScreen.Update();
- base.Update(gameTime);
- }
- public override void Draw(GameTime gameTime)
- {
- GraphicsDevice.Clear(Color.CornflowerBlue);
- currentScreen.Draw();
- base.Draw(gameTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement