XNA - Codeschnipsel - Move_Background-2

Webdesigner's
Verfügbare Informationen zu "XNA - Codeschnipsel - Move_Background-2"

  • Qualität des Beitrags: 0 Sterne
  • Beteiligte Poster: Snowball
  • Forum: Webdesigner's
  • Forenbeschreibung: Das Hilfe Forum für alle Webdesigner
  • aus dem Unterforum: C# XNA
  • Antworten: 1
  • Forum gestartet am: Freitag 20.07.2007
  • Sprache: deutsch
  • Link zum Originaltopic: XNA - Codeschnipsel - Move_Background-2
  • Letzte Antwort: vor 16 Jahren, 5 Monaten, 27 Tagen, 21 Stunden, 55 Minuten
  • Alle Beiträge und Antworten zu "XNA - Codeschnipsel - Move_Background-2"

    Re: XNA - Codeschnipsel - Move_Background-2

    Snowball - 28.10.2007, 19:20

    XNA - Codeschnipsel - Move_Background-2
    Hier mal nen wenig komplexer:

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

    namespace x8
    {
     
        public class Game1 : Microsoft.Xna.Framework.Game
        {
            GraphicsDeviceManager graphics;
            ContentManager content;
            KeyboardState ksState;

            SpriteBatch Sprite;
            SpriteFont Arial;

           
            int hSpeed = 10;
            int vSpeed = 10;

            Vector2 mousepos;
            Vector2 spritePosition = Vector2.Zero;
           
            Texture2D worldmap;
            Texture2D player;

         
            SpriteBatch spriteBatch;

            public Game1()
            {
                graphics = new GraphicsDeviceManager(this);
                content = new ContentManager(this.Services);

                graphics.IsFullScreen = true;

            }


            protected override void Initialize()
            {
               
                base.Initialize();
            }


            protected override void LoadGraphicsContent(bool loadAllContent)
            {
                if (loadAllContent)
                {
                    this.worldmap = Texture2D.FromFile(this.graphics.GraphicsDevice,
                      "worldmap.bmp");
                    this.player = Texture2D.FromFile(this.graphics.GraphicsDevice,
                      "player.bmp");
                    this.spriteBatch = new SpriteBatch(this.graphics.GraphicsDevice);
                    this.IsMouseVisible = true;
                }

                Arial = content.Load<SpriteFont>("Arial");
                Sprite = new SpriteBatch(graphics.GraphicsDevice);

               
            }


         
            protected override void UnloadGraphicsContent(bool unloadAllContent)
            {
                if (unloadAllContent == true)
                {
                    this.content.Unload();
                }
            }


            protected override void Update(GameTime gameTime)
            {

                MouseState mouse = Mouse.GetState();

                if (mouse.LeftButton == ButtonState.Pressed)
                {
                    mousepos = new Vector2(mouse.X, mouse.Y);
                }

               
                ksState = Keyboard.GetState();

                if (ksState.IsKeyDown(Keys.Up))
                {


                    this.spritePosition.Y += this.vSpeed;

                }

                if (ksState.IsKeyDown(Keys.Down))
                {


                    this.spritePosition.Y -= this.vSpeed;

                }

                if (ksState.IsKeyDown(Keys.Left))
                {
                   

                    this.spritePosition.X += this.hSpeed;

                }

                if (ksState.IsKeyDown(Keys.Right))
                {
                   

                    this.spritePosition.X -= this.hSpeed;
                   
                }

                if (ksState.IsKeyDown(Keys.Escape))
                {
                    this.Exit();
                }

             
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                    this.Exit();

                base.Update(gameTime);
            }


           
            protected override void Draw(GameTime gameTime)
            {
                this.graphics.GraphicsDevice.Clear(Color.White);

                this.spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
                this.spriteBatch.Draw(this.worldmap, this.spritePosition, Color.White);
                this.spriteBatch.Draw(this.player, new Vector2(350, 200), Color.White);
                this.spriteBatch.End();

                Sprite.Begin();
                Sprite.DrawString(Arial, "Maus Position: " + mousepos, new Vector2(250, 285), Color.Green);
                Sprite.End();


                base.Draw(gameTime);
            }
        }
    }



    Mit folgendem Code, können Sie den Beitrag ganz bequem auf ihrer Homepage verlinken



    Weitere Beiträge aus dem Forum Webdesigner's



    Ähnliche Beiträge wie "XNA - Codeschnipsel - Move_Background-2"

    Kaila - Move - dEnIz (Sonntag 19.11.2006)
    please move along - Anonymous (Sonntag 23.01.2005)
    Faith Can Move A Mountain - vanessa (Freitag 06.10.2006)
    PHADE_Background_V_1_0 - Butcher (Donnerstag 21.09.2006)
    Historical Background/Physical Geography (4-5.10.06) - *SoulFire* (Samstag 07.10.2006)
    Lieblings Move der WWE - batista (Donnerstag 01.12.2005)
    G-Move 2007 - Jan Schumann (Sonntag 25.03.2007)
    Donnerstag 08. Dezember 2005 im Move Club - Chris (Montag 05.12.2005)
    Neuer Background Allypage - Red Beast (Freitag 20.04.2007)
    1x11 Die Grosse Suche (Move On) - fallenangel (Sonntag 08.10.2006)