Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1056931 Posts in 42931 Topics- by 34879 Members - Latest Member: BatFastard

October 24, 2014, 10:44:54 AM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)movement like this?
Pages: [1]
Print
Author Topic: movement like this?  (Read 552 times)
cubertron
Level 0
***


View Profile Email
« on: March 23, 2013, 12:14:31 PM »

http://examples.oreilly.com/0636920000570/interactive_examples/index.php?example=Ex_07_13

Can anyone tell how can I code the wavy movement in the link above?Any equation for that?I can't really figure out how its done
Logged
ChevyRay
Level 2
**



View Profile WWW Email
« Reply #1 on: March 23, 2013, 12:42:59 PM »

What language are you using? Coding motion like that would take a sine wave Smiley

Here's a live actionscript example if you're interested!

http://wonderfl.net/c/dt8v

I use a function (usually in my engine's global "Math" class), called wave() to do this. Basically I can tell a value ("y" in this case) to "wave" between a beginning and end value over a certain period of time.
« Last Edit: March 23, 2013, 12:48:27 PM by ChevyRay » Logged

Unity Patterns - Tools & Resources for Unity Developers
FlashPunk - 2D Flash Game Engine
kamac
Level 10
*****


Notorious posts editor


View Profile Email
« Reply #2 on: March 23, 2013, 02:15:21 PM »

Basically, here's the formula:

ballY[n] = sin(time * frequency + float(n + 1)/5) * height;

(You should fool around with that (n+1) though, as it is supposed to shift sine wave, so that each ball has slightly different height as seen on example)
Logged

Nothing to do here
cubertron
Level 0
***


View Profile Email
« Reply #3 on: March 23, 2013, 09:09:13 PM »

What language are you using? Coding motion like that would take a sine wave Smiley

Here's a live actionscript example if you're interested!

http://wonderfl.net/c/dt8v

I use a function (usually in my engine's global "Math" class), called wave() to do this. Basically I can tell a value ("y" in this case) to "wave" between a beginning and end value over a certain period of time.

Thanks kamac and chevy(for the live example) it worked like charm. Using Java but translated the code. What topic should I read to clear these things out, I really don't use mathematics in my games  Gomez
Logged
JakobProgsch
Level 1
*



View Profile Email
« Reply #4 on: March 24, 2013, 06:02:26 AM »

How can you "not use mathematics in a game"... just programming along requires some basic understanding of algebra *duck*
Logged

cubertron
Level 0
***


View Profile Email
« Reply #5 on: March 24, 2013, 09:05:02 AM »

How can you "not use mathematics in a game"... just programming along requires some basic understanding of algebra *duck*

I have but only the basic (distance b/w two objects, angle) , any tutorials on mathematics involved in game programming?
Logged
Rahrahrah
Level 1
*



View Profile
« Reply #6 on: March 24, 2013, 12:57:53 PM »

Heyo cubetron..  I have about 4 months under my belt now.  I am an art school drop out after that spent a few years in a local universities C.S. program.  Didn't finish that either..

Um... finishing is like the number one rule I've found when it comes to this game making stuff.  And I am doing my damned'est to do so.  I also have accumulated a few books I own in these 4 months.  Libraries and internets being the best things, but sometimes books in my lap with my ass planted in a comfy chair and something to drink besides it works great.

For moving anything, and especially with Maths I really like the book 'Actionscript 3.0 Animation by Keith Peters'  Good Math funs in there.  And you will get the sin wave presentation in there making super clear sense.  Before long sin waves, and arc tangent functions will just roll right off the top of your head.

I can think of all the many objects I've looted that had a sine wave attached to them.. heheheheh.

Get in there and dig around.
Logged

Trying more and more to relate less and less to Sisyphus.
Austiyn
Guest
« Reply #7 on: March 26, 2013, 04:36:28 PM »

You most definitely need math in games. How the hell do you change the speed of you're character? Or check for collision?
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic