From f29d79f0f4cb4bf9c22badca21294d1414c1d6ad Mon Sep 17 00:00:00 2001 From: Harley White Date: Mon, 17 May 2021 21:51:36 -0400 Subject: [PATCH] Added makeShinies --- changelog.md | 7 +++ docs/particles.md | 2 +- js/Demo/demoMod.js | 2 +- js/game.js | 4 +- js/technical/displays.js | 3 ++ js/technical/particleSystem.js | 86 ++++++++++++++++++++++++---------- js/technical/temp.js | 2 + 7 files changed, 76 insertions(+), 30 deletions(-) diff --git a/changelog.md b/changelog.md index f5e0231..5393bb1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # The Modding Tree changelog: +# v2.5.8 - 5/15/21 +- Added makeShinies, which creates a stationary particle in a random spot. +- Bars will visually update more quickly. +- Fixed a major particle-related issue. +- Fixed autoUpgrade. +- Fixed a minor visal issue with tree nodes. + # v2.5.7 - 5/15/21 - Added a particle system! Not only can it be used for visual effects, but particles can interact with the mouse. They could be used to create golden cookies or collectables, for example. - Added marked feature to buyables, clickables, and challenges. By default, stars multi-completion challenges when maxed. diff --git a/docs/particles.md b/docs/particles.md index a8bae80..c6f2b20 100644 --- a/docs/particles.md +++ b/docs/particles.md @@ -2,7 +2,7 @@ Particles are free-floating elements that can move and have many different behaviors. They can also interact with the mouse. -To make particles, use `makeParticles(particle, amount)`. `particle` is a particle-defining object, with features as explained below. There are also a few other useful things listed at the end. +To make particles, use `makeParticles(particle, amount)`. `particle` is a particle-defining object, with features as explained below. There is also `makeShinies`, which uses different defaults and creates stationary particles at a random location. There are also a few other useful things listed at the end. ```js diff --git a/js/Demo/demoMod.js b/js/Demo/demoMod.js index 42fdf37..b62c9e1 100644 --- a/js/Demo/demoMod.js +++ b/js/Demo/demoMod.js @@ -11,7 +11,7 @@ let modInfo = { // Set your version in num and name let VERSION = { - num: "2.5.7", + num: "2.5.8", name: "Dreams Really Do Come True", } diff --git a/js/game.js b/js/game.js index 962810a..e1aa25e 100644 --- a/js/game.js +++ b/js/game.js @@ -5,7 +5,7 @@ var scrolled = false; // Don't change this const TMT_VERSION = { - tmtNum: "2.5.7", + tmtNum: "2.5.8", tmtName: "Dreams Really Do Come True" } @@ -370,7 +370,7 @@ function gameLoop(diff) { let layer = TREE_LAYERS[x][item] if (tmp[layer].autoPrestige && tmp[layer].canReset) doReset(layer); if (layers[layer].automate) layers[layer].automate(); - if (layers[layer].autoUpgrade) autobuyUpgrades(layer) + if (tmp[layer].autoUpgrade) autobuyUpgrades(layer) } } diff --git a/js/technical/displays.js b/js/technical/displays.js index ce228c0..d85ef72 100644 --- a/js/technical/displays.js +++ b/js/technical/displays.js @@ -52,9 +52,12 @@ function achievementStyle(layer, id){ function updateWidth() { var screenWidth = window.innerWidth + var splitScreen = screenWidth >= 1024 if (player.forceOneTab) splitScreen = false tmp.other.screenWidth = screenWidth + tmp.other.screenHeight = window.innerHeight + tmp.other.splitScreen = splitScreen tmp.other.lastPoints = player.points } diff --git a/js/technical/particleSystem.js b/js/technical/particleSystem.js index 3c431c5..8aaf079 100644 --- a/js/technical/particleSystem.js +++ b/js/technical/particleSystem.js @@ -3,9 +3,9 @@ var particleID = 0; var mouseX = 0; var mouseY = 0; -function makeParticles(data, amount=1) { +function makeParticles(data, amount=1, type = "normal") { for (let x = 0; x < amount; x++) { - let particle = getNewParticle() + let particle = newParticles[type]() for (thing in data) { switch(thing) { @@ -25,8 +25,10 @@ function makeParticles(data, amount=1) { } particle.dir = particle.dir + (particle.spread * (x- amount/2 + 0.5)) - particle.x += particle.offset * sin(particle.dir) - particle.y += particle.offset * cos(particle.dir) * -1 + if(particle.offset) { + particle.x += particle.offset * sin(particle.dir) + particle.y += particle.offset * cos(particle.dir) * -1 + } particle.xVel = particle.speed * sin(particle.dir) particle.yVel = particle.speed * cos(particle.dir) * -1 @@ -36,6 +38,11 @@ function makeParticles(data, amount=1) { } } +// Makes a particle at a random location that stays still until it despawns +function makeShinies(data, amount=1) { + makeParticles(data, amount, "shiny") +} + function sin(x) { return Math.sin(x*Math.PI/180) } @@ -64,30 +71,57 @@ function updateParticles(diff) { } } -function getNewParticle() { - particleID++ - return { - time: 3, - id: particleID, - x: mouseX, - y: mouseY, - width: 35, - height: 35, - image: "resources/genericParticle.png", - angle: 0, - spread: 30, - offset: 10, - speed: 15, - xVel: 0, - yVel: 0, - rotation: 0, - gravity: 0, - fadeOutTime: 1, - fadeInTimer: 0, - fadeIn: 0, - } +const newParticles = { + normal() { + particleID++ + return { + time: 3, + id: particleID, + x: mouseX, + y: mouseY, + width: 35, + height: 35, + image: "resources/genericParticle.png", + angle: 0, + spread: 30, + offset: 10, + speed: 15, + xVel: 0, + yVel: 0, + rotation: 0, + gravity: 0, + fadeOutTime: 1, + fadeInTimer: 0, + fadeInTime: 0, + } + }, + shiny() { + particleID++ + return { + time: 10, + id: particleID, + x: Math.random() * (tmp.other.screenWidth - 100) + 50, + y: Math.random() * (tmp.other.screenHeight - 100) + 50, + width: 50, + height: 50, + image: "resources/genericParticle.png", + angle: 0, + spread: 0, + offset: 0, + speed: 0, + xVel: 0, + yVel: 0, + rotation: 0, + gravity: 0, + fadeOutTime: 1, + fadeInTimer: 0, + fadeInTime: 0.5, + } + }, } + + function updateMouse(event) { mouseX = event.clientX mouseY = event.clientY diff --git a/js/technical/temp.js b/js/technical/temp.js index bc086ad..1050d35 100644 --- a/js/technical/temp.js +++ b/js/technical/temp.js @@ -45,6 +45,8 @@ function setupTemp() { tmp.other = { lastPoints: player.points || decimalZero, oomps: decimalZero, + screenWidth: 0, + screenHeight: 0, } updateWidth()