Author Topic: C#!  (Read 513 times)

0 Members and 1 Guest are viewing this topic.

Offline Physik

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +1/-9
  • Gender: Male
  • _root.pro.value = 1
    • View Profile
C#!
« on: May 19, 2010, 04:42:54 PM »
I've been working on a game, but it's not going very well lol...

namespace Movement2Tutorial
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        Texture2D player;
        Vector2 position;
        float rotation, deltaRotation;
        float scale, deltaScale;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        /// <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()
        {
            // TODO: Add your initialization logic here
            position = new Vector2(300, 200);
            deltaRotation = 0.1f;
            deltaScale = 0.02f;

            base.Initialize();
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            player = Content.Load<Texture2D>("player");
        }

        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }

        /// <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 game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            // TODO: Add your update logic here
            rotation += deltaRotation;
            if (rotation >= Math.PI * 2)
                rotation = 0;
            if (scale > 1.3)
                deltaScale *= -1;
            else if (scale < 0.4)
                deltaScale = (float)Math.Abs(deltaScale);
            scale += deltaScale;

            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)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            spriteBatch.Begin();
            spriteBatch.Draw(player, position, null, Color.White, rotation,
                new Vector2(player.Width / 2, player.Height / 2), scale, SpriteEffects.None, 0.0f);
            spriteBatch.End();

               

            base.Draw(gameTime);
        }
    }
}




Offline » Magic «

  • Who dares wins
  • WaffleBBQrz
  • ******
  • Posts: 4020
  • Karma: +101/-34
  • Gender: Male
  • Prepare for the worst :D
    • View Profile
Re: C#!
« Reply #1 on: May 20, 2010, 09:59:22 AM »
Wrong section...
Copyright© .:~`=-rANdOm-=`~:. GameServer's Administration Team 2008/2009/2010


bubbly bubbly so darn bubbly