it is done
This commit is contained in:
21
core/src/mindustry/world/Pos.java
Normal file
21
core/src/mindustry/world/Pos.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package mindustry.world;
|
||||
|
||||
/** Methods for a packed position 'struct', contained in an int. */
|
||||
public class Pos{
|
||||
public static final int invalid = get(-1, -1);
|
||||
|
||||
/** Returns packed position from an x/y position. The values must be within short limits. */
|
||||
public static int get(int x, int y){
|
||||
return (((short)x) << 16) | (((short)y) & 0xFFFF);
|
||||
}
|
||||
|
||||
/** Returns the x component of a position. */
|
||||
public static short x(int pos){
|
||||
return (short)(pos >>> 16);
|
||||
}
|
||||
|
||||
/** Returns the y component of a position. */
|
||||
public static short y(int pos){
|
||||
return (short)(pos & 0xFFFF);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user