Skip to content

Commit

Permalink
Merge pull request #10 from samdherron/ShrinkPlayerSize&FireballRando…
Browse files Browse the repository at this point in the history
…mGrav

Changed the playerShape.Height when jumping during a few of the jump …
  • Loading branch information
samdherron committed Jul 16, 2019
2 parents 07ae1e3 + 991f51f commit d745696
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 8 deletions.
21 changes: 16 additions & 5 deletions Dropper/Player.cs
Expand Up @@ -173,6 +173,7 @@ public override void Draw(GameTime gameTime)
{
spriteBatch.Begin();


//Determine whether to display Coloured Sprite or Normal Sprite
if (powerUpActive)
{
Expand Down Expand Up @@ -201,6 +202,7 @@ public override void Draw(GameTime gameTime)
new Vector2(0), spriteDirection, 0f);
}

//spriteBatch.FillRectangle(player, Color.Blue);
spriteBatch.End();


Expand Down Expand Up @@ -233,6 +235,7 @@ public override void Update(GameTime gameTime)

float deltaTime = (float)gameTime.ElapsedGameTime.TotalMilliseconds;

player.Height = picSize * scale;

if (powerupTimer >= 0 && powerUpActive)
{
Expand Down Expand Up @@ -283,6 +286,11 @@ public override void Update(GameTime gameTime)
else if (velocity.Y != 0)
{
midJump = true;

if (currentFrame > 14 && currentFrame < 19)
{
player.Height = (picSize * scale) - 32;
}
}


Expand Down Expand Up @@ -357,25 +365,26 @@ public override void Update(GameTime gameTime)
}

//Animation Logic Region
#region New Animation Frame Logic (Adventurer Sheet)
#region Animation Frame Logic (Adventurer Sheet)



//Switch to running frame
if ((velocity.X != 0 && currentFrame < 4))
{
currentFrame = 4;
}





//Cycle Back to Starting running frame
if (velocity.X != 0 && currentFrame >= 8 && !midJump && !isSliding)
{
currentFrame = 4;
}

if (velocity.X == 0 && !midJump && !isSliding)
{
//Standing still frames
if (currentFrame >= 3)
{
currentFrame = 0;
Expand All @@ -386,14 +395,15 @@ public override void Update(GameTime gameTime)

if (midJump)
{

if (currentFrame < 13)
{
currentFrame = 13;
}


}

/*
if (isSliding)
{
if (currentFrame < 9 || currentFrame > 12)
Expand All @@ -407,6 +417,7 @@ public override void Update(GameTime gameTime)
Console.WriteLine("Slide actiated");
}
*/

if (currentFrame < 20 && currentFrame != 9)
{
Expand Down
54 changes: 51 additions & 3 deletions Dropper/Projectile.cs
Expand Up @@ -3,6 +3,7 @@
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;

namespace Fireball_Dodger
{
Expand All @@ -18,7 +19,7 @@ class Projectile : DrawableGameComponent
Random rndColor = new Random();
Random rndSpawnX = new Random();
const float gravity = 0.06f;
public static float speed = 9.7f;
public static float speed = 7.7f;
Vector2 gravityVect = new Vector2(0, gravity);
Random rndY = new Random();
SpriteFont font;
Expand Down Expand Up @@ -102,6 +103,7 @@ public override void Update(GameTime gameTime)
velocity.X = 0;
velocity.Y = 0;


float deltaTime = (float)gameTime.ElapsedGameTime.TotalMilliseconds;

/*
Expand Down Expand Up @@ -149,6 +151,18 @@ public override void Update(GameTime gameTime)
Console.WriteLine("new random Y projectile value: " + projectileShape.Y);
projectilesFired++;

//Gets either div2 or div3 for the projectile size
if (projectileSizeRandomizer(rndColor) == "div2")
{
projectileShape.Width = (512 / 2);
projectileShape.Height = (197 / 2);
}
else
{
projectileShape.Width = (512 / 3);
projectileShape.Height = (197 / 3);
}

//See EnergyRandomRoll method
if (energyProjectile)
{
Expand All @@ -164,12 +178,14 @@ public override void Update(GameTime gameTime)

multiSpawn = multiSpawner(projectileShape, rndSpawnX);

/*
if (multiSpawn && multiCounter > 30)
{
Console.WriteLine("projectile Spawned");
Projectile p1 = new Projectile(Game);
multiCounter = 0;
}
}
*/

if (velocity.X == 0)
{
Expand All @@ -195,7 +211,25 @@ public override void Update(GameTime gameTime)
}

projectileShape.X = projectileShape.X + (int)velocity.X;
projectileShape.Y = projectileShape.Y + (int)velocity.Y;

if (projectileShape.Intersects(Player.player) && Player.powerUpActive)
{
if (rndColor.Next(0, 1) == 0)
{
velocity.Y += (gravityVect.Y * deltaTime * 15);
}
else
{
velocity.Y -= (gravityVect.Y * deltaTime * 15);
}
projectileShape.Y = projectileShape.Y + (int)velocity.Y;
}
else
{

projectileShape.Y = projectileShape.Y + (int)velocity.Y;
}

bulletWaitFireCounter++;

projectileShape.X -= rndSpawnX.Next(0, 15);
Expand Down Expand Up @@ -272,6 +306,20 @@ private bool EnergyRandomRoll(Random energyRoll)
return result;
}

private string projectileSizeRandomizer(Random rnd)
{
string result;

if (rnd.Next(0, 2) == 0)
{
result = "div2";
} else
{
result = "div3";
}

return result;
}


}
Expand Down

0 comments on commit d745696

Please sign in to comment.