feat: ajout une classe pour les inits de base

This commit is contained in:
2025-11-01 20:09:18 +01:00
parent 78ad5d3491
commit 5121e25e46
2 changed files with 24 additions and 4 deletions

20
src/GFactory.java Normal file
View File

@@ -0,0 +1,20 @@
public class GFactory
{
public static Game defaultInit()
{
Integer[][] map = new Integer[][] {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -1, -1, 5, 0 },
{ 0, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 0, 0, -1, 0, 0, -1, 0 },
{ 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0 },
{ 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0 },
{ 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -1, -1, 2, 0, 0, -1, 0 },
{ 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 },
{ 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 },
{ 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -3, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
};
return Game.getInstance().init(3, Map.fromInts(map));
}
}

View File

@@ -7,7 +7,8 @@ public class Main {
}); });
Thread t = new Thread(() -> { Thread t = new Thread(() -> {
while (true) int i = 0;
while (i++ < 10)
{ {
try try
{ {
@@ -17,13 +18,12 @@ public class Main {
{ {
e.printStackTrace(); e.printStackTrace();
} }
System.out.println(Game.create().togglePause() ? "stop" : "fini"); System.out.println(Game.getInstance().togglePause() ? "stop" : "fini" );
} }
}); });
t.start(); t.start();
Game.create() Game.getInstance()
.init(3, m)
.run(); .run();
} }
} }