W
Wild_West
Guest
Is there any way to make a "wiggle" pattern using draw_line so it looks like a wave frequency?
Okay, I'll look into it, thanks.No, if you want to draw curves you have to construct them out of multiple line sections. A sine wave would be pretty simple, but something like bezier curves would need more math.
I'm so rubbish at maths so that helps a lot, thanks. ^^;In case you're wondering, the general equation of a point on a wave is
y = amplitude*sin(W*time + K*x)
where W is the wave frequency (the speed the wave undulates with) and K is the speed the wave itself is moving (and x is the coordinate along the direction the wave is moving in). Basically try out some different values and see whether it's working / looking well or not, but if you use that formula to compute the coordinates it will look like a wave.
This is true, but sometimes animating 6 frames of a wiggle can be far easier than coding an FM/AM synthesizer with wave visualization.@muki All waves are combinations of sine waves with different amplitudes and frequencies. In fact, you can make any shape using a combination of sine waves.
Yeah I mean that's what I WAS gonna do, is try to simulate a wave that the player can manipulate for the sake of having to make both waves the same frequency, triggering a locking object to UNlock.This is true, but sometimes animating 6 frames of a wiggle can be far easier than coding an FM/AM synthesizer with wave visualization.
It depends on the OP's needs of course.
for(var i = 0; i > 360; i++)
{
draw_line(i*2,16+dsin(i)*16,i*2+2,16+dsin(inc_num+1)*16)
}
I actually did see those images from videos I watched looking up more about sin and cosine, but since they didn't really explain anything it doesn't really help a maths novice learn what to do to replicate it.Not using draw_line. Anyways I would look into sine waves. Essentially the sin of an increasing number will result in a wave that ossilates between 0 and 1. Then you can manipulate that how you wish.
Some psuedo-code:
Code:for(var i = 0; i > 360; i++) { draw_line(i*2,16+dsin(i)*16,i*2+2,16+dsin(inc_num+1)*16) }
https://drive.google.com/file/d/0BxPYaBbqcCwPYlhtOXZQQjF5MkU/view?usp=sharing
Here's a little demo I made for my class. It's made entirely in GM.
I'm almost entirely self taught, so when I learned about this years ago I used Kahn Accademy https://www.khanacademy.org/math/trigonometry/trigonometry-right-triangles
If you'd like I can try to make a tutorial. My laptop broke, so I'm not sure my current PC will be able to handle recording software.I actually did see those images from videos I watched looking up more about sin and cosine, but since they didn't really explain anything it doesn't really help a maths novice learn what to do to replicate it.
But I'll look into the other links you provided too.
I mean I'm not gonna say no to an offer of help when I'm stuck so if you're willing to yeah I'd appreciate it ^^If you'd like I can try to make a tutorial. My laptop broke, so I'm not sure my current PC will be able to handle recording software.
for(x=0;x<10;x+=1){
y = sin(x);
draw_point(x,y);
}
for(x=0;x<10;x+=1){
y = sin(x);
draw_point(10*x,10*y);
}
old_x = 0;
old_y = 0;
for(x=0;x<10;x+=1){
y = sin(x);
draw_line(10*old_x,10*old_y,10*x,10*y);
old_x = x;
old_y = y;
}