Mario: Fireball works

This commit is contained in:
2022-11-12 21:32:18 +01:00
parent 3cde73d1ed
commit 7bd652f4e9
19 changed files with 300 additions and 16 deletions
+8 -4
View File
@@ -2,6 +2,7 @@
#include "../sdlpp/sdlpp_rectrenderer.hpp"
#include <array>
#include <fstream>
#include "mario.hpp"
#include "sprites.hpp"
#include "blocks.hpp"
#include "objectids.hpp"
@@ -188,10 +189,13 @@ void loadMapV01(std::shared_ptr<SDLPP::Scene> &scene,
if (block.hasCharacter()) {
if (block.getCharacterId() == MARIO_ID) {
if (editor) {
scene->addObject(createMario(block.getCharacterType(),
renderer, i, j, true));
mario =
scene->getObject(scene->getObjects().size() - 1);
auto mario2 = createMario(block.getCharacterType(),
renderer, i, j, true);
scene->addObject(mario2);
#ifndef EDITOR
std::dynamic_pointer_cast<Mario>(mario2)->setAddObjFunc(std::dynamic_pointer_cast<Mario>(mario)->getAddObjFunc());
#endif
mario = mario2;
} else {
mario->setPos(i * BLOCK_SIZE,
1 - (16 - j) * BLOCK_SIZE);