#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 { /// /// This is the main type for your game /// 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); } /// /// 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. /// 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(); } /// /// Load your graphics content. If loadAllContent is true, you should /// load content from both ResourceManagementMode pools. Otherwise, just /// load ResourceManagementMode.Manual content. /// /// Which type of content to load. protected override void LoadGraphicsContent(bool loadAllContent) { if (loadAllContent) { myTexture = content.Load(@"BlackDragon3"); myTexture2 = content.Load(@"Game"); spriteBatch = new SpriteBatch(graphics.GraphicsDevice); } // TODO: Load any ResourceManagementMode.Manual content } /// /// 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. /// /// Which type of content to unload. protected override void UnloadGraphicsContent(bool unloadAllContent) { if (unloadAllContent == true) { content.Unload(); } } /// /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input and playing audio. /// /// Provides a snapshot of timing values. 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); } /// /// This is called when the game should draw itself. /// /// Provides a snapshot of timing values. 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); } } }