/// <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() { camera = new Camera(); camera.Pos = new Vector2(320, 240); camera.Zoom = 0.5f; base.Initialize(); }
/// <summary> /// Update physics speeds /// </summary> public void Update(GameTime time, Camera cam) { if (isInBubble == true) return; if (isGrowing == false && isShrinking == false) { vPosLast = vPosition; //Clamp the X velocity if (moveState != MovementState.SPRINT) vVelocity.X = MathHelper.Clamp(vVelocity.X, -speedRunMax, speedRunMax); else if (moveState == MovementState.SPRINT) vVelocity.X = MathHelper.Clamp(vVelocity.X, -speedSprintMax, speedSprintMax); //Handle X + Y Movement HandleXMovement(); HandleYMovement(); //Update Position vPosition.X += vVelocity.X; vPosition.Y += vVelocity.Y; //Update camera //Moving left, but camera thinks I'm still moving right if (isLeft == true && cam.isLeft == false) { //Record distance change camXChange += vPosLast.X - vPosition.X; cam.XStick = true; if (camXChange >= 16) { cam.PanLeft(); camXChange = 0; cam.XStick = false; } } else if (isLeft == false && cam.isLeft == true) { camXChange += vPosition.X - vPosLast.X; cam.XStick = true; if (camXChange >= 16) { cam.PanRight(); camXChange = 0; cam.XStick = false; } } else cam.XStick = false; cam.plyPos = vPosition; //Do hit fx timer if (isHitTimer) { timerHitLife++; if (timerHitLife > durHitLife) isHitTimer = false; } this.Position = vPosition; } if (tHeld != null) { if (isLeft) tHeld.Position = new Vector2(vPosition.X - 10, Position.Y + Height - 16); else tHeld.Position = new Vector2(vPosition.X + 10, Position.Y + Height - 16); } //Handle animation UpdateAnimations(time); }