diff --git a/.gitignore b/.gitignore index d4ce5a1..830fab0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +<<<<<<< HEAD # Prerequisites *.d @@ -59,3 +60,8 @@ build-*/ # CLion /cmake-build-*/ +======= +.vs/ +.github/ +out/ +>>>>>>> 762b9c624060a508ae804bdeb07ca98c62a4f52f diff --git a/mod.json b/mod.json index 22ef993..b0289c7 100644 --- a/mod.json +++ b/mod.json @@ -1,4 +1,5 @@ { +<<<<<<< HEAD "geode": "3.0.0", "gd": { "win": "2.206", @@ -29,4 +30,44 @@ "default": false } } +======= + "geode": "2.0.0-beta.24", + "version": "v1.3.1", + "id": "n.robtop-jumpscare", + "name": "Robtop Jumpscare", + "developer": "n", + "gd": { + "android": "2.205", + "win": "2.204", + "ios": "2.205" + }, + "repository": "https://github.com/NicknameGG/robtop-jumpscare", + "description": "Jumpscare yourself everytime you jump!", + "resources": { + "files": [ + "resources/*.mp3", + "resources/*.png" + ] + }, + "settings": { + "randomize-jumpscare": { + "name": "Randomize Jumpscare", + "description": "Jumpscares happen with a certain chance instead of a 100% chance when enabled.", + "type": "bool", + "default": false + }, + "randomize-jumpscare-chance": { + "name": "Randomize Jumpscare Chance", + "description": "The % chance that Robert Topala will jumpscare you. Enable Randomize Jumpscare for this to take effect!", + "type": "float", + "default": 1, + "min": 0, + "max": 100, + "control": { + "slider": true, + "slider-step": 0.05 + } + } + } +>>>>>>> 762b9c624060a508ae804bdeb07ca98c62a4f52f } diff --git a/src/main.cpp b/src/main.cpp index bfed423..e616c37 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,20 +3,21 @@ using namespace geode::prelude; -CCSprite *RobertTopala = nullptr; +CCSprite* RobertTopala = nullptr; bool isHolding = false; class $modify(PlayerObject) { - void jumpscare() { // Check if randomizing is enabled - auto randomizeOption = Mod::get()->getSettingValue("randomize-jumpscare"); + bool randomizeOption = Mod::get()->getSettingValue("randomize-jumpscare"); + double randomizeOptionChance = Mod::get()->getSettingValue("randomize-jumpscare-chance"); + + // if randomize is turned on then there is certain percent chance of the jumpscare + float randPercent = (static_cast(rand()) / static_cast(RAND_MAX)) * 100; - // if randomize is turned on then there is 1 in 100 chance of the jumpscare - if (randomizeOption && (rand() % 100 != 0)) { + if (randomizeOption && (randPercent > randomizeOptionChance)) return; - } - + FMODAudioEngine::sharedEngine()->playEffect("vine-boom.mp3"_spr); // If action is running stop it @@ -47,18 +48,18 @@ class $modify(PlayerObject) { void incrementJumps() { // Check if randomizing is enabled auto randomizeOption = Mod::get()->getSettingValue("randomize-jumpscare"); - - // increment jump jumpscares only happen if randomization is disabled. + + // increment jump jumpscares only happen if randomization is disabled. if (randomizeOption == false) { - // Check if robert exists and if the user is holding jump (Works only for the cube) - const auto runningScene = CCDirector::get()->getRunningScene(); - if (runningScene->getChildByID("robert-topala") && isHolding) { - this->jumpscare(); - } + // Check if robert exists and if the user is holding jump (Works only for the cube) + const auto runningScene = CCDirector::get()->getRunningScene(); + if (runningScene->getChildByID("robert-topala") && isHolding) { + this->jumpscare(); + } } } - void pushButton(PlayerButton p0) { + TodoReturn pushButton(PlayerButton p0) { PlayerObject::pushButton(p0); @@ -78,15 +79,15 @@ class $modify(PlayerObject) { RobertTopala = CCSprite::create("RobertTopala.png"_spr); RobertTopala->setID("robert-topala"); CCSize winSize = CCDirector::get()->getWinSize(); - + float scaleRatio = (winSize.height / RobertTopala->getContentSize().height); - + // Scale robert to fit screen RobertTopala->setScaleX(scaleRatio); RobertTopala->setScaleY(scaleRatio); - + // Center the robert - RobertTopala->setPosition({winSize.width / 2, winSize.height / 2}); + RobertTopala->setPosition({ winSize.width / 2, winSize.height / 2 }); runningScene->addChild(RobertTopala, 100); // Set robert opacity to 0