psxsdk

scene

Two scenes placed by scene files, cubes over a tile map and the same cubes stacked in a tower, drawn from one archive of textures and models, with a badge in the corner cut from a picture: the program the playground starts from.

Controls

The directions turn the middle cube; Cross stops it turning on its own; Start swaps the scene.

Each scene is a file under scenes/, cooked by mkscene into a DAT on the disc, which package scene reads and places: the camera, the projection, the lights and the tile map are the file's, so the program has nothing of its own to set up and swaps scenes by loading another file. The cube's model, the tiles and the badge's picture are the files under pack/level/, which mkarc packs into ASSETS/LEVEL.ARC, one file to read off the disc, and the scene draws from the archive through scene.NewArchive, unpacking each piece once. The badge's picture is assets/badge.png, which png2tim converts into the archive's directory from the go:generate line below, as the playground does for any picture dropped on it. Each frame the program turns the middle cube by name, draws the scene, the sprite into the overlay so that it stays in front, and prints the scene's name and the two fields the scene gives each object, numbers of the program's own. Editing a scene and regenerating moves everything without a change to the code.

Source on GitHub