-
Notifications
You must be signed in to change notification settings - Fork 1
Keeping the Window Open
Let's expand on just opening a Window:
import dgt;
void main()
{
Window window = Window("Your First Window", 800, 600, WindowConfig());
while(window.isOpen)
{
window.begin(Color.white);
window.end();
}
}
A window should open up with a white background and it should pretty much do nothing, except close when you ask it to.
while(window.isOpen) does what you might expect: loops while the window is still open. The window will close if you click the 'X' button or for platform-specific things: Alt-F4 is the preferred wait to close on Windows but on macOS you would use CMD-Q. This line takes care of all that for you.
window.begin(Color.white) starts each iteration of our game loop. The parameter, Color.white, defines the clear color. This means any portion of the window not covered when we draw things (which we'll get to later) will be white.
window.end() ends our iteration of the loop. If we did any drawing, this is where it would get displayed on the screen.