CLOSE

Archive:

2023
2022
2021
2020
2019
2018
2017
2016
Subscribe:Atom Feed

"Devlog: Curves"

Posted: 23 September, 2017

I’m in the process of packing up my life for the move back to Tampere, so this will be the last catch-up blog until I’m setup again. Meh.

Neutrino

I’ve done a fair bit more work on this, due to travel, downtime waiting for estate agents and the start of the new Semester at University. The “big” new item is the curve editor.

I want the enemies to have pretty varied attack patterns, and although a lot of this could be done with the judicious use of Sine, you can’t beat having a decent spline to hand.

There’re a few ways you can do this, but I’ve opted for chaining cubic Bézier curves together, as the maths is about my level.

Maths.... Ugh

Or, in code:

{% highlight c %}

glm::vec2 CalculateBezierPoint(const float t, const glm::vec2* p0, const glm::vec2* p1, const glm::vec2* p2, const glm::vec2* p3) { float fT = clamp(t, 0.0f, 1.0f); float u = 1 — fT; float tt = fTfT; float uu = uu; float uuu = uu * u; float ttt = tt * fT; glm::vec2 p = glm::vec2(uuu * *p0); p += 3 * uu * t * *p1; p += 3 * u * tt * *p2; p += ttt * *p3; return p; }

{% endhighlight %}

ImGui has been a lifesaver, again, as it took very little time to put together enough UI to load, save and edit curves. There’s no real limit to the number of curves I can chain together, but in practice, two or three is more than enough. It’s simple, but it works.

Fancy Gif

The other nice addition to Neutrino, as you can see above, is embedded .GIF output. Totally stole this idea from Philip Bak, but it makes perfect sense; in a world where you need to fire out screenshots on social media as often as possible, what could be better than pressing a button and getting an animated .GIF, resized for Twitter?

We both opted to use this single header lib from Charlie Tangora. 3 function calls and Bob’s your mother’s brother. Perfect.

Other stuff that’s been done:

Anyway, I better get back to packing boxes ;D