mirror of
https://github.com/thepaperpilot/The-Modding-Tree.git
synced 2025-02-07 18:41:36 +00:00
Added additional particle features + fixes
This commit is contained in:
parent
8781d49d8b
commit
3225755fe4
7 changed files with 41 additions and 13 deletions
|
@ -37,7 +37,7 @@ While reading this documentation, the following key will be used when describing
|
||||||
|
|
||||||
- [Upgrades](upgrades.md): How to create upgrades for a layer.
|
- [Upgrades](upgrades.md): How to create upgrades for a layer.
|
||||||
- [Milestones](milestones.md): How to create milestones for a layer.
|
- [Milestones](milestones.md): How to create milestones for a layer.
|
||||||
- [Buyables](buyables.md): Create rebuyable upgrades for your layer (with the option to make them respec-able). Can be used to make Enhancers or Space Buildings.
|
- [Buyables](buyables.md): Create rebuyable upgrades for your layer (with the option to make them respec-able). Can be used to make Enhancers or Space Buildings, for example.
|
||||||
- [Clickables](clickables.md): A more generalized variant of buyables, for any kind of thing that is sometimes clickable. Between these and Buyables, you can do just about anything.
|
- [Clickables](clickables.md): A more generalized variant of buyables, for any kind of thing that is sometimes clickable. Between these and Buyables, you can do just about anything.
|
||||||
- [Achievements](achievements.md): How to create achievements for a layer (or for the whole game).
|
- [Achievements](achievements.md): How to create achievements for a layer (or for the whole game).
|
||||||
|
|
||||||
|
@ -50,3 +50,4 @@ While reading this documentation, the following key will be used when describing
|
||||||
- [Grids][grids.md]: Create a group buttons that behave the same, but have their own data. Good for map tiles, an inventory grid, and more!
|
- [Grids][grids.md]: Create a group buttons that behave the same, but have their own data. Good for map tiles, an inventory grid, and more!
|
||||||
- [Infoboxes](infoboxes.md): Boxes containing text that can be shown or hidden.
|
- [Infoboxes](infoboxes.md): Boxes containing text that can be shown or hidden.
|
||||||
- [Trees](trees-and-tree-customization.md): Make your own trees. You can make non-layer button nodes too!
|
- [Trees](trees-and-tree-customization.md): Make your own trees. You can make non-layer button nodes too!
|
||||||
|
- [Particle system](particles.md): Can be used to create particles for visual effects, but also interactable things like golden cookies or collectables.
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
Don't forget
|
Don't forget
|
||||||
- layer
|
- layer
|
||||||
- style
|
- style
|
||||||
|
- make text particles
|
||||||
|
-fade in?
|
|
@ -300,7 +300,7 @@ addLayer("c", {
|
||||||
["main-display",
|
["main-display",
|
||||||
"prestige-button", "resource-display",
|
"prestige-button", "resource-display",
|
||||||
["blank", "5px"], // Height
|
["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!"],
|
["display-text", "Name your points!"],
|
||||||
["text-input", "thingy"],
|
["text-input", "thingy"],
|
||||||
["display-text",
|
["display-text",
|
||||||
|
@ -560,7 +560,7 @@ const coolParticle = {
|
||||||
image:"options_wheel.png",
|
image:"options_wheel.png",
|
||||||
spread: 20,
|
spread: 20,
|
||||||
gravity: 2,
|
gravity: 2,
|
||||||
time: 9999,
|
time: 3,
|
||||||
rotation (id) {
|
rotation (id) {
|
||||||
return 20 * (id - 1.5) + (Math.random() - 0.5) * 10
|
return 20 * (id - 1.5) + (Math.random() - 0.5) * 10
|
||||||
},
|
},
|
||||||
|
@ -583,4 +583,14 @@ const coolParticle = {
|
||||||
//this.width += 1
|
//this.width += 1
|
||||||
},
|
},
|
||||||
layer: 'f',
|
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,
|
||||||
}
|
}
|
|
@ -592,6 +592,8 @@ function loadVue() {
|
||||||
particles,
|
particles,
|
||||||
mouseX,
|
mouseX,
|
||||||
mouseY,
|
mouseY,
|
||||||
|
shiftDown,
|
||||||
|
ctrlDown,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ function makeParticles(data, amount=1) {
|
||||||
|
|
||||||
particle.xVel = particle.speed * sin(particle.dir)
|
particle.xVel = particle.speed * sin(particle.dir)
|
||||||
particle.yVel = particle.speed * cos(particle.dir) * -1
|
particle.yVel = particle.speed * cos(particle.dir) * -1
|
||||||
|
particle.fadeInTimer = particle.fadeInTime
|
||||||
Vue.set(particles, particle.id, particle)
|
Vue.set(particles, particle.id, particle)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ function updateParticles(diff) {
|
||||||
for (p in particles) {
|
for (p in particles) {
|
||||||
let particle = particles[p]
|
let particle = particles[p]
|
||||||
particle.time -= diff;
|
particle.time -= diff;
|
||||||
|
particle.fadeInTimer -= diff;
|
||||||
if (particle["time"] < 0) {
|
if (particle["time"] < 0) {
|
||||||
Vue.delete(particles, p);
|
Vue.delete(particles, p);
|
||||||
|
|
||||||
|
@ -84,6 +85,8 @@ function getNewParticle() {
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
gravity: 0,
|
gravity: 0,
|
||||||
fadeTime: 1,
|
fadeTime: 1,
|
||||||
|
fadeInTimer: 0,
|
||||||
|
fadeIn: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,24 +95,33 @@ function updateMouse(event) {
|
||||||
mouseY = event.clientY
|
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){
|
function constructParticleStyle(particle){
|
||||||
|
console.log(getOpacity(particle))
|
||||||
return {
|
return {
|
||||||
left: (particle.x - particle.height/2) + 'px',
|
left: (particle.x - particle.height/2) + 'px',
|
||||||
top: (particle.y - particle.height/2) + 'px',
|
top: (particle.y - particle.height/2) + 'px',
|
||||||
width: particle.width + 'px',
|
width: particle.width + 'px',
|
||||||
height: particle.height + 'px',
|
height: particle.height + 'px',
|
||||||
transform: "rotate(" + particle.angle + "deg)",
|
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',
|
"pointer-events": (particle.onClick || particle.onHover) ? 'auto' : 'none',
|
||||||
|
"background-image": "url(" + particle.image + ")",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearParticles(check) {
|
function clearParticles(check) {
|
||||||
if (!check) check = true
|
if (!check) check = true
|
||||||
|
|
||||||
for (p in particles) {
|
for (p in particles) {
|
||||||
console.log(run(check, particles[p], particles[p]))
|
|
||||||
if (run(check, particles[p], particles[p])){
|
if (run(check, particles[p], particles[p])){
|
||||||
Vue.delete(particles, p)
|
Vue.delete(particles, p)
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,9 +191,9 @@ var systemComponents = {
|
||||||
|
|
||||||
'particle': {
|
'particle': {
|
||||||
props: ['data', 'index'],
|
props: ['data', 'index'],
|
||||||
template: `<img class='particle instant' v-bind:style="[constructParticleStyle(data), data.style]" v-bind:src="data.image"
|
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)">
|
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>
|
||||||
</img>
|
</div>
|
||||||
`
|
`
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -47,5 +47,6 @@
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
display: block;
|
display: block;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
z-index: 99999
|
z-index: 99999;
|
||||||
|
background-size:contain;
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue