You are here:

waves!

Put here an image with you slogan

Main Menu

Josh Russell Design
Sprite Proof of concept
Written by Administrator   
Saturday, 28 August 2010 17:58

Description:
Dark Theme is a modern and fresh Joomla template from Joomladesigns which includes the following web design features.

Compatible with Joomla! 1.5 native and legacy mode
Support for a number of module positions
Different layouts options available
Header site title image or H1 / H2 Site title / slogan text
Commented CSS File
Original Sliced Photoshop PSD file supplied with the web site design
Template installation guide supplied with design

To view the latest Joomla templates visit the joomla designs site.

public class BoatClass:DrawableGameComponent
    {
        protected Texture2D Boat;
        protected Texture2D BoatMotor;
        protected Rectangle spriteRectangle;
        protected Vector2 position;
        protected Vector2 motorposition;
        protected SpriteBatch sBatch;
        protected Vector2 origin;
        protected float boatrotation = 0;
        protected const int SHIPWIDTH = 118;
        protected const int SHIPHEIGHT = 238;
        protected const int MOTORWIDTH = 27;
        protected const int MOTORHEIGHT = 39;
        protected Rectangle screenBounds;
        public BoatClass(Game game, ref Texture2D boat, ref Texture2D motor) : base(game)
        {
            // TODO: Construct any child components here  
            Boat = boat;
            BoatMotor = motor;
            position = new Vector2();
            motorposition = new Vector2();
            screenBounds = new Rectangle(0, 0,
                game.GraphicsDevice.Viewport.Width,
                game.GraphicsDevice.Viewport.Height);
            spriteRectangle = new Rectangle(0, 0, SHIPWIDTH, SHIPHEIGHT);
            origin.X = Boat.Width / 2;
            origin.Y = Boat.Height / 2;
            //spriteRectangle = new Rectangle(30, 80, SHIPWIDTH, SHIPHEIGHT);
        }
        public void PutinStartingPosition()
        {
            position.X = screenBounds.Width / 2;
            position.Y = screenBounds.Height / 2;
        }
        public override void Initialize()
        {
            // TODO: Add your initialization code here
            base.Initialize();
        }
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here
            KeyboardState keyboard = Keyboard.GetState();
            if (keyboard.IsKeyDown(Keys.Up))
            {
                position.Y -= 3;
            }
            if (keyboard.IsKeyDown(Keys.Down))
            {
                position.Y += 3;
            }
            if (keyboard.IsKeyDown(Keys.Left))
            {
                //position.X -= 3;
                boatrotation += 0.03f;
            }
            if (keyboard.IsKeyDown(Keys.Right))
            {
                boatrotation -= 0.03f;
                //position.X += 3;
            }
            // Keep the ship inside the screen
            if (position.X < screenBounds.Left)
            {
                position.X = screenBounds.Left;
            }
            if (position.X > screenBounds.Width - SHIPWIDTH)
            {
                position.X = screenBounds.Width - SHIPWIDTH;
            }
            if (position.Y < screenBounds.Top)
            {
                position.Y = screenBounds.Top;
            }
            if (position.Y > screenBounds.Height - SHIPHEIGHT)
            {
                position.Y = screenBounds.Height - SHIPHEIGHT;
            }
            base.Update(gameTime);
        }
        public override void Draw(GameTime gameTime)
        {
            // Draw the ship
            sBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch));
            sBatch.Draw(Boat, new Rectangle(Convert.ToInt32(position.X), Convert.ToInt32(position.Y), Convert.ToInt32(spriteRectangle.Width), Convert.ToInt32(spriteRectangle.Height)), spriteRectangle, Color.White, boatrotation, origin, SpriteEffects.None, 0);
            sBatch.Draw(BoatMotor, position, spriteRectangle, Color.White);

            base.Draw(gameTime);
        }
        /// <summary>
        /// Get the bound rectangle of ship position in screen
        /// </summary>
        public Rectangle GetBounds()
        {
            return new Rectangle((int)position.X, (int)position.Y,
                SHIPWIDTH, SHIPHEIGHT);
        }
 

    }
 

 linked text

Last Updated on Monday, 30 August 2010 05:37