Replaced noise with wave.

This commit is contained in:
Devine Lu Linvega
2016-11-15 18:11:04 -08:00
parent 941c9d6575
commit 7b6c629e1e
3 changed files with 25 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ function Pointer(offset = new Position(), color = new Color('000000'))
this.noise = null;
this.position_prev = null;
this.angle = null;
this.distance = 0;
this.draw = function()
{
@@ -13,9 +14,11 @@ function Pointer(offset = new Position(), color = new Color('000000'))
var position = this.position();
this.distance += position.distance_to(this.position_prev);
if(this.noise){
position.x += (Math.random() * this.noise) - (this.noise/2);
position.y += (Math.random() * this.noise) - (this.noise/2);
position.x += (Math.sin(this.distance/100) * this.noise) - (this.noise/2);
position.y += (Math.sin(this.distance/100) * this.noise) - (this.noise/2);
}
ronin.canvas.context().beginPath();

View File

@@ -46,7 +46,7 @@ function Command(content)
this.noise = function()
{
for (i = 0; i < this.content.length; i++) {
if(this.content[i].indexOf("?") >= 0){ return parseInt(this.content[i][1]); }
if(this.content[i].indexOf("?") >= 0){ return parseInt(this.content[i].replace('?','')); }
}
return null;
}