Interesting development:
I revisited the problem and tried to solve it by doing my own manual calculation instead of using the GetWorldFromSprite commands and unfortunately it produces the same results!
So first I calculate the current X,Y "heading direction" of the ship (x = cosine of the sprite angle, and y = sin of the sprite angle) then attempt to place the particles at the sprite center "minus" the offset amount multiplied by the heading direction. The result is exactly the same as using GetWorldFromSprite, just like the second video in the original post.. looking at the resulting behavior it seems like the Y value is pretty well correct, hence the correct thruster position at top dead center and bottom dead center, so it seems like it's the X value that needs some adjustment..
SOLVED: Finally got this one figured out. I had to divide the X component of the "heading" by the display aspect ratio (1.77 in this case) and it works!
// Includes
#include "template.h"
// Namespace
using namespace AGK;
app App;
int sprite = 0;
int follow = 0;
void app::Begin(void)
{
agk::SetDisplayAspect(1.77);
agk::SetSyncRate(60, 0);
sprite = agk::CreateSprite(0);
agk::SetSpriteSize(sprite, -1, 20);
agk::SetSpritePositionByOffset(sprite, 50, 50);
follow = agk::CreateSprite(0);
agk::SetSpriteSize(follow, -1, 2);
}
int app::Loop(void)
{
// METHOD #1 - NOT WORKING
//agk::SetSpritePosition(follow, agk::GetWorldXFromSprite(sprite, 0, 15), agk::GetWorldYFromSprite(sprite, 0, 15));
// METHOD #2 - MANUAL CALCULATION OF SPRITE "HEADING"
float dx = cos(agk::GetSpriteAngleRad(sprite));
float dy = sin(agk::GetSpriteAngleRad(sprite));
dx /= agk::GetDisplayAspect(); // THIS LINE SOLVES THE PROBLEM
agk::SetSpritePosition(follow, agk::GetSpriteXByOffset(sprite) - (15 * dx), agk::GetSpriteYByOffset(sprite) - (15 * dy));
// KB INPUT TO ROTATE THE SPRITE
if (agk::GetRawKeyState(65)) agk::SetSpriteAngle(sprite, agk::GetSpriteAngle(sprite) - 2);
if (agk::GetRawKeyState(68)) agk::SetSpriteAngle(sprite, agk::GetSpriteAngle(sprite) + 2);
agk::Sync();
return 0;
}
void app::End(void)
{
}
Note: If you port this example code to tier 1 you'll have to make one minor change. The cos function in C++ takes radians while the cos function in AppGameKit takes degrees. So change the two occurences of GetSpriteAngleRad to just GetSpriteAngle