Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Quick Start

Vrekt edited this page Jul 19, 2018 · 2 revisions

Here you will learn how get setup with Stellar to start creating your game!

The GameManager

The GameManager holds everything necessary for your game. Things like the window, drawing, and the stack. The stack is a list of GameStates which hold methods for updating and drawing your game, we'll learn more about that later.

To start, initialize a new GameManager with these parameters.

GameManager manager = new GameManager(windowTitle, windowWidth, windowHeight, myPreferences, myDrawType, TICK_RATE);

Here is an example with my parameters.

GameManager manager = new GameManager("GameTest", 800, 600, WindowPreferences.defaultTemplate(), GameWindow.DrawType.WINDOW, 60);

windowTitle: This is the title of the window.

windowWidth, windowHeight: These parameters indicate the dimensions of the game window.

myPreferences: These are settings to define your window, to keep the default settings use: WindowPreferences.defaultTemplate().

myDrawType: This is the drawing method to use. Available options are: WINDOW, PANEL.

Drawing directly to the window allows for triple-buffering, but the whole window is considered the canvas (including title and side bars.)

The advantages of using a panel is its the most preferred way of drawing and does not interfere with the side/title bars.

TICK_RATE: This is how fast to run the game-loop.

GameStates

As mentioned before GameStates are the base of your game and include methods to update/draw whatever is needed.

To create a new GameState simply implement the GameState interface.

public class TestState implements GameState {

Make sure to implement its methods, and that's it!

Starting the game

Next, we can push the TestState we created. When you push a new GameState it will be added to a list allowing it to be invoked for tick/drawing updates.

manager.push(new TestState());

Finally, we can start the game.

manager.start();
Clone this wiki locally