# Sine Wave problem

**URL:** <https://forum.kirupa.com/t/sine-wave-problem/182393>\
**Category:** flash\
**Created:** [March 17, 2006, 6:53pm UTC](https://forum.kirupa.com/t/sine-wave-problem/182393 "2006-03-17T18:53:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stermer](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@stermer](https://forum.kirupa.com/u/stermer)\
**Post date:** [March 17, 2006, 6:53pm UTC](https://forum.kirupa.com/t/sine-wave-problem/182393/1 "2006-03-17T18:53:28Z")

</div>

ok, i am trying to create a rightward moving sine wave with a fill underneath it, so it looks like a ripple. my problem is for some reason, i can get it to move leftward, but when i try to invert it, i get the bottom right hand corner up in the middle.

here’s my code:

NbrControlPoints = 20;  
StartX = 0;  
EndX = Stage.width;  
BottomY = Stage.height;  
WaterLevel = Stage.height/2;  
WaveHeight = 30;  
WaveSpeed = .0005;

\_root.onEnterFrame = function()  
{  
this.clear();  
this.beginFill(0xFE9919, 100);  
this.moveTo(StartX, BottomY);  
for (x = 0; x \< NbrControlPoints; ++x)  
{  
var r = x/(NbrControlPoints-1);  
px = EndX + r\*(StartX - EndX);  
py = WaterLevel + WaveHeight_Math.sin(r_Math.PI\*2 + getTimer()\*WaveSpeed);  
this.lineTo(px,py);  
}  
this.lineTo(StartX, BottomY);  
this.lineTo(EndX, BottomY);  
this.endFill();  
}

and i missing something stupid that is making this happen? i’ve been troubleshooting this for 2 hours and the math is now making my head hurt.

any help would be appriciated.
