Don't go outside the screen (memory corruptions)

This commit is contained in:
2022-08-02 12:51:59 +02:00
parent f4973bdf84
commit 9590362bec
4 changed files with 42 additions and 40 deletions

View File

@@ -8,14 +8,15 @@ bool FlipScreen( SDL_Surface * Screen );
struct xyz {
int x, y, z;
} CursorPos, Camera;
};
/*** Thanks to <https://gist.github.com/jordwest/8a12196436ebcf8df98a2745251915b5> for the maths! ***/
struct xyz OrthoToIso ( int x, int z, int Multiply ) {
struct xyz OrthoToIso ( int x, int y, int z, int Multiply ) {
struct xyz xyz;
xyz.x = x * 1 * 0.5 * Multiply + z * -1 * 0.5 * Multiply;
xyz.z = x * 0.5 * 0.5 * Multiply + z * 0.5 * 0.5 * Multiply;
xyz.y = xyz.z;
return xyz;
}