Mario: add turtle enemy
This commit is contained in:
parent
fd96a1c2cc
commit
f0182cf4d4
@ -73,12 +73,14 @@ target_sources(mario
|
||||
PRIVATE visitors/mario_visitor.cpp
|
||||
PRIVATE visitors/mushroom_visitor.cpp
|
||||
PRIVATE visitors/goomba_visitor.cpp
|
||||
PRIVATE visitors/turtle_visitor.cpp
|
||||
PRIVATE visitors/bounce_visitor.cpp
|
||||
PRIVATE visitors/visitor_generator.cpp
|
||||
PRIVATE visitors/projectile_visitor.cpp
|
||||
PRIVATE blocks/coinblock.cpp
|
||||
PRIVATE blocks/mushroomblock.cpp
|
||||
PRIVATE blocks/goombablock.cpp
|
||||
PRIVATE blocks/turtleblock.cpp
|
||||
PRIVATE blocks/fireball.cpp
|
||||
PRIVATE scenes/load_scene.cpp
|
||||
PRIVATE scenes/game_main_menu.cpp
|
||||
@ -91,6 +93,7 @@ target_sources(editor
|
||||
PRIVATE ${CommonFiles}
|
||||
PRIVATE blocks/coineditorblock.cpp
|
||||
PRIVATE blocks/goombablock.cpp
|
||||
PRIVATE blocks/turtleblock.cpp
|
||||
PRIVATE editor.cpp
|
||||
PRIVATE edit_box.cpp
|
||||
PRIVATE tool_box.cpp
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "blocks/coinblock.hpp"
|
||||
#include "blocks/mushroomblock.hpp"
|
||||
#include "blocks/goombablock.hpp"
|
||||
#include "blocks/turtleblock.hpp"
|
||||
#include "mario.hpp"
|
||||
|
||||
#define CAN_BE_DESTROYED_FLAG 0x0000000000000001
|
||||
@ -322,6 +323,7 @@ const std::vector<uint64_t> possibleMods = {
|
||||
const std::vector<uint64_t> possibleCharacters = {
|
||||
MARIO_ID,
|
||||
GOOMBA_ID,
|
||||
TURTLE_ID,
|
||||
};
|
||||
|
||||
const std::vector<LandType::Value> possibleLands = {
|
||||
@ -573,6 +575,10 @@ createBlockById(uint64_t id, int x, int y,
|
||||
result = std::static_pointer_cast<MarioBlock>(
|
||||
std::make_shared<GoombaBlock>(x, y, renderer));
|
||||
break;
|
||||
case TURTLE_ID:
|
||||
result = std::static_pointer_cast<MarioBlock>(
|
||||
std::make_shared<TurtleBlock>(x, y, renderer));
|
||||
break;
|
||||
#ifdef EDITOR
|
||||
case DESTRUCTIBLE_MODIFIER_ID:
|
||||
result = std::static_pointer_cast<MarioBlock>(
|
||||
|
@ -371,6 +371,7 @@ SceneStruct mainGameScene(const std::string &level_path) {
|
||||
moving_objects.push_back(mario);
|
||||
std::unordered_set<int> moving_object_ids = {
|
||||
GOOMBA_ID,
|
||||
TURTLE_ID,
|
||||
};
|
||||
for (auto &obj : scene->getObjects(moving_object_ids)) {
|
||||
moving_objects.push_back(std::dynamic_pointer_cast<MarioBlock>(obj));
|
||||
|
@ -74,6 +74,7 @@
|
||||
// character IDs
|
||||
#define MARIO_ID 0x0F
|
||||
#define GOOMBA_ID 0x0E
|
||||
#define TURTLE_ID 0x0D
|
||||
|
||||
#define DEATH_ID 0x1001
|
||||
#define STOP_MOVEMENT 0x2000
|
||||
|
@ -111,3 +111,8 @@ const SDLPP::Vec2D<uint64_t> BOWSER_SHIFT = { 0, 173 };
|
||||
const std::vector<SDL_Rect> GOOMBA_WALK_ANIM = { { 1, 28, 16, 16 },
|
||||
{ 18, 28, 16, 16 } };
|
||||
const SDL_Rect GOOMBA_DEATH_SRC = { 39, 28, 16, 16 };
|
||||
const std::vector<SDL_Rect> TURTLE_WALK_ANIM = { { 60, 12, 16, 32 },
|
||||
{ 77, 12, 16, 32 } };
|
||||
const std::vector<SDL_Rect> TURTLE_SHELL_ANIM = { { 136, 28, 16, 16},
|
||||
{ 136, 28, 16, 16},
|
||||
{ 153, 28, 16, 16} };
|
||||
|
@ -107,6 +107,8 @@ extern const SDL_Rect MOD_TELEPORT_SRC;
|
||||
//------------------ ENEMIES -------------------------
|
||||
extern const SDL_Rect GOOMBA_DEATH_SRC;
|
||||
extern const std::vector<SDL_Rect> GOOMBA_WALK_ANIM;
|
||||
extern const std::vector<SDL_Rect> TURTLE_WALK_ANIM;
|
||||
extern const std::vector<SDL_Rect> TURTLE_SHELL_ANIM;
|
||||
|
||||
extern const SDLPP::Vec2D<uint64_t> OVERWORLD_SHIFT;
|
||||
extern const SDLPP::Vec2D<uint64_t> UNDERWORLD_SHIFT;
|
||||
|
@ -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:
|
||||
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>());
|
||||
|
Loading…
Reference in New Issue
Block a user