In true computer programming spirit, I should probably start with "Part 0", so first here are some preliminaries:PulpCore tutorial 0: Getting Started
IDE-specific setup guides:
Bookmark these PulpCore links:
And now, onto the main feature.PulpCore tutorial 1: Stages, Scenes, Sprites, and Hello World
In this tutorial, I explain the test code provided in the "Getting Started with BlueJ" article.
Two core concepts of a PulpCore applet are the Stage
and the Scene
is where an applet is displayed. There is only one Stage per applet. The Stage contains static methods that handle loading, updating, and drawing Scenes. Stage also contains methods for getting the height and width of the applet and setting the frame rate.
is an object that updates the display and handles input from the user. All PulpCore apps must implement at least one Scene.
A typical game will have multiple Scenes, each corresponding to a component of the game: a title scene, main menu scene, main game scene, high score scene, help scene, etc.
The Scene2D class extends the Scene class and provides commonly used features like Sprite management, layer management (layers are Groups of Sprites; typical layers include the background image(s), player/NPC images, and the GUI), and Timeline management (Timelines control animations). Subclasses should override the following two methods:
- load(), which executes when the scene is created, typically where resources are loaded
- update(int), which executes once per frame, typically contains game logic, input handling, etc.
Rendering is handled by the drawScene() method; most apps will not override this method.
The first Scene loaded by an applet is defined by the "scene" applet parameter (in the HMTL file):
<param name="scene" value="MyFirstScene" />
is an image together with location information. PulpCore contains a number of Sprite classes:
- ImageSprite, a standard sprite with an image that is static (CoreImage) or animated (AnimatedImage)
- FilledSprite, a solid-colored rectangle (optionally with a colored border), typically used as background
- Label, a sprite that displays text; image-based fonts may be loaded using the CoreFont class
- some standard user-interface controls: Button, TextField, Slider
- Group, a sprite that is itself a collection of sprites
Sprites are added to a scene using the add() method.
Below is the code for a "Hello World"-style class that illustrates the information above.
public class PulpyDemo extends Scene2D
public void load()
int centerX = Stage.getWidth() / 2;
int centerY = Stage.getHeight() / 2;
background = new FilledSprite(Colors.YELLOW);
helloLabel = new Label(CoreFont.getSystemFont(), "Hello World!", centerX, 40);
logoImage = new ImageSprite(CoreImage.load("logo.png"), centerX, centerY);
public void update(int elapsedTime)
Thanks for reading!