Skip to content

Instantly share code, notes, and snippets.

View happyDemon's full-sized avatar

Kerstens Maxim happyDemon

  • Shyfter
  • Belgium
View GitHub Profile
@happyDemon
happyDemon / pokemon-watch.js
Last active March 4, 2017 07:55
Vue.js explained through Pokemon #5
watch: {
attackEffect(value, oldValue)
{
// If the battleEffect has been reset and we've got another one waiting in our queue
if(value === false && this.attackEffectQueue.length > 0)
{
// Show the effect from the queue
this.showAttackEffect(this.attackEffectQueue[0]);
// Remove the effect from the queue
@happyDemon
happyDemon / pokemon-methods.js
Last active March 4, 2017 08:26
Vue.js explained through Pokemon #5
showAttackEffect(effect)
{
// If there's already an attack effect, queue it
if(this.attackEffect != false)
{
this.attackEffectQueue.push(effect);
return;
}
// Show attack effect
@happyDemon
happyDemon / pokemon-data.js
Last active March 4, 2017 07:47
Vue.js explained through Pokemon #5
attackEffect: false,
attackEffectQueue: []
@happyDemon
happyDemon / pokemon-attack.js
Created March 3, 2017 14:27
Vue.js explained through Pokemon #5
if(attackPower > 0)
{
// Show that the opponnet is receiving damage
Velocity(document.getElementById(this.otherPokemon+'-pokemon'), 'callout.swing');
}
@happyDemon
happyDemon / pokemon-attack.js
Created March 3, 2017 14:23
Vue.js explained through Pokemon #5
// Show that the current pokemon is attacking
Velocity(document.getElementById(this.pokemonImageId), 'callout.pulse');
@happyDemon
happyDemon / pokemon-template.html
Created March 3, 2017 11:24
Vue.js explained through Pokemon #5
<transition appear name="pokemon-image">
<img :id="pokemonImageId" v-if="alive" :src="image" class="pokemon-bottom"/>
</transition>
@happyDemon
happyDemon / pokemon-style.css
Last active March 3, 2017 10:41
Vue.js explained through Pokemon #5
<style>
/* Setup enter animation */
.pokemon-image-enter-active {
transition: all .5s ease;
}
/* Setup leave animation */
.pokemon-image-leave-active {
transition: all .5s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
/* Enter effect */
@happyDemon
happyDemon / pokemon-methods.js
Created March 3, 2017 07:04
Vue.js explained through Pokemon #4
calculateDamage(attackName) {
const attack = this.local.pokemon.attacks[attackName];
const damage = new Damage(attack, this.local.pokemon, this.opponent.pokemon);
return damage.power();
},
@happyDemon
happyDemon / pokemon-script.js
Created March 3, 2017 07:03
VUe.js explained through Pokemon #4
import Damage from './Damage';
@happyDemon
happyDemon / Damage.js
Created March 3, 2017 06:24
Vue.js explained through POkemon #4
power() {
return Math.floor(this.calculateStatsPower() * this.calculateStab() * this.calculateTypeEffect() * this.calculateCritical() * this.calculateOther() * this.getRandomFactor())
}