[DEVLOG] Cutielympics, a game jam entry

Not sure if that counts as “simple”, but I’m using an iterative way for replacing arctan2 in Escarmouche:

here
  • You have an angle ANGLE, relative to the world’s angle (so 0 means you look to the right, 180 to the left, 90 to the top. Might be different depending on your coordinate system, especially with Y sign)
  • You have a target vector (from Dest to Target, DEST_TO_TARGET)
  • You get the ANGLE’s vector, using fast cos/sin, ANGLE_VECTOR (if ANGLE is 0, you’ll get 1, 0)
  • You calculate the 2D cross product of ANGLE_VECTOR with DEST_TO_TARGET, assign to LATERAL_DEVIATION : ANGLE_VECTOR.x * DEST_TO_VECTOR.y - ANGLE_VECTOR.y * DEST_TO_VECTOR.x

Now, it gets very interesting:

  • if LATERAL_DEVIATION is 0, both ANGLE_VECTOR and DEST_TO_TARGET are perfectly aligned.
  • If LATERAL_DEVIATION is negative, (for instance, DEST_TO_VECTOR is 1, 0, and ANGLE_VECTOR is 0.9, 0.1), that means your ANGLE_VECTOR is actually to far on the left.
    • So you subtract an increment for your angle.
  • If LATERAL_DEVIATION is positive, (for instance, DEST_TO_VECTOR is 1, 0, and ANGLE_VECTOR is 0.9, -0.1), that means your ANGLE_VECTOR is actually to far on the right.
    • So you add an increment for your angle.

All of these only use a lookup table (cos/sin), 2 multiplications, some addition/substraction, comparisons and PoT divisions (but not necessarily if you’re clever enough).

  • With only an additional multiplication+comparison involving LATERAL_DEVIATION, you can know if the angle between both vectors is greater or lower than a given angle - because it’s then a ratio.
    • I use it to make the units rotate slower when they need to “aim”.
    • Also, units don’t move “toward” if their not “facing enough” their target. This to avoid the “waltz bug” where everyone rotate around each others :laughing:
  • It’s excellent for rotating once or twice per frame. Getting an exact angle can be done with this too, but a direct lookup table might be best.

(btw, you can also use the dot product to know if you’re looking toward or away from a target!)

Think of it as a robot following a line using with 2 color sensors.
Because it’s iterative, it’s excellent for Escarmouche - units rotate slowly toward their target then seek it. With a few iterations it can completely replace a proper arctan2, but lookup tables might be more interesting for you

1 Like

Thanks! I will dig into that when I need a proper arctan() function in MP. For now I will use the lookup table.

I briefly looked into some of the more complicated functions when implementing my fixed points library, but I didn’t look at arctan/atan.

I had a quick look around and it looks like there’s a decent handful of identities you can use to simplify matters.

I found some source code for a floating point implementation of atan2 written in C by SunSoft in 1993, and there’s a list of special cases from which it’s possible to derive some special cases that would be valid for fixed point arithmetic.

(The original mentions negative zero, NaN and both forms of infinity, which naturally aren’t relevant for fixed points.)

  • atan2(0, x) is 0
  • atan2(0, -x) is pi
  • atan2(nonzero, 0) is pi/2
  • atan2(-nonzero, 0) is -pi/2

I’m having to make a bit of a leap of logic with these though. The original lists the first argument and the result with ±, which doesn’t make it clear whether a negative input forms a negative result (and vice versa) or whether a negative input forms a positive result (and vice versa).

The file’s quite small, so I’ll leave a copy here in case you find it useful: e_atan2.c (3.6 KB)

Devlog #9

The initial javelin sport using the lookup table to resolve the angle using arctan().

tetrathlon_javelin1

7 Likes

I think that looks perfect.

3 Likes

Looks smooth and authentic

1 Like

Your entry looks really great!
Probably the javelin should already be at a starting angle and not horizontal while running.
Will be possibile to adjust the trowing angle like in Track and Fields?
The more you keep presse the trowing button the more the angle rise…

2 Likes

Thanks :slightly_smiling_face:

I can try that.

Yes, absolutely!

2 Likes

Devlog #10

Selecting the angle for the spear.

3 Likes

That looks like team Finland in Tokio

1 Like

I really badly want to play this!

1 Like

Devlog #11

Added the final event: Hurdles
tetrathlon_hurdles2

Yes, that have to be final, because I realised that otherwise I will not get this ready in time!

That means also that the name cannot be “Tetrathlon”. Also “Triathlon” is “taken”.

So, any suggestions for the new name?

6 Likes

Maybe… Hamster Olympics :smiley:

2 Likes

Really nailing the cute factor! And seems to be simple enough for all ages to play! :+1:

Not sure about the name…

Furries Challenge
Sports “FUR” Pokitto
Adorable Critters Olympics
Lets Move: Hamster Edition

LOL

2 Likes

Cutelympics?

1 Like

Furlympics?

2 Likes

For the sake of searching, I wouldn’t put too much “fur” in titles. Just saying :eyes:

5 Likes

Hamster Summer Games?
Ultimate Hamster Sports Challenge?

Fluffy Sports?

1 Like

Olympets Games :laughing:

4 Likes

Looks like I might not get the entry ready by this week. I am busy with other business this week :frowning: