/** * Flade - Flash Dynamics Engine * Release 0.4 alpha * Particle class * Copyright 2004, 2005 Alec Cove * * This file is part of Flade. The Flash Dynamics Engine. * * Flade is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Flade is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Flade; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Flash is a registered trademark of Macromedia */ Particle = function(posX, posY) { // current and previous positions this.curr = new Vector(posX, posY); this.prev = new Vector(posX, posY); this.temp = new Vector(0,0); var drawClipName = "partdrawclip_" + this.depth; this.dmc = createEmptyMovieClip (drawClipName, this.depth); Particle.prototype.depth++; } Particle.prototype.depth = 1000; Particle.prototype.verlet = function(sysObj) { this.temp.x = this.curr.x; this.temp.y = this.curr.y; this.curr.x += sysObj.coeffDamp * (this.curr.x - this.prev.x) + sysObj.gravity.x; this.curr.y += sysObj.coeffDamp * (this.curr.y - this.prev.y) + sysObj.gravity.y; this.prev.x = this.temp.x; this.prev.y = this.temp.y; } Particle.prototype.checkCollision = function(surface, sysObj) { surface.resolveParticleCollision(this, sysObj); } Particle.prototype.paint = function() { this.dmc.clear(); this.dmc.lineStyle(0, 0x666666, 100); Graphics.prototype.paintCircle(this.dmc, this.curr.x, this.curr.y, 2); } Particle.prototype.setPos = function(px, py) { this.curr.x = px; this.curr.y = py; this.prev.x = px; this.prev.y = py; }