Tried to implement lives. Failed. Everything crashes if I try to RemoveEntity in Update.
This commit is contained in:
@@ -9,13 +9,17 @@
|
||||
#include "Core/CTransform.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CLife.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/EBallFellOffStage.h"
|
||||
#include "Physics/CBoxShape.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <intrin.h>
|
||||
@@ -47,6 +51,7 @@ public:
|
||||
void Initialize() override;
|
||||
|
||||
void CreateBasicLevel(int, int, glm::vec2, int);
|
||||
void CreateLife(int);
|
||||
void SaveLevel(int, int, glm::vec2, int); // Shouldn't be here, but I'm experimenting.
|
||||
void LoadLevel(char[20]);
|
||||
void CreateBrick(int, int, glm::vec2, int, int);
|
||||
@@ -56,12 +61,17 @@ public:
|
||||
|
||||
void EndLevel();
|
||||
|
||||
void Update(double dt);
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
int lives = 3;
|
||||
int pastLives = 3;
|
||||
|
||||
private:
|
||||
dd::EventRelay<LevelSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<LevelSystem, dd::Events::BallFellOffStage> m_EBall;
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool BallFellOffStage(const dd::Events::BallFellOffStage &event);
|
||||
|
||||
bool m_Initialized = false;
|
||||
|
||||
@@ -70,6 +80,8 @@ private:
|
||||
int tLines = 8;
|
||||
glm::vec2 tSpaceBetweenBricks = glm::vec2(2, 0.5);
|
||||
int tSpaceToEdge = 0;
|
||||
|
||||
EntityID entityToRemove = NULL;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user