Code-library :: physic.as

Contenu du snippet

voici un des fichier d'une librairie de fonction que je suis en train de creer.
certaines fonctions sont de moi, d'autres viennent de differents sites.
Ce fichier est en construction perpetuel.
il n'y a ici que les fonctions dont je me suis le plus servi dans mes projets.
ce fichier contient des fichier permettant de gerer la physic :: gravité, orbite, etc...

Source / Exemple :


////
/*
description	physicals movements :: gravity, bounce, etc...
filename	physic.as
Author 		BlackWizzard 
Contact		postmater@blackwizzard.com
url		http://laboratory.blackwizzard.com
created		14/02/03
last modified	16/02/03

  • /
/* :: init gravity :: */ movieclip.prototype.initGravity = function() { this.decay = 2; this.speed = 0; this.oldspeed = 1; } /* :: start gravity :: */ movieclip.prototype.gravity = function(map) { if (map.hitTest(this._x, this._y, true) || map.hitTest(this._x+this._width/2, this._y, true) || map.hitTest(this._x-this._width/2, this._y, true)) { this.speed = 0; this.xspeed = 0; if (map.hitTest(this._x, this._y-1, true) || map.hitTest(this._x+this._width/2, this._y-1, true) || map.hitTest(this._x-this._width/2, this._y-1, true)) { this._y -= 1; } } this._y -= this.speed; this.speed -= this.decay; } /* :: make orbit :: */ movieclip.prototype.orbit = function(centerX, centerY, ratio, dir, speed) { this.centerX = centerX; this.centerY = centerY; this.ratio = ratio; this.dir = dir; this._x = centerX + Math.cos(t) * ratio; this._y = centerY + dir * Math.sin(t) * ratio; t += speed; };

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.