1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2025-05-13 05:11:10 +00:00

Added additional particle features + fixes

This commit is contained in:
Harley White 2021-05-14 21:51:49 -04:00
parent 8781d49d8b
commit 3225755fe4
7 changed files with 41 additions and 13 deletions

View file

@ -300,7 +300,7 @@ addLayer("c", {
["main-display",
"prestige-button", "resource-display",
["blank", "5px"], // Height
["raw-html", function() {return "<button onclick='console.log(`yeet`);'>'HI'</button>"}],
["raw-html", function() {return "<button onclick='console.log(`yeet`); makeParticles(textParticle)'>'HI'</button>"}],
["display-text", "Name your points!"],
["text-input", "thingy"],
["display-text",
@ -560,7 +560,7 @@ const coolParticle = {
image:"options_wheel.png",
spread: 20,
gravity: 2,
time: 9999,
time: 3,
rotation (id) {
return 20 * (id - 1.5) + (Math.random() - 0.5) * 10
},
@ -583,4 +583,14 @@ const coolParticle = {
//this.width += 1
},
layer: 'f',
}
const textParticle = {
spread: 20,
gravity: 0,
time: 3,
speed: 0,
text: function() { return "<h1 style='color:yellow'>" + format(player.points)},
offset: 30,
fadeInTime: 1,
}

View file

@ -592,6 +592,8 @@ function loadVue() {
particles,
mouseX,
mouseY,
shiftDown,
ctrlDown,
},
})
}

View file

@ -32,7 +32,7 @@ function makeParticles(data, amount=1) {
particle.xVel = particle.speed * sin(particle.dir)
particle.yVel = particle.speed * cos(particle.dir) * -1
particle.fadeInTimer = particle.fadeInTime
Vue.set(particles, particle.id, particle)
}
@ -50,6 +50,7 @@ function updateParticles(diff) {
for (p in particles) {
let particle = particles[p]
particle.time -= diff;
particle.fadeInTimer -= diff;
if (particle["time"] < 0) {
Vue.delete(particles, p);
@ -84,6 +85,8 @@ function getNewParticle() {
rotation: 0,
gravity: 0,
fadeTime: 1,
fadeInTimer: 0,
fadeIn: 0,
}
}
@ -92,24 +95,33 @@ function updateMouse(event) {
mouseY = event.clientY
}
function getOpacity(particle) {
if ((particle.time < particle.fadeTime) && particle.fadeTime)
return particle.time / particle.fadeTime
if (particle.fadeInTimer > 0)
return 1 - (particle.fadeInTimer / particle.fadeInTime)
return 1
}
function constructParticleStyle(particle){
console.log(getOpacity(particle))
return {
left: (particle.x - particle.height/2) + 'px',
top: (particle.y - particle.height/2) + 'px',
width: particle.width + 'px',
height: particle.height + 'px',
transform: "rotate(" + particle.angle + "deg)",
opacity: ((particle.time < particle.fadeTime) && particle.fadeTime) ? particle.time / particle.fadeTime : 1,
opacity: getOpacity(particle),
"pointer-events": (particle.onClick || particle.onHover) ? 'auto' : 'none',
"background-image": "url(" + particle.image + ")",
}
}
function clearParticles(check) {
if (!check) check = true
if (!check) check = true
for (p in particles) {
console.log(run(check, particles[p], particles[p]))
if (run(check, particles[p], particles[p])){
Vue.delete(particles, p)
}

View file

@ -191,9 +191,9 @@ var systemComponents = {
'particle': {
props: ['data', 'index'],
template: `<img class='particle instant' v-bind:style="[constructParticleStyle(data), data.style]" v-bind:src="data.image"
v-on:click="run(data.onClick, data)" v-on:mouseenter="run(data.onMouseOver, data)" v-on:mouseleave="run(data.onMouseLeave, data)">
</img>
template: `<div class='particle instant' v-bind:style="[constructParticleStyle(data), data.style]"
v-on:click="run(data.onClick, data)" v-on:mouseenter="run(data.onMouseOver, data)" v-on:mouseleave="run(data.onMouseLeave, data)" ><span v-html="data.text"></span>
</div>
`
},