chris.software     development     reviews     feed

Integrating the Engine With Krypton

So far, integration has been going really well. I have played with my infrastructure a bit, and gotten the drawing of the lights to look pretty much exactly how I imagined them. The last thing I’m working out is creating some vertices in the shape of the cone lights I’m using to implement game effects, which is nearly complete. I found an excellent function on Stack Overflow for rotating vectors around points that works great, so I might as well post that code here (thanks to Empyrean):

public static Vector2 RotateVector2(Vector2 point, float radians, Vector2 pivot)
{
    float cosRadians = (float)Math.Cos(radians);
    float sinRadians = (float)Math.Sin(radians);

    Vector2 translatedPoint = new Vector2();
    translatedPoint.X = point.X - pivot.X;
    translatedPoint.Y = point.Y - pivot.Y;

    Vector2 rotatedPoint = new Vector2();
    rotatedPoint.X = translatedPoint.X * cosRadians - translatedPoint.Y * sinRadians + pivot.X;
    rotatedPoint.Y = translatedPoint.X * sinRadians + translatedPoint.Y * cosRadians + pivot.Y;

    return rotatedPoint;
}

I basically sat down for a bit drawing out the problem and figuring out exactly what I needed to do, and then was able to find an answer from that. So once I’ve ironed this out, I’ll have my old functionality back with the lights actually implementing their effects on the player, and then I’ll be ready to keep developing new stuff! My plans are basically as follows:

So that’s some stuff. But to work I go…