Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/maps/MapTemplate.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@
<object id="1809" name="MemoryFragment" type="MemoryFragment" x="3784" y="2637" width="80" height="60">
<properties>
<property name="video_path" value="assets/video/Anchor_1.mp4"/>
<property name="fragment_id" type="int" value="0"/>
</properties>
</object>
<object id="1811" name="HidingRock" type="HidingRock" x="6286.79" y="8529.7" width="64" height="64">
Expand Down
2 changes: 2 additions & 0 deletions include/MemoryFragment.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class MemoryFragment : public Entity
void SetVideoPath(const std::string& path) { videoPath_ = path; }
void SetCollectRange(float r) { collectRange_ = r; }
void SetScale(float s) { scale_ = s; }
void SetFragmentId(int id) { fragmentId_ = id; }

private:
void Draw();
Expand All @@ -30,6 +31,7 @@ class MemoryFragment : public Entity
std::string videoPath_ = "";
float collectRange_ = 100.0f;
float scale_ = 0.5f; // 256 * 0.5 = 128px on screen
int fragmentId_ = -1;

// SS_Fragment_Collectible.png: 1536x1024 → 6 cols × 4 rows of 256×256 frames
static constexpr int COLS = 6;
Expand Down
10 changes: 10 additions & 0 deletions include/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ class Player : public Entity
bool IsBearMode() const { return isBearMode_; }
bool IsBearModeActive() const { return isBearMode_ || isBearTransforming_ || isThrowingBear_ || isKidSleeping_; }

// Memory Fragments
bool HasMemoryFragment(int index) const { return index >= 0 && index < 3 ? hasMemoryFragment_[index] : false; }
void SetMemoryFragment(int index, bool v) { if (index >= 0 && index < 3) hasMemoryFragment_[index] = v; }
bool IsMemoryFragmentNew(int index) const { return index >= 0 && index < 3 ? isMemoryFragmentNew_[index] : false; }
void SetMemoryFragmentNew(int index, bool v) { if (index >= 0 && index < 3) isMemoryFragmentNew_[index] = v; }

private:

void GetPhysicsValues();
Expand Down Expand Up @@ -194,6 +200,10 @@ class Player : public Entity
bool hasStuffedAnimal_ = false;
EquippedItem equippedItem_ = EquippedItem::NONE;

// Memory fragments
bool hasMemoryFragment_[3] = { false, false, false };
bool isMemoryFragmentNew_[3] = { false, false, false };

// Push rock state
bool isPushing_ = false;
int pushContactCount_ = 0; // track overlapping push_rock contacts
Expand Down
1 change: 1 addition & 0 deletions include/SaveSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct GameState
bool playerHasBlanket = false;
bool playerHasSlingshot = false;
bool playerHasStuffedAnimal = false;
bool hasMemoryFragment[3] = { false, false, false };

// Checkpoint state
std::string activeCheckpointId;
Expand Down
10 changes: 10 additions & 0 deletions include/Scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ class Scene : public Module
// ── Loading Screen ────────────────────────────────────────────────────────
void LoadLoading();
void UnloadLoading();

// Persistent state across map loads
bool savedHasBlanket_ = false;
bool savedHasSlingshot_ = false;
bool savedHasStuffedAnimal_ = false;
bool savedFragments_[3] = {false, false, false};
void UpdateLoading(float dt);
void DrawLoading();
float loadingTimer_ = 0.0f;
Expand Down Expand Up @@ -508,14 +514,17 @@ class Scene : public Module

// ── Memories UI ───────────────────────────────────────────────────────────
SDL_Texture* texMemoria1Base_ = nullptr;
SDL_Texture* texMemoria1Collected_ = nullptr;
SDL_Texture* texMemoria1N1_ = nullptr;
SDL_Texture* texMemoria1N2_ = nullptr;

SDL_Texture* texMemoria2Base_ = nullptr;
SDL_Texture* texMemoria2Collected_ = nullptr;
SDL_Texture* texMemoria2N1_ = nullptr;
SDL_Texture* texMemoria2N2_ = nullptr;

SDL_Texture* texMemoria3Base_ = nullptr;
SDL_Texture* texMemoria3Collected_ = nullptr;
SDL_Texture* texMemoria3N1_ = nullptr;
SDL_Texture* texMemoria3N2_ = nullptr;
SDL_Texture* texMemoria3N3_ = nullptr;
Expand All @@ -532,6 +541,7 @@ class Scene : public Module

