JavaBase API
A lightweight, turtle-graphics based game engine for Java.
JavaBase API
Eine leichtgewichtige, Turtle-Grafik basierte Spiele-Engine für Java.
Getting Started
Erste Schritte
JavaBase is a minimal framework that provides a 60 FPS game loop and a center-oriented coordinate system. It uses Turtle Graphics logic (drawing by moving a pen) alongside modern helper methods for shapes and text.
JavaBase ist ein minimales Framework, das einen 60-FPS-Game-Loop und ein zentriertes Koordinatensystem bietet. Es nutzt die Logik der Turtle-Grafik (Zeichnen durch Bewegen eines Stifts) zusammen mit modernen Hilfsmethoden für Formen und Text.
public class MyGame extends CoreGame {
public void start() { /* Setup */ }
public void draw() { /* Render */ }
public void input(Input in) { /* Logic */ }
}
package engine.core
public abstract class CoreGame
The base class for your game. All drawing coordinates are relative to the center of the screen (0,0).
Die Basisklasse für Ihr Spiel. Alle Zeichenkoordinaten beziehen sich auf die Mitte des Bildschirms (0,0).
| Method | Methode | Description | Beschreibung |
|---|---|---|---|
start() | Called once when the window opens. | ||
draw() | Called every frame. Use drawing commands here. | ||
input(Input in) | Called before draw. Use for logic and movement. | ||
moveTo(x, y) | Moves pen to absolute coordinate. Draws if pen is down. | ||
move(dx, dy) | Moves pen relative to current position. | ||
penUp() / penDown() | Toggle whether movement leaves a trail. | ||
color(Color c) | Sets the current drawing color. | ||
setThickness(float t) | Sets line width (Stroke). | ||
drawCircle(r, filled) | Draws a circle at the current pen position. | ||
drawRect(w, h, filled) | Draws a rectangle at current position. | ||
drawText(str, x, y) | Draws text at specified coordinates. |
package engine.input
public class Input
Polling system for user interaction.
Abfragesystem für Benutzerinteraktionen.
// Inside input(Input in)
if (in.isUp()) { /* W or Arrow Up */ }
if (in.isKey(KeyEvent.VK_E)) { /* Custom key */ }
int mx = in.getMouseX(); // 0 is center
Simple Example: Neon Circle
Einfaches Beispiel: Neon-Kreis
This simple script draws a glowing circle that follows the mouse.
Dieses einfache Skript zeichnet einen leuchtenden Kreis, der der Maus folgt.
@Game(name = "Neon Mouse")
public class NeonFollower extends CoreGame {
double x, y;
@Override
public void start() {
setFontSize(20);
}
@Override
public void input(Input input) {
// Move towards mouse
x += (input.getMouseX() - x) * 0.1;
y += (input.getMouseY() - y) * 0.1;
}
@Override
public void draw() {
clear();
// Draw Neon Glow
color(new Color(0, 255, 255, 100));
setThickness(10);
moveTo(x, y);
drawCircle(40, false);
// Draw Core
color(Color.WHITE);
setThickness(2);
drawCircle(40, false);
drawText("FOLLOWING MOUSE", -70, 250);
}
}