Mario: teleport to hardcoded level
This commit is contained in:
+26
-3
@@ -36,7 +36,7 @@ Mario::Mario(int x, int y, const std::shared_ptr<SDLPP::Renderer> &renderer, std
|
||||
Mario::Mario(const std::shared_ptr<SDLPP::Renderer> &renderer, std::function<void(std::shared_ptr<MarioBlock>&, bool)> addObject)
|
||||
: Mario(0, 0, renderer, addObject) {}
|
||||
void Mario::walkLeft() {
|
||||
if (!controllable) {
|
||||
if (!controllable || isCrouching()) {
|
||||
return;
|
||||
}
|
||||
if (on_ground)
|
||||
@@ -51,7 +51,7 @@ void Mario::walkLeft() {
|
||||
}
|
||||
|
||||
void Mario::walkRight() {
|
||||
if (!controllable) {
|
||||
if (!controllable || isCrouching()) {
|
||||
return;
|
||||
}
|
||||
if (on_ground)
|
||||
@@ -71,6 +71,8 @@ void Mario::setStanding() {
|
||||
}
|
||||
}
|
||||
|
||||
void setTeleportLevelMain(const std::string &level);
|
||||
|
||||
void Mario::handleVisitor(SDLPP::Visitor &visitor) {
|
||||
#ifndef EDITOR
|
||||
// TODO -
|
||||
@@ -130,6 +132,11 @@ void Mario::handleVisitor(SDLPP::Visitor &visitor) {
|
||||
if (m_visitor.hasMushroom()) {
|
||||
setBig();
|
||||
}
|
||||
if (m_visitor.hasTeleport() && isCrouching()) {
|
||||
std::cout << "TELEPORTING" << std::endl;
|
||||
setTeleportLevelMain(m_visitor.getTeleportLevel());
|
||||
std::cout << "Setted" << std::endl;
|
||||
}
|
||||
if (m_visitor.levelEnd() && controllable) {
|
||||
if (std::abs(getPos().getX() - m_visitor.getEndPos().getX()) <
|
||||
BLOCK_SIZE / 8) {
|
||||
@@ -140,6 +147,9 @@ void Mario::handleVisitor(SDLPP::Visitor &visitor) {
|
||||
if (m_visitor.isDead()) {
|
||||
handleDeath();
|
||||
}
|
||||
if (m_visitor.isInstantDead()) {
|
||||
setDeath();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void Mario::handleDeath() {
|
||||
@@ -152,7 +162,7 @@ void Mario::handleDeath() {
|
||||
}
|
||||
|
||||
void Mario::jump() {
|
||||
if (!controllable) {
|
||||
if (!controllable || isCrouching()) {
|
||||
return;
|
||||
}
|
||||
if (!on_ground)
|
||||
@@ -168,6 +178,19 @@ void Mario::jump() {
|
||||
pauseAnimation();
|
||||
}
|
||||
|
||||
void Mario::crouch() {
|
||||
if(walkingLeft()) {
|
||||
walkRight();
|
||||
} else if(walkingRight()) {
|
||||
walkLeft();
|
||||
}
|
||||
_crouching = true;
|
||||
}
|
||||
|
||||
void Mario::uncrouch() {
|
||||
_crouching = false;
|
||||
}
|
||||
|
||||
#ifndef EDITOR
|
||||
void Mario::fire() {
|
||||
if (!hasFire()) {
|
||||
|
||||
Reference in New Issue
Block a user