Skip to content

Hello World

Nick Donnelly edited this page Aug 13, 2021 · 2 revisions

The simplest way to get started is to use the MinvioApp class, below is a basic example you can use to get started.

public class MinvioAppExample extends MinvioApp {

    int x = 0;

    public static void main(String... args) {
        MinvioApp app = new MinvioAppExample();
        app.start(new BasicDisplayAwt(600, 300), "Minvio App Example", 30);
    }

    @Override
    public void draw(BasicDisplay bd, double delta) {
        x++;
        if (x > 200) x = 0;
        bd.cls(new Color(207, 198, 179));
        bd.setDrawColor(new Color(17, 52, 69, 215));
        bd.drawText("Hello, World", x, 100);
    }
}

Create the app class by extending MinvioApp:

public class MinvioAppExample extends MinvioApp {

MinvioApp only has one method that must be implemented - the draw() method, however there are some other methods that could be useful depending on your use-case, init() and update().

To start up the program, we create a main method as follows, creating an instance of the containing class. We then start the main loop bay calling app.start, in which we pass a newly created instance of BasicDisplayAwt. app.start starts a loop that will call the draw() function 30 times per second, we create our draw function in the next step.

    public static void main(String... args) {
        MinvioApp app = new MinvioAppExample();
        app.start(new BasicDisplayAwt(600, 300), "Minvio App Example", 30);
    }

Clone this wiki locally