Mario: add turtle enemy
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "../objectids.hpp"
|
||||
#include "../sprites.hpp"
|
||||
#include "../mario.hpp"
|
||||
#include "../blocks/turtleblock.hpp"
|
||||
|
||||
void GoombaVisitor::visit(const SDLPP::RenderObject &obj) {
|
||||
auto id = obj.getId();
|
||||
@@ -47,7 +48,15 @@ void GoombaVisitor::visit(const SDLPP::RenderObject &obj) {
|
||||
}
|
||||
break;
|
||||
case DEATH_ID:
|
||||
death = true;
|
||||
instant_death = true;
|
||||
break;
|
||||
case TURTLE_ID:
|
||||
{
|
||||
auto &turtle = dynamic_cast<const TurtleBlock &>(obj);
|
||||
if(turtle.isShell() && turtle.getMovement().getX() != 0) {
|
||||
death = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MARIO_ID:
|
||||
{
|
||||
|
||||
@@ -62,6 +62,7 @@ void MarioVisitor::visit(const SDLPP::RenderObject &obj) {
|
||||
_instant_death = true;
|
||||
break;
|
||||
case GOOMBA_ID:
|
||||
case TURTLE_ID:
|
||||
if (from != MARIO_FLOOR_DETECT && from != MARIO_ENEMY_DETECT) {
|
||||
_death = true;
|
||||
} else if (from == MARIO_FLOOR_DETECT || from == MARIO_ENEMY_DETECT) {
|
||||
|
||||
@@ -46,6 +46,7 @@ void ProjectileVisitor::visit(const SDLPP::RenderObject &obj) {
|
||||
}
|
||||
break;
|
||||
case GOOMBA_ID:
|
||||
case TURTLE_ID:
|
||||
death = true;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "mario_visitor.hpp"
|
||||
#include "mushroom_visitor.hpp"
|
||||
#include "goomba_visitor.hpp"
|
||||
#include "turtle_visitor.hpp"
|
||||
#include "projectile_visitor.hpp"
|
||||
#include "../mario.hpp"
|
||||
|
||||
@@ -29,6 +30,10 @@ getVisitor(const MarioBlock &block, SDLPP::Scene &scene,
|
||||
result = std::static_pointer_cast<SDLPP::Visitor>(
|
||||
std::make_shared<GoombaVisitor>(block.getPos()));
|
||||
break;
|
||||
case TURTLE_ID:
|
||||
result = std::static_pointer_cast<SDLPP::Visitor>(
|
||||
std::make_shared<TurtleVisitor>(block.getPos()));
|
||||
break;
|
||||
case FIREBALL_ID:
|
||||
result = std::static_pointer_cast<SDLPP::Visitor>(
|
||||
std::make_shared<ProjectileVisitor>());
|
||||
|
||||
Reference in New Issue
Block a user