package com.lloydm.javakogengine_chess; import android.util.Log; class Functions { public static int oseed = 12345678; public static int seed = 12345678; public static int[] seeds = new int[0]; // ///////////////////Method Definition/////////////// public static String ClockTime(int seconds) { int mins = (seconds - (seconds % 60)) / 60; int secs = seconds % 60; return zstr(mins,2) + ":" + zstr(secs,2); } ///////////////////Method Definition/////////////// public static String zstr(int i,int n) { //return an integer number such as 123 as 00123, //i = the number //n = the number of digits to use String s = "" + i; while(s.length()0)//11apr2021 { seed = seeds[seeds.length - 1];//11apr2021 seeds = (int[]) ArrayResize.Resize(seeds,seeds.length - 1); //11apr2021 } else//11apr2021 { seed = oseed;//11apr2021 Log.i(Config.TAG,"Warning:Seeds Out of Sync");//11apr2021 } } ///////////////////Method Definition/////////////// public static float abs(float value) { //absolute value if(value<0) { return -1* value; } return value; } ///////////////////Method Definition/////////////// public static int Rand(int min,int max) { //random number generator return min + (int)(random()*(double)(max-min)); } // ///////////////////Method Definition/////////////// public static int Sign(float value) { //return the sign positive or negative of the number, or zero if(value>0){return 1;} if(value<0){return -1;} return 0; } // ///////////////////Method Definition/////////////// public static int rand(int min,int max) { //random number generator return Rand(min,max); } // ///////////////////Method Definition/////////////// public static int sign(float value) { //alias of Sign return Sign(value); } // ///////////////////Method Definition/////////////// public static double random() { //pseudo random number generator Functions.seed = ((89723453 * Functions.seed + 42854321) % 1000000); double r = ((double)Functions.seed / 1000000.0); if(r<0) { r*=-1.0; } return r; } ///////////////////Method Definition/////////////// public static int isox(int x,int y,int w) { //isometric calculation //pass in the grid square and return a location in screen coordinates return (w/2) * (1 + x - y); } // ///////////////////Method Definition/////////////// public static int isoy(int x,int y,int w) { //isometric calculation //pass in the grid square and return a location in screen coordinates return (w/4) * (1 + y + x); } // ///////////////////Method Definition/////////////// public static int screentoisox(int sx,int sy,int w,int offsetx,int offsety) { //isometric calculation //pass in screen coordinates and convert to iso x grid sx-=offsetx; sy-=offsety; return (int)((((float)sx + 2f * (float)sy)/(float)w) - 1f); } // ///////////////////Method Definition/////////////// public static int screentoisoy(int sx,int sy,int w,int offsetx,int offsety) { //isometric calculation //pass in screen coordinates and convert to iso y grid sx-=offsetx; sy-=offsety; return (int)((2f*(float)sy - (float)sx)/(float)w); } }