// Hover fade states
float memoryHoverTimers_[3] = { 0.0f, 0.0f, 0.0f };
float memoryNewAnimTimer_[3] = { 0.0f, 0.0f, 0.0f };

// Fullscreen state
bool showMemoryViewer_ = false;
Expand Down
2 changes: 2 additions & 0 deletions src/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,8 @@ void Map::LoadEntities(std::shared_ptr<Player> &player, bool portalTransition,
frag->SetCollectRange(prop.attribute("value").as_float(100.0f));
else if (pname == "scale")
frag->SetScale(prop.attribute("value").as_float(0.5f));
else if (pname == "fragment_id")
frag->SetFragmentId(prop.attribute("value").as_int(-1));
}
frag->Start();
LOG("MemoryFragment spawned at (%.0f, %.0f)", frag->position.getX(),
Expand Down
11 changes: 11 additions & 0 deletions src/MemoryFragment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Cinematics.h"
#include "Log.h"
#include <cmath>
#include "Player.h"

MemoryFragment::MemoryFragment() : Entity(EntityType::MEMORY_FRAGMENT)
{
Expand Down Expand Up @@ -53,6 +54,16 @@ bool MemoryFragment::Update(float dt)
{
fading_ = false;
collected_ = true;

// Set fragment in Player
if (fragmentId_ >= 0 && fragmentId_ < 3) {
auto& scn = *Engine::GetInstance().scene;
if (scn.player) {
scn.player->SetMemoryFragment(fragmentId_, true);
scn.player->SetMemoryFragmentNew(fragmentId_, true);
}
}

if (!videoPath_.empty())
{
Engine::GetInstance().cinematics->PlayVideo(videoPath_.c_str());
Expand Down
15 changes: 15 additions & 0 deletions src/SaveSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ void SaveSystem::CollectPlayerState()
gameState_.playerHasBlanket = scene->player ? scene->player->HasBlanket() : false;
gameState_.playerHasSlingshot = scene->player ? scene->player->HasSlingshot() : false;
gameState_.playerHasStuffedAnimal = scene->player ? scene->player->HasStuffedAnimal() : false;
for (int i = 0; i < 3; ++i) {
gameState_.hasMemoryFragment[i] = scene->player ? scene->player->HasMemoryFragment(i) : false;
}

if (pendingCheckpointPositionOverride_)
{
Expand Down Expand Up @@ -349,6 +352,10 @@ void SaveSystem::ApplyPlayerState()
scene->player->SetHasBlanket(gameState_.playerHasBlanket);
scene->player->SetHasSlingshot(gameState_.playerHasSlingshot);
scene->player->SetHasStuffedAnimal(gameState_.playerHasStuffedAnimal);
for (int i = 0; i < 3; ++i) {
scene->player->SetMemoryFragment(i, gameState_.hasMemoryFragment[i]);
scene->player->SetMemoryFragmentNew(i, false);
}
scene->player->Revive();
scene->ResetHealthUI(scene->player->health);
}
Expand Down Expand Up @@ -503,6 +510,10 @@ bool SaveSystem::WriteXML(const std::string& filename)
stateNode.append_attribute("hasBlanket") = gameState_.playerHasBlanket;
stateNode.append_attribute("hasSlingshot") = gameState_.playerHasSlingshot;
stateNode.append_attribute("hasStuffedAnimal") = gameState_.playerHasStuffedAnimal;
for (int i = 0; i < 3; ++i) {
std::string attrName = "hasMemoryFragment" + std::to_string(i);
stateNode.append_attribute(attrName.c_str()) = gameState_.hasMemoryFragment[i];
}

// Entities node (placeholder for future)
pugi::xml_node entitiesNode = root.append_child("entities");
Expand Down Expand Up @@ -577,6 +588,10 @@ bool SaveSystem::ReadXML(const std::string& filename)
gameState_.playerHasBlanket = stateNode.attribute("hasBlanket").as_bool(false);
gameState_.playerHasSlingshot = stateNode.attribute("hasSlingshot").as_bool(false);
gameState_.playerHasStuffedAnimal = stateNode.attribute("hasStuffedAnimal").as_bool(false);
for (int i = 0; i < 3; ++i) {
std::string attrName = "hasMemoryFragment" + std::to_string(i);
gameState_.hasMemoryFragment[i] = stateNode.attribute(attrName.c_str()).as_bool(false);
}
}
}

Expand Down
Loading
Loading