123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|649|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> Sort of Sine movement

Sun, 19 Sep 2010, 16:26
dna
I have this program that I am writing which has snow like particles in the bacground.
I was trying to make the snow like particles move in a non linear fashion, meaning, linear but with a slight sinusoid move as well.
Here is the expression that I am using.


Apparently when I add the *COS(TT) or *SIN(TT) to the end, it speeds it up when I want a sine movement



This portion adds the direction

-=-=-
DNA
Sun, 19 Sep 2010, 16:36
Jayenkai
Assuming you have TT being a number (0->100 snowflakes)
Imagine TT is 0
DOT_X(TT)=DOT_X(TT)+DD_X(TT)*SPEED(TT)*SIN(TT)
Sin(TT) for snowflake 0 will ALWAYS be 0
Cos(TT) for snowflake 0 will ALWAYS be 1

So, snowflake 0 will always be going 0 across, and 1 down.

At the same time, snowflake 90, will ALWAYS be Sin(90) and Cos(90) so will be going 1 to the right, and 0 down.

Instead of Sin(TT) and Cos(TT), create a "SineWave" variable..
Where you do your Flip at the bottom of your main loop..

SineWave=SineWave+1 (experiment with this value to see what looks good)

Then use DOT_X(TT)=DOT_X(TT)+DD_X(TT)*SPEED(TT)*SIN(SineWave)
(and similarly for Y/Cos)

This should give a nice spread to both, and if you play around with the values a little, should make things look nice and siney.

-=-=-
''Load, Next List!''
Sun, 19 Sep 2010, 16:48
dna
here's the body of it.



These particles bounce off the walls like pong. They then move off the walls at right angles.
I did add the RND(1.0)-.6 to give it a little wiggle, but it's not the movement I want.


-=-=-
DNA
Sun, 19 Sep 2010, 17:19
Jayenkai
1. The ranty bit
STOP USING CAPS FOR EVERYTHING. FOR SOME REASON, SINCE WE STARTED USING NICE FONTS ON PC'S, CAPS LOOKS UGLY AS FUCK. SURE, ON AN AMSTRAD, OR A SPECTRUM, IT LOOKS HALF ALRIGHT, BUT NOW THAT WE'VE GOT BOLD AND HIGHLIGHTED SYNTAX, IT JUST LOOKS UGLY AND IS STRANGELY MUCH MORE UNREADABLE THAN IT OUGHTA BE.


2. The important bit
All of your arrays should be set to be Floats..
Dim LikeThis#(123678)
..because if they're int's..
Dim LikeThis(123678)
..the .6 will have no effect. Integers have no decimals, but floats do.
Since you didn't bother to post the dim lines, I can't tell which you used.

3. The "BlitzTipz" bit
Plots, Ovals, Rect are ALL equally annoyingly stupidly slow in Blitz. Well, they're not REALLY slow, but if you're using them to draw loads of dots, like this, it'll get stupidly slow quite quickly.

Instead, create a bunch of little snowflake sprites quickly, at the top of your game, and draw those ( drawimage flakes(rand(20)),x,y ) instead of trying to plot/rect/oval them.

-=-=-
''Load, Next List!''
Sun, 19 Sep 2010, 17:20
dna
Sorry about the Caps. I use them when I type in the code so I can see it better.

I reposted the entire source.

Two other things about the code: (1) I wanted to be able to sweep the mouse across the snow and have a random group of them volumetrically move the direction the mouse was dragged.

The other was the speed of the flakes. If you run the code you can see that sometimes the flakes will slow down because of the processor instead of continuing at the same speed.

Any Suggestions?


-=-=-
DNA
Sun, 19 Sep 2010, 17:42
Jayenkai
Stupid play thing of the day.



I call it "Stirring my straw inside a glass of Coke"

Updated : Version 2!!

-=-=-
''Load, Next List!''
Sun, 19 Sep 2010, 19:34
dna
I do not know what the red bar was for but I see what you meant when you made the flakes.
but the movement I was referring to was a convection within the already undulating particles.
Sort of like the wind, not from the dragging of the mouse. So if you run the code I posted and view the particles, and with them moving in that fashion a mouse drag over a region of the particles, creates a convection of those particles.

** I see. It's a progress bar

** I found that if I use the faster method then I would have to use Maskimage.

-=-=-
DNA