Esempio n. 1
0
		/// <summary>
		/// Update method for the Shoes that's called once a frame.
		/// </summary>
		/// <param name="gameTime">Snapshot of the game timing state.</param>
		/// <param name="guy">A reference to the Guy.</param>
		public void Update(GameTime gameTime, ref Guy guy)
		{
			this.handleAnimation(gameTime);
			handleMovement(gameTime, ref guy);
			doInterface(guy.isGuyBeingShot);

			oldKeyboardState = newKeyboardState; // In Update() so the interface works. Commented out at the bottom of handleMovement.
		}
Esempio n. 2
0
		protected override void LoadContent()
		{
			// Create a new SpriteBatch, which can be used to draw textures.
			spriteBatch = new SpriteBatch(GraphicsDevice);

			// Create and load the level.
			level = new Level(this.Content);

			// Load level.
			level.LoadLevel();
		   
			// Create the Shoes.
			shoes = new Shoes(Content.Load<Texture2D>("Sprites/Shoes32x48"), Character.State.Idle, 0, 32, 48, 0, spriteBatch, graphics.PreferredBackBufferHeight, graphics.PreferredBackBufferWidth, Keys.W, Keys.A, Keys.S, Keys.D, this.Content);

			// Set the initial position of the player.
			shoes.Position = level.getPlayerStartingPosition();

			// Create the Guy.
			guy = new Guy(Content.Load<Texture2D>("Sprites/Guy32x48"), spriteBatch, 0, 0, 32, 48, graphics.PreferredBackBufferHeight, graphics.PreferredBackBufferWidth);

			// Load the debug font. We use this for debugging purposes.
			debugFont = Content.Load<SpriteFont>("debugFont"); 
		}
Esempio n. 3
0
		// ******************
		// * START MOVEMENT *
		// ******************

		/// <summary>
		/// Handles all of the movement for the Shoes.
		/// </summary>
		/// <param name="gameTime">Snapshot of the game timing state.</param>
		/// <param name="guy">A reference to the Guy.</param>
		private void handleMovement(GameTime gameTime, ref Guy guy)
		{
			float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;	// Represents the amount of time that has passed since the previous frame.
			newKeyboardState = Keyboard.GetState();						// Get the new state of the keyboard.

			// Handles delaying movement after the Shoes have collided with a Spring.
			stopDelayingMovementAfterSpringCollisionIfPossible();

			// Set the horizontal velocity based on if the Shoes are on the ground or in the air.
			setHorizontalVelocity();

			// Check to see if the player wants to jump. If so, set the vertical velocity appropriately.
			checkIfShoesWantToJump(guy.tileAbove());

			// Move the Shoes if the player has pressed the appropriate key.
			moveShoesLeftOrRightIfPossible(delta);

			// Have the Shoes ascend from jumping if they haven't started falling yet.
			haveShoesAscendFromJumpOrFallFromGravity(delta);

			// If the Shoes have collided with a Spring, then apply movement from the Spring over time.
			checkIfShoesCanBounceFromSpring(delta);

			// If the Shoes have collided with a Launcher and are ready to be launched, then apply movement from the Launcher over time.
			checkIfShoesCanLaunch(guy.powerOfLauncherBeingUsed);

			// If the Shoes have fallen to the bottom of the map, reset the Shoes and Guy to the starting position of the level.
			resetShoesAndGuyToLevelStartingPositionIfNecessary(guy);

			// Update timers.
			updateTimers(gameTime);

			// Get the old state of the keyboard.
			//oldKeyboardState = newKeyboardState; // Commented out so the interface works.
		}
Esempio n. 4
0
		/// <summary>
		/// If the Shoes have fallen to the bottom of the map, reset the Shoes and Guy to the starting position of the level.
		/// </summary>
		/// <param name="guy">A reference to the Guy. Needed so that a check can be done to ensure that there isn't a tile above the linked Guy/Shoes.</param>
		private void resetShoesAndGuyToLevelStartingPositionIfNecessary(Guy guy)
		{
			if (Position.Y > 704)
			{
				Position = Level.playerStartingPosition;
				guy.Position = Position;
			}
		}