static void Main(string[] args) { using (GameLoop game = new GameLoop()) { game.Run(); } }
public class GameLoop : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; public GameLoop() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; } protected override void Initialize() { base.Initialize(); } protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); } protected override void UnloadContent() { } protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); base.Draw(gameTime); } }
Texture2D ArkaPlan; Texture2D Ari;
Rectangle OyunPencere;
OyunPencere = new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height); ArkaPlan = Content.Load<Texture2D>("fil"); Ari = Content.Load<Texture2D>("ari");
public GameLoop() { this.Window.Title = "XNA - Oyun Temelleri"; graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; }
spriteBatch.Begin(SpriteBlendMode.AlphaBlend); spriteBatch.Draw(ArkaPlan, OyunPencere, Color.White); spriteBatch.Draw(Ari, Vector2D.Zero, Color.White); spriteBatch.End();
Vector2 Location = Vector2.Zero;
spriteBatch.Draw(Ari, Location, Color.White);
protected override void Update(GameTime gameTime) { KeyboardState ks = Keyboard.GetState(); if (ks.IsKeyDown(Keys.Escape)) this.Exit(); if (ks.IsKeyDown(Keys.Up)) Location.Y -= 3; if (ks.IsKeyDown(Keys.Down)) Location.Y += 3; if (ks.IsKeyDown(Keys.Left)) Location.X -= 3; if (ks.IsKeyDown(Keys.Right)) Location.X += 3; base.Update(gameTime); }