From 341f4dda0948f2305754b9ec1477213e43865d22 Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 23 Jul 2019 16:40:40 +1000 Subject: [PATCH] blast and text colours --- client/assets/styles/game.css | 33 +++----- client/package.json | 2 +- client/src/components/anims/blast.jsx | 106 ++++++++++---------------- 3 files changed, 51 insertions(+), 90 deletions(-) diff --git a/client/assets/styles/game.css b/client/assets/styles/game.css index d6ccd3d8..7fc39187 100644 --- a/client/assets/styles/game.css +++ b/client/assets/styles/game.css @@ -234,65 +234,54 @@ */} .game-construct.red-damage { -/* filter: drop-shadow(0 0 0.2em red); -*/ color: red; + color: #a52a2a; /*ensure construct doesn't get opacity lowered because of being KO before the KO animation*/ opacity: 1; - - /*border-color: red;*/ } .red-damage button { - /*border: 1px solid red;*/ - color: red; + color: #a52a2a; } .red-damage text { - fill: red; + fill: #a52a2a; } .red-damage .stats { - /*border-top: 1px solid red;*/ + /*border-top: 1px solid #a52a2a;*/ } .game-construct.blue-damage { -/* filter: drop-shadow(0 0 0.2em blue); -*/ color: blue; + color: #3498db; opacity: 1; - /*border-color: blue;*/ } .blue-damage button { - /*border: 1px solid blue;*/ - color: blue; + color: #3498db; } .blue-damage text { - fill: blue; + fill: #3498db; } .blue-damage .stats { - /*border-top: 1px solid blue;*/ } .game-construct.green-damage { -/* filter: drop-shadow(0 0 0.2em green); -*/ color: green; + color: #1FF01F; opacity: 1; - /*border-color: green;*/ } .green-damage button { - /*border: 1px solid green;*/ - color: green; + color: #1FF01F; } .green-damage text { - fill: green; + fill: #1FF01F; } .green-damage .stats { - /*border-top: 1px solid green;*/ + /*border-top: 1px solid #1FF01F;*/ } .game-construct.purple-damage { diff --git a/client/package.json b/client/package.json index fbf72b65..7fcacae2 100644 --- a/client/package.json +++ b/client/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "start": "parcel watch index.html --out-dir /var/lib/mnml/public/current", - "anims": "parcel watch animations.html --out-dir /var/lib/mnml/public/current", + "anims": "parcel watch animations.html --no-hmr --out-dir /var/lib/mnml/public/current", "build": "parcel build index.html", "scss": "node-sass --watch assets/scss -o assets/styles", "lint": "eslint --fix --ext .jsx src/", diff --git a/client/src/components/anims/blast.jsx b/client/src/components/anims/blast.jsx index 9c4fcb4f..f8c66715 100644 --- a/client/src/components/anims/blast.jsx +++ b/client/src/components/anims/blast.jsx @@ -1,100 +1,72 @@ const preact = require('preact'); const { Component } = require('preact'); const anime = require('animejs').default; +const times = require('lodash/times'); -const { TIMES } = require('../../constants'); -const { randomPoints } = require('../../utils'); +const { TIMES, COLOURS } = require('../../constants'); -const duration = TIMES.TARGET_DURATION_MS; - - -function projectile(x, y, radius, colour) { - return ( - - ); -} - -class AttackCharge extends Component { - constructor(props) { +class Blast extends Component { + constructor() { super(); - this.team = props.team; this.animations = []; - const points = randomPoints(8, 60, { x: 0, y: 0, width: 300, height: 400 }); - this.charges = points.map(coord => projectile(coord[0], coord[1], 20, '#00aabb')); } render() { return ( - // {this.charges} + viewBox="0 0 300 300"> - - - - + + + + + + + - - - - - - - {this.charges} + + {times(50, () => ( + + + + + ))} + ); } componentDidMount() { - anime.set('#blast', { - translateX: -200 * this.props.direction.x, - translateY: -300 * this.props.direction.y, - }); - this.animations.push(anime({ - targets: '#blast', + targets: ['#blast'], opacity: [ - { value: 1, delay: TIMES.TARGET_DELAY_MS, duration: TIMES.TARGET_DURATION_MS * 0.3 }, - { value: 0, delay: TIMES.TARGET_DURATION_MS * 0.7, duration: TIMES.POST_SKILL_DURATION_MS }, + { value: 1, delay: TIMES.TARGET_DELAY_MS, duration: TIMES.TARGET_DURATION_MS * 0.2 }, + { value: 0, delay: TIMES.TARGET_DURATION_MS * 0.5, duration: TIMES.TARGET_DURATION_MS * 0.2 }, ], + easing: 'easeInOutSine', })); - anime.set('#explosion feDisplacementMap', { - scale: 1, - }); - this.animations.push(anime({ - targets: '#blast', - translateY: 0, - translateX: 0, - loop: false, + targets: ['#blast g'], + transform: () => ` + translate(${anime.random(-100, 100)} ${anime.random(-100, 100)}) + `, + style: { rotate: anime.random(-180, 180) }, + easing: 'easeOutCubic', delay: TIMES.TARGET_DELAY_MS, - duration: (duration * 1 / 2), - easing: 'easeInQuad', - })); - - this.animations.push(anime({ - targets: '#explosion feDisplacementMap', - scale: 200, - loop: false, - delay: TIMES.TARGET_DELAY_MS + duration * 1 / 2, - duration: duration * 1 / 2, - easing: 'easeInQuad', + duration: TIMES.TARGET_DURATION_MS, })); } + // this is necessary because + // skipping / timing / unmounting race conditions + // can cause the animations to cut short, this will ensure the values are reset + // because preact will recycle all these components componentWillUnmount() { for (let i = this.animations.length - 1; i >= 0; i--) { this.animations[i].reset(); @@ -102,4 +74,4 @@ class AttackCharge extends Component { } } -module.exports = AttackCharge; +module.exports = Blast;