mirror of
https://github.com/Acamaeda/The-Modding-Tree.git
synced 2024-11-21 08:12:39 +00:00
More particle work
This commit is contained in:
parent
df0c79f800
commit
1ea1ad5118
6 changed files with 59 additions and 16 deletions
|
@ -556,4 +556,4 @@ addLayer("a", {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
const coolParticle = {}
|
const coolParticle = {image:"options_wheel.png"}
|
|
@ -579,6 +579,7 @@ function loadVue() {
|
||||||
challengeStyle,
|
challengeStyle,
|
||||||
challengeButtonText,
|
challengeButtonText,
|
||||||
constructBarStyle,
|
constructBarStyle,
|
||||||
|
constructParticleStyle,
|
||||||
VERSION,
|
VERSION,
|
||||||
LAYERS,
|
LAYERS,
|
||||||
hotkeys,
|
hotkeys,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Variables that must be defined to display popups
|
// Variables that must be defined to display popups
|
||||||
var particles = [];
|
var particles = {};
|
||||||
var particleID = 0;
|
var particleID = 0;
|
||||||
var mouseX = 0;
|
var mouseX = 0;
|
||||||
var mouseY = 0;
|
var mouseY = 0;
|
||||||
|
@ -9,23 +9,49 @@ function makeParticles(data, amount=1) {
|
||||||
for (let x = 0; x < amount; x++) {
|
for (let x = 0; x < amount; x++) {
|
||||||
let particle = getNewParticle()
|
let particle = getNewParticle()
|
||||||
for (thing in data) {
|
for (thing in data) {
|
||||||
|
|
||||||
switch(thing) {
|
switch(thing) {
|
||||||
case DEFAULT:
|
case 'onClick', 'onHover', 'update': // Functions that should be copied over
|
||||||
particle[thing]=data[thing]
|
particle[thing] = data[thing]
|
||||||
|
default:
|
||||||
|
particle[thing]=run(data[thing], data, x)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
particles.push(particle)
|
if (data.angle === undefined) {
|
||||||
|
particle.dir = particle.angle
|
||||||
|
}
|
||||||
|
particle.dir = particle.dir + (particle.spread * (x- amount/2 + 0.5))
|
||||||
|
|
||||||
|
particle.xVel = particle.speed * sin(particle.dir)
|
||||||
|
particle.yVel = particle.speed * cos(particle.dir) * -1
|
||||||
|
|
||||||
|
Vue.set(particles, particle.id, particle)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sin(x) {
|
||||||
|
return Math.sin(x*Math.PI/180)
|
||||||
|
}
|
||||||
|
|
||||||
|
function cos(x) {
|
||||||
|
return Math.cos(x*Math.PI/180)
|
||||||
|
}
|
||||||
|
|
||||||
//Function to reduce time on active popups
|
|
||||||
function updateParticles(diff) {
|
function updateParticles(diff) {
|
||||||
for (p in particles) {
|
for (p in particles) {
|
||||||
particles[p].time -= diff;
|
particles[p].time -= diff;
|
||||||
if (particles[p]["time"] < 0) {
|
if (particles[p]["time"] < 0) {
|
||||||
particles.splice(p, 1); // Remove popup when time hits 0
|
Vue.delete(particles, p);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (particles[p].update) run(particles[p].update, particles[p])
|
||||||
|
particles[p].angle += particles[p].rotation
|
||||||
|
particles[p].x += particles[p].xVel
|
||||||
|
particles[p].y += particles[p].yVel
|
||||||
|
particles[p].yVel += particles[p].gravity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,10 +59,21 @@ function updateParticles(diff) {
|
||||||
function getNewParticle() {
|
function getNewParticle() {
|
||||||
particleID++
|
particleID++
|
||||||
return {
|
return {
|
||||||
time: 5,
|
time: 2,
|
||||||
id: particleID,
|
id: particleID,
|
||||||
x: mouseX,
|
x: mouseX,
|
||||||
y: mouseY,
|
y: mouseY,
|
||||||
|
width: 35,
|
||||||
|
height: 35,
|
||||||
|
image: "resources/genericParticle.png",
|
||||||
|
angle: 0,
|
||||||
|
spread: 30,
|
||||||
|
offset: 20,
|
||||||
|
speed: 20,
|
||||||
|
xVel: 0,
|
||||||
|
yVel: 0,
|
||||||
|
rotation: 0,
|
||||||
|
gravity: 4,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,3 +81,13 @@ function updateMouse(event) {
|
||||||
mouseX = event.clientX
|
mouseX = event.clientX
|
||||||
mouseY = event.clientY
|
mouseY = event.clientY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function constructParticleStyle(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)",
|
||||||
|
}
|
||||||
|
}
|
|
@ -191,8 +191,8 @@ var systemComponents = {
|
||||||
|
|
||||||
'particle': {
|
'particle': {
|
||||||
props: ['data', 'index'],
|
props: ['data', 'index'],
|
||||||
template: `<div class='particle' v-bind:style="{left: data.x + 'px', top: data.y + 'px'}">ahragagag
|
template: `<img class='particle instant' v-bind:style="constructParticleStyle(data)" v-bind:src="data.image">
|
||||||
</div>
|
</img>
|
||||||
`
|
`
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -44,13 +44,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.particle {
|
.particle {
|
||||||
border: 4px solid;
|
background-color: transparent;
|
||||||
border-radius: 7px;
|
|
||||||
width: 50px;
|
|
||||||
min-height: 60px;
|
|
||||||
background-color: #696969;
|
|
||||||
display: block;
|
display: block;
|
||||||
border-color: rgba(0, 0, 0, 0.25);
|
|
||||||
position:absolute;
|
position:absolute;
|
||||||
z-index: 99999
|
z-index: 99999
|
||||||
}
|
}
|
BIN
resources/genericParticle.png
Normal file
BIN
resources/genericParticle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
Loading…
Reference in a new issue