Wavy lines in java?

But im only trying to make a simple 2d effect here lol nothing 3d yet! im not nearly ready for that

Where did he say his code related to 3d?

He mentioned 3D cameras :wink:

We are not making fun of your lack of skill…simply advising that you try to solve problems before asking us to solve them for you. Being in middle school is not an excuse, rather it is a privilege to start game programming so young.

I did try and solve this problem…but with my research and no knowledge of trig I had no clue you could do this

Thank you very much! i truly appreciate the help… I must soon learn all the trig in the world!

Personally I believe it’s best to start young, it allows the brain to adapt and grow in a way, specialise at a deeper level.
It’s also nice for trying to get a job “programming since 12” ;D

you can also use graph.tk to see how your equations will look.

I’m assuming you saw my edit with the code and explanation?

In anyway, I understand your frustration. You just want to get things done without painstakingly reading through lots of explanations. You want to get things done[tm]. However, that’s not the right way to learn things and use them properly in the future. Hopefully you get a small glimpse of what you can do with sin(theta) and hopefully you keep learning more maths because math is just awesome :smiley:

Kids these days. Back when I learned to program we didn’t have internets.


[quote="ra4king,post:12,topic:40431"]

Not “shouldn’t make games” but should learn more before starting to make games.
[/quote]
Or, failing that, join StackOverflow. :wink:


[quote="ra4king,post:28,topic:40431"] hopefully you keep learning more maths because math is just awesome :D [/quote] Yes

Ok masteryoom. It’s time to talk. With all due respect, please refrain from using all these oversized texts and obnoxious colors.

Let’s act like adults here, please. We can get silly sometimes, but properly and at the right time.

Note: this is not meant to be offensive. I am simply tired of seeing you post with HUGE font random comments that add nothing to the conversation. Let’s maintain a high signal to noise ratio on these boards.

Back to math: you might want to wander on over to http://khanacademy.org and check out the geometry and trig lessons. You’re going need some basic trig to do any 2d game dealing with angles, waves, that sort of thing, and some basic vector and matrix arithmetic for any 3d game.

:confused: I guess this is too demotivating…
Yes. He already pointed out, he’s just in middle school, and many others are too.
Even if you don’t know trigonometry you are still able to make games.
And we didn’t have trigonometry in math until this grade, and we only talked about sin, cos and tan yet. No vectors, and obviously no matrices. And I still understand vectors fully and am able to use matrices, even if I don’t understand them perfectly.
And I am able to code games, no reason to demotivate somebody like that, really. He is probably just as old as you, Jimmt, what would think if you didn’t know trigonometry and somebody said that to you? :confused: You had to learn it yourself too, I guess.

Heyho,
A vector describes the way from one point to another. You got a 3D world -> x,y,z axis.
The x-axis says how far something is west or east.
The y-axis says how far something is north or south.
The z-axis says how high something is. //That doesn’t sound english ::slight_smile:

pi = 3.14…
sin(x) is a wave that:
-sin(0pi/4) = 0
-sin(1
pi/4) = 1
-sin(2pi/4) = 0
-sin(3
pi/4) = -1
-sin(4*pi/4) = 0

sin(alpha) = something between -1 and 1
sin(alpha-[whole Number]*Period) = sin(alpha) = something between -1 and 1 // Note 1

sin(alpha) = 0.5
<=> alpha = arcsin(0.5)
<=> alpha = 0.524
Have a look at “Note 1” -> Actualle the result is 0.524+2kpi // k instanceof whole numbers

cos(x) wave:
cos(pi/4 - alpha) = sin(alpha)
cos(alpha) = sin( pi/4 - alpha)
tan-wave:
tan(alpha) = sin(alpha)/cos(alpha)

I don’t know how much you already know, if you have any questions left, feel free to ask :slight_smile:
best regards

I’m not understanding that completely… so what I want to do is continuously increase the y values by lets say 5. Then I want the x balls to have the curve. So would I use the sin function in the x values? And also this isn’t a 3d game, just a simple 2d one

Maybe its different in your area, but in my school we learned sin, cos, and tan in 8th grade…limited trig, the rest I learned what I needed to.

I forgot about that place. It’ll help once I get into trigonometry and other geometry. Thanks.

Ugh. You don’t even need sin(x) to fake a falling snowflake animation. What is this place coming to? sigh

Seriously, all you need is a simple loop to oscillate between 2 points and represent a falling snowflake. Obviously the snowflake will be moving downward, so you need to keep the y constant, and make sure the x value oscillates (or moves back and forth between 2 values.) Here is some psuedo-code…



//This is the starting horizontal value for the flake
public int x = 10;
//The starting vertical value - We want the snowflake to start off screen
public int y = -10;
//Whether a snowflake will move left or right
public boolean moveLeft;

public void snowflakeLoop(){

    y = y + 2;

    if(moveLeft) {
          x = x - 1;
          if( x < 5 )
                moveLeft = false;
    }
    else{
         x = x + 1;
         if( x > 15 )
                 moveLeft = true;
    }
} 

Have the picture of the snowflake bind to this and running through that loop multiple times will achieve the snowflake effect without trig. What happened to the whole notion of simplicity in this forum? [/rant]

Simplicity isn’t all about noobproof code.

And some old-wolves (75% of this forum, my optimistic guess) would say that using sin() is way simpler.

No, you don’t need trig for simple oscillation, but knowing how sin and cos work is still going to be a rather big help in the long run … and earlier. Certainly it’s easier to express wave motion with a single function than with all that state.

…I am not pro at anything but if you want to make snow, you do not need sines, oscillating or anything other then some objects the get a random x velocity and have a y velocity pulling them slow towards the ground. Oscillating would be for things like a feather falling. Most of the time snow is being blow all around or is going in a general direction but still very random as each flake is different.

Now for that example it looks like the objects are going back and forth between directions which is not very nice looking but does suggest osculating and sines.

If you are having a hard time understanding suggestions then this is to advanced and you need to slow down a little. Tip on where to start. If you know some basic java, (can draw squares and such in a window) then try making stuff move around. Have an object that gets updated and moves. Maybe make it bounce against the screen. After that, play with the movement a little. Start small and work up.

What that example has is basically a particle system that plays more like an animation. This is not something you start out with. The reason why most people won’t just give all the code is so you can learn how to do it. If we all just did our kids math problems for them, then they would never learn. Good luck and if you need a starting point just ask. :slight_smile: