diff --git a/assets/visual/plr/plr_jumpdown_sheet/plr_jumpdown1.png b/assets/visual/plr/plr_jumpdown_sheet/plr_jumpdown1.png new file mode 100644 index 0000000..1a9b43e Binary files /dev/null and b/assets/visual/plr/plr_jumpdown_sheet/plr_jumpdown1.png differ diff --git a/assets/visual/plr/plr_jumpdown_sheet/plr_jumpdown2.png b/assets/visual/plr/plr_jumpdown_sheet/plr_jumpdown2.png new file mode 100644 index 0000000..8116b6e Binary files /dev/null and b/assets/visual/plr/plr_jumpdown_sheet/plr_jumpdown2.png differ diff --git a/assets/visual/plr/plr_jumpdown_sheet/plr_jumpdown3.png b/assets/visual/plr/plr_jumpdown_sheet/plr_jumpdown3.png new file mode 100644 index 0000000..af5db89 Binary files /dev/null and b/assets/visual/plr/plr_jumpdown_sheet/plr_jumpdown3.png differ diff --git a/assets/visual/plr/plr_jumpup_sheet/plr_jumpup1.png b/assets/visual/plr/plr_jumpup_sheet/plr_jumpup1.png new file mode 100644 index 0000000..c248d33 Binary files /dev/null and b/assets/visual/plr/plr_jumpup_sheet/plr_jumpup1.png differ diff --git a/assets/visual/plr/plr_jumpup_sheet/plr_jumpup2.png b/assets/visual/plr/plr_jumpup_sheet/plr_jumpup2.png new file mode 100644 index 0000000..337f4ef Binary files /dev/null and b/assets/visual/plr/plr_jumpup_sheet/plr_jumpup2.png differ diff --git a/assets/visual/plr/plr_jumpup_sheet/plr_jumpup3.png b/assets/visual/plr/plr_jumpup_sheet/plr_jumpup3.png new file mode 100644 index 0000000..a186982 Binary files /dev/null and b/assets/visual/plr/plr_jumpup_sheet/plr_jumpup3.png differ diff --git a/assets/visual/plr/plr_run_sheet/plr_run1.png b/assets/visual/plr/plr_run_sheet/plr_run1.png new file mode 100644 index 0000000..126cc70 Binary files /dev/null and b/assets/visual/plr/plr_run_sheet/plr_run1.png differ diff --git a/assets/visual/plr/plr_run_sheet/plr_run2.png b/assets/visual/plr/plr_run_sheet/plr_run2.png new file mode 100644 index 0000000..fdb4a85 Binary files /dev/null and b/assets/visual/plr/plr_run_sheet/plr_run2.png differ diff --git a/assets/visual/plr/plr_run_sheet/plr_run3.png b/assets/visual/plr/plr_run_sheet/plr_run3.png new file mode 100644 index 0000000..25c8f09 Binary files /dev/null and b/assets/visual/plr/plr_run_sheet/plr_run3.png differ diff --git a/assets/visual/plr/plr_run_sheet/plr_run4.png b/assets/visual/plr/plr_run_sheet/plr_run4.png new file mode 100644 index 0000000..45adec6 Binary files /dev/null and b/assets/visual/plr/plr_run_sheet/plr_run4.png differ diff --git a/assets/visual/plr/plr_stand_sheet/plr_stand1.png b/assets/visual/plr/plr_stand_sheet/plr_stand1.png new file mode 100644 index 0000000..4dce027 Binary files /dev/null and b/assets/visual/plr/plr_stand_sheet/plr_stand1.png differ diff --git a/assets/visual/plr/plr_stand_sheet/plr_stand10.png b/assets/visual/plr/plr_stand_sheet/plr_stand10.png new file mode 100644 index 0000000..70fc1a3 Binary files /dev/null and b/assets/visual/plr/plr_stand_sheet/plr_stand10.png differ diff --git a/assets/visual/plr/plr_stand_sheet/plr_stand2.png b/assets/visual/plr/plr_stand_sheet/plr_stand2.png new file mode 100644 index 0000000..95f3938 Binary files /dev/null and b/assets/visual/plr/plr_stand_sheet/plr_stand2.png differ diff --git a/assets/visual/plr/plr_stand_sheet/plr_stand3.png b/assets/visual/plr/plr_stand_sheet/plr_stand3.png new file mode 100644 index 0000000..f50e3d8 Binary files /dev/null and b/assets/visual/plr/plr_stand_sheet/plr_stand3.png differ diff --git a/assets/visual/plr/plr_stand_sheet/plr_stand4.png b/assets/visual/plr/plr_stand_sheet/plr_stand4.png new file mode 100644 index 0000000..86b3cf3 Binary files /dev/null and b/assets/visual/plr/plr_stand_sheet/plr_stand4.png differ diff --git a/assets/visual/plr/plr_stand_sheet/plr_stand5.png b/assets/visual/plr/plr_stand_sheet/plr_stand5.png new file mode 100644 index 0000000..d6be538 Binary files /dev/null and b/assets/visual/plr/plr_stand_sheet/plr_stand5.png differ diff --git a/assets/visual/plr/plr_stand_sheet/plr_stand6.png b/assets/visual/plr/plr_stand_sheet/plr_stand6.png new file mode 100644 index 0000000..fbdc695 Binary files /dev/null and b/assets/visual/plr/plr_stand_sheet/plr_stand6.png differ diff --git a/assets/visual/plr/plr_stand_sheet/plr_stand7.png b/assets/visual/plr/plr_stand_sheet/plr_stand7.png new file mode 100644 index 0000000..fbdc695 Binary files /dev/null and b/assets/visual/plr/plr_stand_sheet/plr_stand7.png differ diff --git a/assets/visual/plr/plr_stand_sheet/plr_stand8.png b/assets/visual/plr/plr_stand_sheet/plr_stand8.png new file mode 100644 index 0000000..4371bbe Binary files /dev/null and b/assets/visual/plr/plr_stand_sheet/plr_stand8.png differ diff --git a/assets/visual/plr/plr_stand_sheet/plr_stand9.png b/assets/visual/plr/plr_stand_sheet/plr_stand9.png new file mode 100644 index 0000000..70fc1a3 Binary files /dev/null and b/assets/visual/plr/plr_stand_sheet/plr_stand9.png differ diff --git a/mod.json b/mod.json index ce4f386..df9ab61 100644 --- a/mod.json +++ b/mod.json @@ -33,6 +33,18 @@ "typo_run_sheet": [ "assets/**/upscale/typo_run_only*" ], + "plr_run_sheet": [ + "assets/**/plr_run_sheet/plr_run*" + ], + "plr_stand_sheet": [ + "assets/**/plr_stand_sheet/plr_stand*" + ], + "plr_jumpup_sheet": [ + "assets/**/plr_jumpup_sheet/plr_jumpup*" + ], + "plr_jumpdown_sheet": [ + "assets/**/plr_jumpdown_sheet/plr_jumpdown*" + ], "tp_sheet": [ "assets/_tp/frames/**/*.png" ] diff --git a/src/main.cpp b/src/main.cpp index 8445651..632a64a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,8 +7,6 @@ using namespace geode::prelude; CCFileUtils::sharedFileUtils()->addPriorityPath( (Mod::get()->getTempDir() / "resources" / "user95401.run_mod").string().data() ); - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("typo_run_sheet.plist"_spr, "typo_run_sheet.png"_spr); - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("tp_sheet.plist"_spr, "tp_sheet.png"_spr); } //tools @@ -261,7 +259,7 @@ class $modify(CCSpriteModExt, CCSprite) { #endif // 1 -//layers +//layers n objects #if 1 #include @@ -370,4 +368,127 @@ class $modify(CreatorLayerExt, CreatorLayer) { } }; +#include +class $modify(PlayerObjectExt, PlayerObject) { + struct Fields { + float m_lastPlatformerXVelocity = 0.1; + }; + bool isCube() { + auto player = this; + if (!player->m_isShip && !player->m_isBall && !player->m_isBird && !player->m_isDart && !player->m_isRobot && !player->m_isSpider && !player->m_isSwing) + return true; + return false; + } + void mySch(float) { + m_fields->m_lastPlatformerXVelocity = + fabs(this->m_platformerXVelocity) > 0.001f ? + this->m_platformerXVelocity : m_fields->m_lastPlatformerXVelocity; + auto mainLayer = this->getChildByIDRecursive("main-layer"); + auto plr_run = dynamic_cast(this->getChildByIDRecursive("plr_run")); + auto plr_jumpup = dynamic_cast(this->getChildByIDRecursive("plr_jumpup")); + auto plr_jumpdown = dynamic_cast(this->getChildByIDRecursive("plr_jumpdown")); + auto plr_stand = dynamic_cast(this->getChildByIDRecursive("plr_stand")); + if (plr_run and plr_jumpup and mainLayer) { + auto showplr = (this->isCube() or this->m_isRobot) and not this->m_isDead; + auto jmpup = not this->m_isOnGround and fabs(m_yVelocity) > 0.1f; + auto stand = this->m_platformerXVelocity == 0.f and this->m_isPlatformer; + auto goesLeft = m_fields->m_lastPlatformerXVelocity < 0.f and this->m_isPlatformer; + mainLayer->setVisible(not showplr); + ;;;;;; plr_run->setVisible(showplr and !jmpup and !stand); + ;;; plr_jumpup->setVisible(showplr and jmpup and m_yVelocity > 0.1f); + ; plr_jumpdown->setVisible(showplr and jmpup and m_yVelocity < -0.1f); + ;;;; plr_stand->setVisible(showplr and !jmpup and stand); + plr_run->setFlipX(goesLeft); + plr_jumpup->setFlipX(goesLeft); + plr_jumpdown->setFlipX(goesLeft); + plr_stand->setFlipX(goesLeft); + plr_run->setFlipY(this->m_isUpsideDown); + plr_jumpup->setFlipY(this->m_isUpsideDown); + plr_jumpdown->setFlipY(this->m_isUpsideDown); + plr_stand->setFlipY(this->m_isUpsideDown); + plr_run->setAnchorPoint(this->m_isUpsideDown ? CCPoint(0.5f, 0.66f) : CCPoint(0.5f, 0.43f)); + plr_jumpup->setAnchorPoint(this->m_isUpsideDown ? CCPoint(0.5f, 0.66f) : CCPoint(0.5f, 0.43f)); + plr_jumpdown->setAnchorPoint(this->m_isUpsideDown ? CCPoint(0.5f, 0.66f) : CCPoint(0.5f, 0.43f)); + plr_stand->setAnchorPoint(this->m_isUpsideDown ? CCPoint(0.5f, 0.66f) : CCPoint(0.5f, 0.43f)); + } + this->m_robotBurstParticles->setVisible(0); + this->m_iconSprite->setScale(1.f); + log::debug("{}->{}() m_yVelocity={}", this, __FUNCTION__, m_yVelocity); + } + void updateRotation(float p0) { + if (this->isCube()) { + this->m_isRobot = 1; + if (this->m_isOnGround) PlayerObject::updateRotation(p0); + this->m_isRobot = 0; + } + else PlayerObject::updateRotation(p0); + } + bool init(int p0, int p1, GJBaseGameLayer * p2, cocos2d::CCLayer * p3, bool p4) { + if (!PlayerObject::init( p0, p1, p2, p3, p4)) return false; + this->schedule(schedule_selector(PlayerObjectExt::mySch)); + auto plr_run = CCSprite::createWithSpriteFrameName("plr_run1.png"_spr); + if (plr_run) { + plr_run->setScale(1.4f); + plr_run->setID("plr_run"); + plr_run->setVisible(0); + this->addChild(plr_run); + //frames + auto frames = new CCArray; + for (int i = 1; i <= 4; i++) + frames->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(fmt::format("plr_run{}.png"_spr, i).data())); + //animate + plr_run->runAction(CCRepeatForever::create(CCAnimate::create(CCAnimation::createWithSpriteFrames(frames, 0.04f)))); + }; + auto plr_stand = CCSprite::createWithSpriteFrameName("plr_stand1.png"_spr); + if (plr_stand) { + plr_stand->setScale(1.4f); + plr_stand->setID("plr_stand"); + plr_stand->setVisible(0); + this->addChild(plr_stand); + //frames + auto frames = new CCArray; + for (int i = 1; i <= 10; i++) + frames->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(fmt::format("plr_stand{}.png"_spr, i).data())); + //animate + plr_stand->runAction(CCRepeatForever::create(CCAnimate::create(CCAnimation::createWithSpriteFrames(frames, 0.06f)))); + this->m_iconSprite->runAction(CCRepeatForever::create(CCAnimate::create(CCAnimation::createWithSpriteFrames(frames, 0.06f)))); + }; + auto plr_jumpup = CCSprite::createWithSpriteFrameName("plr_jumpup1.png"_spr); + if (plr_jumpup) { + plr_jumpup->setScale(1.4f); + plr_jumpup->setID("plr_jumpup"); + plr_jumpup->setVisible(0); + this->addChild(plr_jumpup); + //frames + auto frames = new CCArray; + for (int i = 1; i <= 3; i++) + frames->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(fmt::format("plr_jumpup{}.png"_spr, i).data())); + //animate + plr_jumpup->runAction(CCRepeatForever::create(CCAnimate::create(CCAnimation::createWithSpriteFrames(frames, 0.06f)))); + }; + auto plr_jumpdown = CCSprite::createWithSpriteFrameName("plr_jumpdown1.png"_spr); + if (plr_jumpdown) { + plr_jumpdown->setScale(1.4f); + plr_jumpdown->setID("plr_jumpdown"); + plr_jumpdown->setVisible(0); + this->addChild(plr_jumpdown); + //frames + auto frames = new CCArray; + for (int i = 1; i <= 3; i++) + frames->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(fmt::format("plr_jumpdown{}.png"_spr, i).data())); + //animate + plr_jumpdown->runAction(CCRepeatForever::create(CCAnimate::create(CCAnimation::createWithSpriteFrames(frames, 0.06f)))); + }; + updatePlayerFrame(1); + return true; + } + void updatePlayerFrame(int p0) { + PlayerObject::updatePlayerFrame(p0); + this->m_iconSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("plr_stand1.png"_spr)); + this->m_iconSpriteSecondary->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("emptyGlow.png")); + this->m_iconSpriteWhitener->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("emptyGlow.png")); + this->m_iconGlow->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("emptyGlow.png")); + } +}; + #endif // 1