Hi, Thanks for having me.
Playing around with the Processing "Hello World" (drawing a line), I eventually brought myself to a place where I'm drawing a line to a point on a sin wave (two lines actually, one from the top and one from the bottom). It's pretty and I'm really just trying to transition from actionscript.
All I'm doing is increasing a variable and taking the sin of it for the x position of the line. Again, something I used in actionscript all the time.
Now... what I haven't done in a long, long time is really play with this. A few years ago I would make shooter games and the enemy behavior was usually based off of a sin or cos. I could SWEAR that using tan() I could get a pattern like:
At least I remember making enemies move in that pattern. Well when I switched the function to tan(i) I got:
Which not only wasn't the wave I was expecting, it's not a wave at all. In fact it's not even a pattern!
So that surprised me. Now, is my memory completely faulty? Second, it's been 15 years since I had highschool math but... is that right!?
Code:
void move(){
float n = sin(i); //make a float to control the up and down
float p = .7; //make a float to control the left and right
i = i+.1; //increase i
y = y+n; //move y by the sin(i)
if(x<width){ //if x isn't off screen
x=x+p; //move x
}
else{//and if it is
x=0;//move it back to the other side
}