All pastes #449364 Raw Edit

XNAF

public text v1 · immutable
·published 2007-04-20 04:55 UTC
rendered paste body

#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
#endregion

namespace XNA_Fighter
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        ContentManager content;

        SpriteBatch spriteBatch;  //Object that draws sprites
        
        Texture2D myTexture;
        
        Texture2D mainMenuTexture;

        Rectangle texRec;


        Vector2 spritePosition;
        Texture2D myTexture2;
        Vector2 spritePosition2;
        float xPos;
        float yPos;

        int screenW;
        int screenH;

        public Game1()
        {
            xPos = 200;
            yPos = 200;

            

            graphics = new GraphicsDeviceManager(this);
            content = new ContentManager(Services);
            spritePosition = new Vector2(0, 0);
            spritePosition2 = new Vector2(xPos, yPos);

            
        }


        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            screenW = graphics.GraphicsDevice.DisplayMode.Width;
            screenH = graphics.GraphicsDevice.DisplayMode.Height;
            graphics.PreferredBackBufferWidth = screenW;
            graphics.PreferredBackBufferHeight = screenH;
            graphics.IsFullScreen = true;
            texRec = new Rectangle(0, 0, screenW, screenH);

            base.Initialize();
        }


        /// <summary>
        /// Load your graphics content.  If loadAllContent is true, you should
        /// load content from both ResourceManagementMode pools.  Otherwise, just
        /// load ResourceManagementMode.Manual content.
        /// </summary>
        /// <param name="loadAllContent">Which type of content to load.</param>
        protected override void LoadGraphicsContent(bool loadAllContent)
        {
            if (loadAllContent)
            {
                myTexture = content.Load<Texture2D>(@"BlackDragon3");
                myTexture2 = content.Load<Texture2D>(@"Game");
                spriteBatch = new SpriteBatch(graphics.GraphicsDevice);

            }

            // TODO: Load any ResourceManagementMode.Manual content
        }


        /// <summary>
        /// Unload your graphics content.  If unloadAllContent is true, you should
        /// unload content from both ResourceManagementMode pools.  Otherwise, just
        /// unload ResourceManagementMode.Manual content.  Manual content will get
        /// Disposed by the GraphicsDevice during a Reset.
        /// </summary>
        /// <param name="unloadAllContent">Which type of content to unload.</param>
        protected override void UnloadGraphicsContent(bool unloadAllContent)
        {
            if (unloadAllContent == true)
            {
                content.Unload();
            }
        }


        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the default game to exit on Xbox 360 and Windows
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }

            float xNew = spritePosition2.X + 15f * GamePad.GetState(PlayerIndex.One).ThumbSticks.Right.X;
            float yNew = spritePosition2.Y - 15f * GamePad.GetState(PlayerIndex.One).ThumbSticks.Right.Y;

            if (xNew > 0 && xNew < 1240)
            {
                spritePosition2.X = xNew;
            }
            if (yNew > 0 && yNew < 680)
            {
                spritePosition2.Y = yNew;
            }
            // TODO: Add your update logic here

            base.Update(gameTime);
        }


        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.DarkGray);

            spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
            spriteBatch.Draw(myTexture,texRec,new Rectangle(0,0,1900,1080), Color.WhiteSmoke);
            spriteBatch.Draw(myTexture2, spritePosition2, Color.White);

            
                
            spriteBatch.End();

            base.Draw(gameTime);
            
        }
    }
}