Ya coge los diamantes, aunque no los recuerda
This commit is contained in:
@@ -41,6 +41,7 @@ Player::Player(SDL_Renderer *renderer, Asset *asset, Input *input, Map *map)
|
||||
collider.insert(collider.end(), {p, p, p, p, p, p, p, p, p, p, p, p});
|
||||
underFeet.insert(underFeet.end(), {p, p, p});
|
||||
hookedOnMovingPlatform = -1;
|
||||
diamonds = 0;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -106,6 +107,7 @@ void Player::checkInput()
|
||||
vy -= jumpStrenght;
|
||||
state = jumping;
|
||||
jumpPressed = true;
|
||||
JA_PlaySound(sound_jump);
|
||||
}
|
||||
}
|
||||
else if (state == jumping)
|
||||
@@ -356,6 +358,12 @@ bool Player::isOnMovingPlatform()
|
||||
onMovingPlatform |= (map->getActorName(map->actorCollision(f)) == a_moving_platform);
|
||||
hookedOnMovingPlatform = std::max(hookedOnMovingPlatform, (map->actorCollision(f)));
|
||||
}
|
||||
|
||||
if (!onMovingPlatform)
|
||||
{
|
||||
hookedOnMovingPlatform = -1;
|
||||
}
|
||||
|
||||
return onMovingPlatform;
|
||||
}
|
||||
|
||||
@@ -433,5 +441,15 @@ void Player::setMap(Map *map)
|
||||
int Player::checkActors()
|
||||
{
|
||||
SDL_Rect rect = sprite->getRect();
|
||||
return map->actorCollision(rect);
|
||||
const int index = map->actorCollision(rect);
|
||||
const int name = map->getActorName(index);
|
||||
|
||||
if (name == a_diamond)
|
||||
{
|
||||
diamonds++;
|
||||
JA_PlaySound(sound_coin);
|
||||
map->deleteActor(index);
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
Reference in New Issue
Block a user