Getting Started
Follow the steps below to run your first game.
Get Playfield Engine
Download
- Download the latest All-in-One ZIP of Playfield Engine from the website.
- Extract the ZIP file to any folder you like.
On Windows:
- Double-click
playfield.exe. - The sample game will start automatically.
On macOS:
- Open
misc/macos/Playfield.dmg. - Copy the
Playfieldapp from the DMG into the same folder asplayfield.exe. - Double-click the
Playfieldapp to run the sample game.
On Linux:
- Copy
misc/linux/Playfield-x86_64.AppImageinto the same folder asplayfield.exe. - Make the AppImage executable if necessary (
chmod +x Playfield-x86_64.AppImage). - Double-click the AppImage to run the sample game.
Making a First Game
To create a minimal game:
- Make a new folder anywhere you like.
- Open your favorite text editor in that folder.
- Create a new file called
main.pf. - Copy the following code into to the file an save it.
// Called when the window is created.
func setup() {
// Return the window configuration.
return {
width: 1280,
height: 720,
title: My First Game
};
}
// Called once when the game starts.
func start() {
// Create a white 100x100 texture.
tex = Engine.createColorTexture({
width: 100,
height: 100,
r: 255, g: 255, b: 255, a: 255
});
}
// Called every frame before rendering.
func update() {
posX = Engine.mousePosX;
posY = Engine.mousePosY;
}
// Called every frame to render graphics.
func render() {
Engine.draw({ texture: tex, x: posX, y: posY });
}
Running Games
Playfield Engine can load a game in two ways:
- From a folder that contains a
main.pffile. - From an
assets.pakfile that bundles all game assets.
To create an assets.pak file, see Distributing Games.