Permalink
Browse files

commented code and updated fireball functionality

  • Loading branch information...
wizrides
wizrides committed Apr 29, 2011
1 parent 8e64c09 commit 2ad49597dfa16801175172687d71148355a4b1e2
Showing with 33 additions and 10 deletions.
  1. +17 −4 MarioFireball.cpp
  2. +6 −2 Movable.cpp
  3. +10 −4 Shell.cpp
View
@@ -44,11 +44,15 @@ bool MarioFireball::canMove()
Drawable *dTop = this->checkTop();
Drawable *dBottom = this->checkBottom();
+ // if keepGoing is true, object can continue to move under current velocities
+ // if keepGoing is false, object needs to turn around
bool keepGoing = true;
+ // if something is detected to the right or the left of the object
+ // determine if it should be removed, or kill the object and be removed
if (dRight != NULL)
{
- if (dRight->objectType() == BREAKABLE || dRight->objectType() == QUESTION || dRight->objectType() == PIPE || dRight->objectType() == OFFQUESTION || dRight->objectType() == REGULAR || dRight->objectType() == FLAG)
+ if (dRight->objectType() == BREAKABLE || dRight->objectType() == QUESTION || dRight->objectType() == PIPE || dRight->objectType() == OFFQUESTION || dRight->objectType() == REGULAR || dRight->objectType() == FLAG || dRight->objectType() == SHELL)
{
Level::sharedLevel()->removeDrawable(this);
}
@@ -58,10 +62,9 @@ bool MarioFireball::canMove()
Level::sharedLevel()->removeDrawable(this);
}
}
-
if (dLeft != NULL)
{
- if (dLeft->objectType() == BREAKABLE || dLeft->objectType() == QUESTION || dLeft->objectType() == PIPE || dLeft->objectType() == OFFQUESTION || dLeft->objectType() == REGULAR || dLeft->objectType() == FLAG)
+ if (dLeft->objectType() == BREAKABLE || dLeft->objectType() == QUESTION || dLeft->objectType() == PIPE || dLeft->objectType() == OFFQUESTION || dLeft->objectType() == REGULAR || dLeft->objectType() == FLAG || dLeft->objectType() == SHELL)
{
Level::sharedLevel()->removeDrawable(this);
}
@@ -72,6 +75,7 @@ bool MarioFireball::canMove()
}
}
+ // if an enemy falls on the fireball, kill the enemy and the fireball
if (dTop != NULL) {
if (dTop->objectType() == GOOMBA || dTop->objectType() == TURTLE || dTop->objectType() == PLANT)
{
@@ -80,21 +84,30 @@ bool MarioFireball::canMove()
}
}
+ // if something is detected below the fireball
+ // if it is an enemy, kill it and the fireball
+ // if it should stop falling, set y velocity to 0
+ // if it hits a shell, shell should survive and fireball should disappear
+ // if two fireballs are directly next to one another, should both fall
if (dBottom != NULL) {
if (dBottom->objectType() == GOOMBA || dBottom->objectType() == TURTLE || dBottom->objectType() == PLANT)
{
Level::sharedLevel()->removeDrawable(dBottom);
Level::sharedLevel()->removeDrawable(this);
}
- else if (dBottom->objectType() == BREAKABLE || dBottom->objectType() == QUESTION || dBottom->objectType() == PIPE || dBottom->objectType() == OFFQUESTION || dBottom->objectType() == REGULAR || dBottom->objectType() == FLAG)
+ else if (dBottom->objectType() == BREAKABLE || dBottom->objectType() == QUESTION || dBottom->objectType() == PIPE || dBottom->objectType() == OFFQUESTION || dBottom->objectType() == REGULAR || dBottom->objectType() == FLAG )
{
this->setYVelocity(0.0);
}
+ else if (dBottom->objectType() == SHELL) {
+ Level::sharedLevel()->removeDrawable(this);
+ }
else if (dBottom->objectType() == MARIOFIREBALL){
this->setYVelocity(-1.0);
}
}
+ // nothing is below the fireball, it should also fall
else {
this->setYVelocity(-1.0);
}
View
@@ -34,6 +34,8 @@ bool Movable::canMove()
Drawable *dLeft = this->checkLeft();
Drawable *dBottom = this->checkBottom();
+ // if keepGoing is true, object can continue to move under current velocities
+ // if keepGoing is false, object needs to turn around
bool keepGoing = true;
// if nothing underneath
@@ -50,20 +52,21 @@ bool Movable::canMove()
}
}
- // if a block type is underneath
+ // if a type is underneath that shouldn't fall through, set velocity to 0
else
{
if (dBottom->objectType() == REGULAR || dBottom->objectType() == BREAKABLE || dBottom->objectType() == QUESTION || dBottom->objectType() == PIPE || dBottom->objectType() == OFFQUESTION)
{
this->setYVelocity(0.0);
}
+ // needs to ignore background and fall
else if (dBottom->objectType() == BACKGROUND)
{
this->setYVelocity(-2.0);
}
}
- // if nothing to the right or left
+ // if nothing to the right and if it should turn around at that object
if (dRight != NULL && dRight->objectType() != BACKGROUND)
{
if (dRight->objectType() == REGULAR || dRight->objectType() == BREAKABLE || dRight->objectType() == QUESTION || dRight->objectType() == PIPE)
@@ -72,6 +75,7 @@ bool Movable::canMove()
}
}
+ // if nothing is to the left and if it should turn around at that object
if (dLeft != NULL && dLeft->objectType() != BACKGROUND)
{
if (dLeft->objectType() == REGULAR || dLeft->objectType() == BREAKABLE || dLeft->objectType() == QUESTION || dLeft->objectType() == PIPE)
View
@@ -53,8 +53,12 @@ bool Shell::canMove()
Drawable *dBottom = this->checkBottom();
Drawable *dTop = this->checkTop();
+ // if keepGoing is true, object can continue to move under current velocities
+ // if keepGoing is false, object needs to turn around
bool keepGoing = true;
+ // if and object is detected to the right, left, bottom, or top
+ // and shell should kill it, remove from list
if (dRight != NULL)
{
if (dRight->objectType() == GOOMBA || dRight->objectType() == TURTLE || dRight->objectType() == PLANT)
@@ -81,34 +85,36 @@ bool Shell::canMove()
}
}
- // if nothing underneath
+ // if nothing underneath and make sure it doesn't detect itself, set to fall
if ((dBottom == NULL || dBottom == this) || dBottom->objectType() == BACKGROUND || dBottom->objectType() == COIN)
{
this->setYVelocity(-2.0);
}
- // if a block type is underneath
+ // // if a type is underneath that shouldn't fall through, set velocity to 0
else
{
if (dBottom->objectType() == REGULAR || dBottom->objectType() == BREAKABLE || dBottom->objectType() == QUESTION || dBottom->objectType() == PIPE || dBottom->objectType() == OFFQUESTION || dBottom->objectType() == FLAG)
{
this->setYVelocity(0.0);
}
+
+ // needs to ignore background and fall
else if (dBottom->objectType() == BACKGROUND)
{
this->setYVelocity(-2.0);
}
}
- // if nothing to the right or left
+ // if something is detected to the right or left, object should turn around
+ // should ignore the background objects
if (dRight != NULL && dRight->objectType() != BACKGROUND)
{
if (dRight->objectType() == REGULAR || dRight->objectType() == BREAKABLE || dRight->objectType() == QUESTION || dRight->objectType() == PIPE || dRight->objectType() == FLAG)
{
keepGoing = false;
}
}
-
if (dLeft != NULL && dLeft->objectType() != BACKGROUND)
{
if (dLeft->objectType() == REGULAR || dLeft->objectType() == BREAKABLE || dLeft->objectType() == QUESTION || dLeft->objectType() == PIPE || dLeft->objectType() == FLAG)

0 comments on commit 2ad4959

Please sign in to comment.