Created
October 14, 2020 20:38
-
-
Save Mr00Anderson/8216b26a6fd5510a67846db49d580712 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.virtual_hex.gdx.engine.maps; | |
public class TwoDIndexCalculation { | |
public static int rowMajorYTopLeft(int x, int y, int width){ | |
return (width * x) + y; | |
} | |
public static int rowMajorYBottomLeft(int x, int y, int height, int indexHeight, int arrayLastIndex){ | |
int indexY = indexHeight - y; | |
return arrayLastIndex - ((height * x) + indexY); | |
} | |
public static int rowMajorTopRight(int x, int y, int width, int indexHeight){ | |
int indexY = indexHeight - y; | |
return (width * x) + indexY; | |
} | |
public static int colMajorYTopLeft(int x, int y, int width){ | |
return (width * y) + x; | |
} | |
public static int colMajorYBottomLeft(int x, int y, int width, int indexHeight){ | |
int indexY = indexHeight - y; | |
return (width * indexY) + x; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment