Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NicknameGG committed Jun 29, 2024
2 parents c1105ac + 762b9c6 commit 3a21521
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 19 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
# Prerequisites
*.d

Expand Down Expand Up @@ -59,3 +60,8 @@ build-*/

# CLion
/cmake-build-*/
=======
.vs/
.github/
out/
>>>>>>> 762b9c624060a508ae804bdeb07ca98c62a4f52f
41 changes: 41 additions & 0 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
<<<<<<< HEAD
"geode": "3.0.0",
"gd": {
"win": "2.206",
Expand Down Expand Up @@ -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
}
39 changes: 20 additions & 19 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>("randomize-jumpscare");
bool randomizeOption = Mod::get()->getSettingValue<bool>("randomize-jumpscare");
double randomizeOptionChance = Mod::get()->getSettingValue<double>("randomize-jumpscare-chance");

// if randomize is turned on then there is certain percent chance of the jumpscare
float randPercent = (static_cast<float>(rand()) / static_cast<float>(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
Expand Down Expand Up @@ -47,18 +48,18 @@ class $modify(PlayerObject) {
void incrementJumps() {
// Check if randomizing is enabled
auto randomizeOption = Mod::get()->getSettingValue<bool>("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);

Expand All @@ -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
Expand Down

0 comments on commit 3a21521

Please sign in to comment.