import { Vector } from '../types' ; export class Ball { private speed : Vector ; private ballImage : HTMLImageElement = new Image ( ) ; constructor ( speed , private ballSize , private position , image ) { this . ballSize = ballSize ; this . position = position ; this . speed = { x : speed , y : - speed } ; this . ballImage . src = image ; } get width ( ) : number { return this . ballSize ; } get height ( ) : number { return this . ballSize ; } get pos ( ) : Vector { return this . position ; } get image ( ) : HTMLImageElement { return this . ballImage ; } changeYDirection ( ) { this . speed . y = - this . speed . y ; } changeXDirection ( ) { this . speed . x = - this . speed . x ; } moveBall ( ) { this . pos . x += this . speed . x ; this . pos . y += this . speed . y ; } }