Skip to content

Graphics class

Pegacraffft edited this page Nov 3, 2020 · 2 revisions

Graphics class

This class is another controller class of the engine. It shouldn't be initialised. It handles stuff like rendering and the graphics loop.

1. moveCam(int x, int y)

This method is used to move the camera to a different location on screen. x and y are the top left corner of the cam.

Parameters:

int x: The x position the camera should be set to.

int y: The y position the camera should be set to.

Examples:

//Moves the cam to x: 100, y: 100
Graphics.moveCam(100, 100);

Getter and Setter:

getCamPos()

Returns the camera position as a Point.

screenCenter()

Returns the exact center of the screen as a Point.

Public variables:

g

This variable is the normal Graphics2D object. It is used to render and draw graphics.

Examples:

//Draws a rectangle from x: 0, y: 0 to x: 100, y: 100
Graphics.g.fillRect(0, 0, 100, 100);

stdWidth

This variable sets the standard width, the displays will have.

Example:

//Sets the standard width to 800px
Graphics.g.stdWidth = 800d;

stdHeight

This variable sets the standard height, the displays will have.

Example:

//Sets the standard height to 800px
Graphics.g.stdHeight = 800d;