Exemplo n.º 1
0
        protected override void Initialize()
        {
            platformContent = new PlatpormContent();

            platformList = new PlatformList(platformContent);

            platformList.AddPlatform(new Vector2(100, GameConstants.WindowHeight - 100));
            platformList.AddPlatform(new Vector2(400, GameConstants.WindowHeight - 200));

            droid = new Player(new Vector2(GameConstants.WindowWidth / 2, GameConstants.WindowHeight - 100), 5, platformList);

            base.Initialize();
        }
Exemplo n.º 2
0
        public Player(Vector2 playerPosition, int totalPlayerActionCount, PlatformList platformList = null)
        {
            this.totalPlayerActionCount = totalPlayerActionCount;
            playerActions       = new Animation[totalPlayerActionCount];
            currentPlayerAction = (int)ActionType.IDLE;

            this.playerPosition = playerPosition;
            playerVelocity      = new Vector2();

#if JUMP
            currentJumpingTime = 0;
            couldJump          = true;
#endif

#if PLATFORM
            this.platformList = platformList;
#endif
            currentSpriteEffect = SpriteEffects.None;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Update position and idex of droping object
        /// </summary>
        /// <param name="gameTime"> current game time </param>
        /// <param name="spritePosition"> store position of sprite witch drop this object </param>
        public void Update(GameTime gameTime, Vector2 spritePosition, PlatformList platformList = null)
        {
            if (isVisible)
            {
                float dropingDirection = 0;
                // If we drop to the right
                if (currentSpriteEffect == SpriteEffects.None)
                {
                    dropingDirection = 1;
                }
                // If we drop to the left
                else if (currentSpriteEffect == SpriteEffects.FlipHorizontally)
                {
                    dropingDirection = -1;
                }

                //Update current sword position
                position.X += dropingDirection * GameConstants.droppingObjectVelocityX * gameTime.ElapsedGameTime.Milliseconds;

                ++currentState;
                if (currentState >= states.StatesCount)
                {
                    currentState = 0;
                }

                // If current object leaves screen
                if (position.X < 0 || position.X > GameConstants.WindowWidth)
                {
                    isVisible = false;
                    // Set initial position for droping is equal to current sprite position
                    position = spritePosition;
                }

                //if (platformList != null)
                //{
                //    for (int currentPlatformID = 0; currentPlatformID < platformList.Count; ++currentPlatformID)
                //        if (new Rectangle((int)position.X, (int)position.Y, states[currentState].Width, states[currentState].Height).Intersects(platformList.At(currentPlatformID).Rectangle))
                //            platformList.At(currentPlatformID).VISIBILITY = false;
                //}
            }
        }