C# Projects
Aquaphobia - 2D XNA Platformer
This summer, I have been part of a game project that has submitted a game for the Microsoft Dream Build Play competition. The team consisted of 7 individuals: 3 programmers, 1 designer, 1 artist, 1 producer, and 1 project manager. The project spanded from end of May to the beginning of August. The game features 2D platforming mechanics, per-pixel collision, HLSL, physics, OOP, and sound. I was in charge of player mechanics and movement, per-pixel collision, and the game sound. Below is are samples of the gameplay mechanics and player animation.
Solution Screen:

public override void HandleInput(GameInput input) {
PlayerIndex playerIndex;
float moveX = input.LeftThumbstickX(ControllingPlayer, out playerIndex) * 30 * level.Player.SpeedModifier;
float moveY = input.LeftThumbstickY(ControllingPlayer, out playerIndex);
if (input.IsMoveLeft(ControllingPlayer, out playerIndex))
moveX -= 30 * level.Player.SpeedModifier;
if (input.IsMoveRight(ControllingPlayer, out playerIndex))
moveX += 30 * level.Player.SpeedModifier;
if (level.tallyFinished && input.IsButtonA(ControllingPlayer, out playerIndex))
LoadingScreen.Load(ScreenManager, false, new BackgroundScreen(), new MainMenuScreen());
// If player DIES
if (!level.Player.IsAlive)
// Play death sound
SoundManager.PlaySound("PlayerDeath2", 1.0f);
// If player is NOT DYING
if (!level.Player.isDying)
{
// If player is NOT currently attacking
if (!level.Player.PlayerArm.attacking)
{
//If player is connected and presses PAUSE
if (!input.GamePadIsConnected || input.IsPause(ControllingPlayer) && !winTest)
{
SoundManager.PlaySound("Pause", 0.7f);
SoundManager.MusicVolume(0.5f); // turn down music for menu
ScreenManager.AddScreen(new SidePauseMenuScreen());
}
// If player is moving in any direction
if (moveX != 0 || moveY != 0)
{
// If player is moving LEFT
if (moveX < 0)
{
level.Player.PlayerArm.attDir = Arm.AttackDirection.Left;
level.Player.eDirection = Entity.Direction.Left;
}
// If player is moving RIGHT
else if (moveX > 0)
{
level.Player.PlayerArm.attDir = Arm.AttackDirection.Right;
level.Player.eDirection = Entity.Direction.Right;
}
// If player is pressing UP
if (moveY < -0.6f)
level.Player.PlayerArm.attDir = Arm.AttackDirection.Up;
// If player is pressing DOWN
else if (moveY > 0.6f)
level.Player.PlayerArm.attDir = Arm.AttackDirection.Down;
// Apply movement force accordingly
level.Player.AddForce(new Force(moveX, 0));
}
else // If player is NOT MOVING
{
if (level.Player.eDirection == Entity.Direction.Left)
level.Player.PlayerArm.attDir = Arm.AttackDirection.Left;
else if (level.Player.eDirection == Entity.Direction.Right)
level.Player.PlayerArm.attDir = Arm.AttackDirection.Right;
}
// If player presses the JUMP BUTTON
if (input.IsButtonA(ControllingPlayer, out playerIndex) && (level.Player.eState == Entity.State.OnGround))
{
// Apply jump force and update state
level.Player.AddForce(new Force(450.0, 90));
level.Player.eState = Entity.State.Jumping;
// Play jump sound
SoundManager.PlaySound("Jump", 0.9f);
}
// If player presses the USE BUTTON
if (input.IsButtonB(ControllingPlayer, out playerIndex) && level.Player.SpeedBoostAvailable)
{
// Use player power up
level.Player.UseSpeedBoost = true;
SoundManager.PlaySound("UsePower", 1.0f);
}
// If player is pressing the ATTACK BUTTON
if (input.IsButtonX(ControllingPlayer, out playerIndex))
{
// Update player state to ATTACKING
level.Player.eState = Entity.State.Attacking;
// If player is moving analogue stick in Y AXIS
if (moveY != 0)
{
// If player is pressing UP
if (moveY < -0.5f)
level.Player.PlayerArm.attDir = Arm.AttackDirection.Up;
// If player is pressing DOWN
else if (moveY > 0.5f)
{
level.Player.PlayerArm.attDir = Arm.AttackDirection.Down;
// Apply downward force
level.Player.AddForce(new Force(150.0, -90));
}
}
else // if player is NOT pressing UP or DOWN
{
// If player is NOT doing air attack
if (!level.Player.PlayerArm.allowAirAttack)
{
if (level.Player.eDirection == Entity.Direction.Left)
{
level.Player.PlayerArm.attDir = Arm.AttackDirection.Left;
level.Player.AddForce(new Force(100.0, 180)); // apply LEFT force
}
else if (level.Player.eDirection == Entity.Direction.Right)
{
level.Player.PlayerArm.attDir = Arm.AttackDirection.Right;
level.Player.AddForce(new Force(100.0, 0)); // apply RIGHT force
}
}
else // If player IS doing air attack
{
if (level.Player.eDirection == Entity.Direction.Left)
{
level.Player.PlayerArm.attDir = Arm.AttackDirection.Left;
level.Player.AddForce(new Force(350.0, 180)); // apply LEFT force
}
else if (level.Player.eDirection == Entity.Direction.Right)
{
level.Player.PlayerArm.attDir = Arm.AttackDirection.Right;
level.Player.AddForce(new Force(350.0, 0)); // apply RIGHT force
}
}
}
}
}
else // Else, if player IS currently attacking
{
level.Player.AddForce(new Force(moveX, 0));
// If the attack sound is allowed to be played
if (level.Player.PlayerArm.playAttackSound)
// Play attack sound
SoundManager.PlaySound("AttackWhip", 0.9f);
}
}
/// <summary>
/// Calculates all of the player sprite animations.
/// </summary>
public void ApplyAnimations()
{
if (IsAlive)
{
// If player is beginning or in a jump
if (eState == State.Jumping)
{
reachPeak = false;
// If the player is beginnign a jump
if (CurrentAnimation != "Jump")
CurrentAnimation = "Jump";
// Else, if player has reached the end of jump animation
else if (CurrentFrameAnimation.IsAtEnd)
eState = State.Falling;
}
// Else, if player is in falling or rising
else if (eState == State.Falling)
{
// If peak activation hasn't been triggered
if (!reachPeak)
{
// If player is reaching the peak of the jump
if (VelocityY > -160 && VelocityY < 0)
{
reachPeak = true; // trigger peak activation
// Do peak animation
if (CurrentAnimation != "Peak")
CurrentAnimation = "Peak";
}
// Else, if the player is rising or falling
else
if (CurrentAnimation != "Fall")
CurrentAnimation = "Fall";
}
else // Else, if peak has already been triggered
{
if (CurrentAnimation == "Peak")
if (CurrentFrameAnimation.PlayCount > 0)
CurrentAnimation = "Fall"; // Do fall animation
}
}
// Else, if player is on the ground
else if (eState == State.OnGround)
{
// If player was previously FALLING
if (prevState == State.Falling)
hasLanded = true; // allow for landing sound
else
hasLanded = false;
reachPeak = false;
// If the player is NOT moving
if (Math.Abs(VelocityX) < 10)
{
// Do idle animation
if (CurrentAnimation != "Idle")
CurrentAnimation = "Idle";
}
// Else, if the player IS moving
else
{
// Do move animation
if (CurrentAnimation != "Move")
CurrentAnimation = "Move";
}
}
}
prevState = eState; // Set previous state for next update
}