Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- namespace Game3
- {
- public class Game1 : Microsoft.Xna.Framework.Game
- {
- GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
- SpriteBatch spriteBatch2;
- int speed = 3;
- Texture2D bg;
- int x = 0;
- private AnimatedTexture SpriteTexture;
- private AnimatedTexture SpriteTexture2;
- private const float Rotation = 0;
- private const float Scale = 1.0f;
- private const float Depth = 0.5f;
- public Game1()
- {
- graphics = new GraphicsDeviceManager(this);
- SpriteTexture = new AnimatedTexture(Vector2.Zero, Rotation, Scale, Depth);
- SpriteTexture2 = new AnimatedTexture(Vector2.Zero, Rotation, Scale, Depth);
- Content.RootDirectory = "Content";
- }
- protected override void Initialize()
- {
- base.Initialize();
- }
- private Vector2 xPos = new Vector2(0, 335);
- private Vector2 xPos2 = new Vector2(0, 650);
- private const int Frames = 8;
- private const int FramesPerSec = 15;
- private const int FramesRow = 2;
- protected override void LoadContent()
- {
- bg = Content.Load<Texture2D>("mission");
- spriteBatch = new SpriteBatch(GraphicsDevice);
- SpriteTexture.Load(Content, "Rockman_walk", Frames, FramesRow, FramesPerSec);
- spriteBatch2 = new SpriteBatch(GraphicsDevice);
- SpriteTexture2.Load(Content, "Rockman_warp", 10, 1, FramesPerSec);
- }
- protected override void UnloadContent()
- {
- }
- protected override void Update(GameTime gameTime)
- {
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
- this.Exit();
- float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
- SpriteTexture.UpdateFrame(elapsed);
- xPos.X += speed;
- if (xPos.X > 650 && x == 0)
- {
- speed *= 0;
- x = 0;
- SpriteTexture2.UpdateFrame(elapsed);
- }
- base.Update(gameTime);
- }
- protected override void Draw(GameTime gameTime)
- {
- GraphicsDevice.Clear(Color.CornflowerBlue);
- spriteBatch.Begin();
- spriteBatch.Draw(bg, new Vector2(0, -100), Color.White);
- if (xPos.X < 650)
- {
- SpriteTexture.DrawFrame(spriteBatch, xPos);
- }
- else if (speed == 0 && x == 0)
- {
- SpriteTexture2.DrawFrame(spriteBatch, xPos);
- if (SpriteTexture2.Frame == 9)
- {
- x = 2;
- }
- }
- spriteBatch.End();
- base.Draw(gameTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement