Space Invaders

The classic game Space Invaders, without GUI.
This commit is contained in:
Fernando Méndez
2020-09-17 20:06:49 +02:00
committed by GitHub
parent 08097b1ba0
commit 1d271afe24
49 changed files with 3086 additions and 0 deletions

View File

@ -0,0 +1,24 @@
package tp.p2.util;
/**
* @author Fernando M<>ndez Torrubiano
*
*/
public class MyStringUtils {
public static String repeat(String elmnt, int length) {
String result = "";
for (int i = 0; i < length; i++) {
result += elmnt;
}
return result;
}
public static String centre(String text, int len){
String out = String.format(" %"+len+"s %s %"+len+"s", "",text,"");
float mid = (out.length()/2);
float start = mid - (len/2);
float end = start + len;
return out.substring((int)start, (int)end);
}
}