Example #1
0
 public override void Draw(SpriteBatch spriteBatch, Map map)
 {
     if (visible)
     {
         base.Draw(spriteBatch, map);
     }
 }
Example #2
0
 public override void Draw(SpriteBatch theSpriteBatch, Map map)
 {
     foreach (Rocket aRocket in mRockets)
     {
         aRocket.Draw(theSpriteBatch, map);
     }
     base.Draw(theSpriteBatch, map);
 }
Example #3
0
        //Draws the sprite to the screen
        public virtual void Draw(SpriteBatch theSpriteBatch, Map map)
        {
            //Find the screen position for the texture
            Vector2 scrpos = map.worldToScreen(mPosition);

            //map.drawOnMap(theSpriteBatch, mSpriteTexture, mPosition, source);
            theSpriteBatch.Draw(mSpriteTexture, scrpos, source, Color.White);
        }
Example #4
0
        public void Update(GameTime theGameTime, Map map)
        {
            KeyboardState currentKeyboardState = Keyboard.GetState();
            UpdateMovement(currentKeyboardState);
            UpdateRocket(theGameTime, currentKeyboardState, map);
            mPreviousKeyboardState = currentKeyboardState;

            map.setViewPos(mPosition);

            base.Update(theGameTime, mSpeed, mDirection);
        }
Example #5
0
        /// <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
            player = new Player();

            map = new Map();

            Globals.screenWidth = graphics.GraphicsDevice.Viewport.Width;
            Globals.screenHeight = graphics.GraphicsDevice.Viewport.Height;

            base.Initialize();
        }
Example #6
0
        private void shootRocket(Map map)
        {
            if (mCurrentState == State.Walking)
            {
                //Check if there are any invisible rockets in the list
                bool createNewRocket = true;
                Vector2 rocketDirection;
                if (mDirection.X == MOVE_LEFT)
                {
                    rocketDirection = new Vector2(MOVE_LEFT, 0);
                }
                else
                {
                    rocketDirection = new Vector2(MOVE_RIGHT, 0);
                }
                Vector2 rocketStartPosition =
                    map.screenToWorld(new Vector2(mPosition.X + rocketDirection.X * X_FRAME_WIDTH + X_ROCKET_OFFSET,
                        mPosition.Y + Y_ROCKET_OFFSET));

                Vector2 rocketSpeed = new Vector2(ROCKET_SPEED, 0);
                foreach (Rocket aRocket in mRockets)
                {
                    if(!aRocket.visible){
                        createNewRocket = false;
                        aRocket.Fire(rocketStartPosition, rocketSpeed, rocketDirection);
                        break;
                    }
                }

                if (createNewRocket)
                {
                    Rocket aRocket = new Rocket();
                    aRocket.LoadContent(mContentManager);
                    aRocket.Fire(rocketStartPosition, rocketSpeed, rocketDirection);
                    mRockets.Add(aRocket);
                }
            }
        }
Example #7
0
        private void UpdateRocket(GameTime theGameTime, KeyboardState theCurrentKeyboardState, Map map)
        {
            foreach (Rocket aRocket in mRockets)
            {
                aRocket.Update(theGameTime);
            }

            if(theCurrentKeyboardState.IsKeyDown(Keys.Z) && !mPreviousKeyboardState.IsKeyDown(Keys.Z)){
                shootRocket(map);
            }
        }