Home Artists Posts Import Register

Content

So here's a possibly confusing screenshot of something I'm working on. Currently the animation system for SMS works on timers. So when Jesse is laughing, a laughing timer ticks up and down to various points giving, and the different limbs rotate and animated based on some percentage of that timer. I'm however, not the best at math, and have always found it to be kind of a pain, so the timer I was using was simply increasing by 1 each step. (A step is basically a frame in Game Maker, and one cycle of code) So a 1 second animation would count from 0-29, simply adding 1 each time. Which would be the red line in the image. So I did a bit of research and with the help of a couple of very long in depth articles and a couple hours of experimenting I found an algorithm that would work better then simply adding 1 each time. This new algorithm gave the black wave. As you can see the black line starts to move slowly then drops very quickly the slows down again. So by adding this algorithm to the current animation system all the awkward choppiness of the current animations will smooth out significantly. Honestly I don't fully understand how the math works behind it XD but it works, so I'm not questioning it. I won't be updating all the animations immediately I'll just update them slowly as I feel like it basically. Though as I do that, I'm going to start to implement variable frame rates. So players can set how smooth they want the game to be visually. This will have a huge impact on the current code, but shouldn't be overly complicated to implement. This isn't a priority however so it'll still be a while before you guys can play around with it. (most likely) Big boring nerd post. I dunno if anyone is interested in me posting more stuff like this or not but if you are let me know XD

Files

Comments

Anonymous

I want to hear more stuff like this. Preferably with a bit more explanation as to how the thing works, but seeing as you didn't know in this case, I can't expect an explanation. Hopefully next time.

draite (edited)

Comment edits

2023-03-18 07:12:35 t = Time (the current time) b = Beginning (starting position) c = Change (end position) d = Duration (the length of time) if(t == d) return c; t = t/(d/2); if(t < 1) return (c/2*t*t) + b; else{ t -= 1; return -c/2 * (t*(t-2) -1) + b;} This is the script XD basically my understanding is that if the time is less then half the final duration it's just a matter of squaring the time and multiplying that by the change. But it has to half the change value since it's only calculating for the first half of the timer. The second half ends up sorta inverted, though I don't full understand how the -2 and -1 are altering it to work, but it does XD'
2014-08-12 16:07:58 t = Time (the current time) b = Beginning (starting position) c = Change (end position) d = Duration (the length of time) if(t == d) return c; t = t/(d/2); if(t < 1) return (c/2*t*t) + b; else{ t -= 1; return -c/2 * (t*(t-2) -1) + b;} This is the script XD basically my understanding is that if the time is less then half the final duration it's just a matter of squaring the time and multiplying that by the change. But it has to half the change value since it's only calculating for the first half of the timer. The second half ends up sorta inverted, though I don't full understand how the -2 and -1 are altering it to work, but it does XD'

t = Time (the current time) b = Beginning (starting position) c = Change (end position) d = Duration (the length of time) if(t == d) return c; t = t/(d/2); if(t < 1) return (c/2*t*t) + b; else{ t -= 1; return -c/2 * (t*(t-2) -1) + b;} This is the script XD basically my understanding is that if the time is less then half the final duration it's just a matter of squaring the time and multiplying that by the change. But it has to half the change value since it's only calculating for the first half of the timer. The second half ends up sorta inverted, though I don't full understand how the -2 and -1 are altering it to work, but it does XD'

Anonymous

I got an A in GCSE Maths, which was a whole bunch of algebra. I have no idea what this post was about. Still, interesting to see the coding side of things.

Anonymous

Nerd stuff is a big part of making the game sooo keep em coming! :3

Anonymous

it's decelerating from max to zero speed, but why do you have t-=1? please look here: <a href="http://gizma.com/easing/" rel="nofollow noopener" target="_blank">http://gizma.com/easing/</a>

draite

That's actually where I got the code. =) Well originally I got it from <a href="http://www.robertpenner.com/easing/penner_chapter7_tweening.pdf" rel="nofollow noopener" target="_blank">http://www.robertpenner.com/easing/penner_chapter7_tweening.pdf</a> but had to look it up again since in that article it was converted to work for action script in Flash, not GML.

draite

Good to know ^ ^ I'll try to do a post like this as often as I can.