Path: blob/main/public/games/files/garbage-collector/js/entities/trash.js
1036 views
/*jshint bitwise: false*/1/*globals define*/2define([3'entities/physics-entity',4'entities/explosion',5'config/colors',6'config/material'7], function( PhysicsEntity, Explosion, Colors, Material ) {8'use strict';910function Trash( options, lifeTime ) {11PhysicsEntity.call( this, options );1213// In seconds.14this.lifeTime = lifeTime || 0;15this.time = 0;16}1718Trash.prototype = new PhysicsEntity();19Trash.prototype.constructor = Trash;2021Trash.prototype.update = function( dt ) {22PhysicsEntity.prototype.update.call( this, dt );2324this.time += dt;2526var explosion, fill;27if ( this.time > this.lifeTime ) {28this.game.removed.push( this );2930fill = Colors.Explosion[ Material.type( this.material ) ];3132if ( fill ) {33explosion = new Explosion( this.x, this.y );34explosion.fill.set( fill );35this.game.add( explosion );36}37}38};3940Trash.prototype.draw = function( ctx ) {41ctx.lineJoin = 'round';42PhysicsEntity.prototype.draw.call( this, ctx );43ctx.lineJoin = 'miter';44};4546return Trash;47});484950