Search in sources :

Example 1 with Mindustry

use of io.anuke.mindustry.Mindustry in project Mindustry by Anuken.

the class DesktopLauncher method main.

public static void main(String[] arg) {
    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    config.setTitle("Mindustry");
    config.setMaximized(true);
    config.setWindowedMode(960, 540);
    config.setWindowIcon("sprites/icon.png");
    Platform.instance = new DesktopPlatform(arg);
    Net.setClientProvider(new KryoClient());
    Net.setServerProvider(new KryoServer());
    try {
        new Lwjgl3Application(new Mindustry(), config);
    } catch (Throwable e) {
        CrashHandler.handle(e);
    }
}
Also used : Mindustry(io.anuke.mindustry.Mindustry) KryoServer(io.anuke.kryonet.KryoServer) Lwjgl3Application(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application) Lwjgl3ApplicationConfiguration(com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration) KryoClient(io.anuke.kryonet.KryoClient)

Example 2 with Mindustry

use of io.anuke.mindustry.Mindustry in project Mindustry by Anuken.

the class HtmlLauncher method createApplicationListener.

@Override
public ApplicationListener createApplicationListener() {
    instance = this;
    setLogLevel(LOG_NONE);
    setLoadingListener(new LoadingListener() {

        @Override
        public void beforeSetup() {
        }

        @Override
        public void afterSetup() {
            scaleCanvas();
            setupResizeHook();
        }
    });
    Net.setClientProvider(new WebsocketClient());
    Platform.instance = new Platform() {

        DateTimeFormat format = DateTimeFormat.getFormat("EEE, dd MMM yyyy HH:mm:ss");

        @Override
        public String format(Date date) {
            return format.format(date);
        }

        @Override
        public String format(int number) {
            return NumberFormat.getDecimalFormat().format(number);
        }

        @Override
        public boolean canJoinGame() {
            String ref = Document.get().getReferrer();
            return !ref.startsWith("https") && !ref.contains("itch.io");
        }

        @Override
        public byte[] getUUID() {
            Settings.defaults("uuid", "");
            String uuid = Settings.getString("uuid");
            if (uuid.isEmpty()) {
                byte[] result = new byte[8];
                new Random().nextBytes(result);
                uuid = new String(Base64Coder.encode(result));
                Settings.putString("uuid", uuid);
                Settings.save();
                return result;
            }
            return Base64Coder.decode(uuid);
        }
    };
    return new Mindustry();
}
Also used : Mindustry(io.anuke.mindustry.Mindustry) Platform(io.anuke.mindustry.io.Platform) Random(java.util.Random) Date(java.util.Date) DateTimeFormat(com.google.gwt.i18n.shared.DateTimeFormat)

Aggregations

Mindustry (io.anuke.mindustry.Mindustry)2 Lwjgl3Application (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application)1 Lwjgl3ApplicationConfiguration (com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration)1 DateTimeFormat (com.google.gwt.i18n.shared.DateTimeFormat)1 KryoClient (io.anuke.kryonet.KryoClient)1 KryoServer (io.anuke.kryonet.KryoServer)1 Platform (io.anuke.mindustry.io.Platform)1 Date (java.util.Date)1 Random (java.util.Random)1