/**
* @author Wolfgang Kowarschick <kowa@hs-augsburg.de>
* @copyright 2017 - 2018
* @license CC-BY-NC-SA-4.0
*/
import {ModelRectangle} from './ModelRectangle';
class ModelPaddle extends ModelRectangle
{ /**
* @param {Object} [p_config]
* @param {number} [p_config.width = 0]
* @param {number} [p_config.height = 0]
* @param {number} [p_config.x = 0]
* @param {number} [p_config.y = 0]
* @param {number} [p_config.vx = 0]
* @param {number} [p_config.vy = 0]
* @param {number} [p_config.ax = 0]
* @param {number} [p_config.ay = 0]
* @param {string} [p_config.player = '']
*/
constructor(p_config)
{ super(p_config); }
/** @override */
reset()
{ const {width=0, height=0, x=0, y=0, player=''} = this.config;
this.width = width; this.height = height;
this.x = x; this.y = y;
this.vx = 0; this.vy = 0;
this.ax = 0; this.ay = 0;
this.player = player;
}
down()
{ if (this.vy === 0)
{ this.vy = this.config.vy;
this.ay = this.config.ay;
}
}
up()
{ if (this.vy === 0)
{ this.vy = -this.config.vy;
this.ay = -this.config.ay;
}
}
stop()
{ if (this.vy !== 0)
{ this.vy = 0;
this.ay = 0;
}
}
}
export {ModelPaddle};