Skip to content

Commit b076008

Browse files
committed
[godoc] Add more info to pi.Load
1 parent af6d78c commit b076008

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

pi.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,21 @@ var Time float64
6565

6666
var GameLoopStopped bool
6767

68-
// Load loads files like sprite-sheet.png, custom-font.png
68+
// Load loads files: sprite-sheet.png and custom-font.png from resources parameter.
6969
//
70-
// Load looks for resources with specific names in the resources parameter, eg "sprite-sheet.png".
70+
// Load looks for images with hard-coded names, eg for sprite-sheet it loads "sprite-sheet.png".
71+
// Your file name must be exactly the same. And it cannot be inside subdirectory.
72+
//
73+
// sprite-sheet.png file must have an indexed color mode. This means that pixels in the sprite-sheet
74+
// file refers to an index of the color defined in a small palette, also attached to the file in a
75+
// form of mapping: index number->RGB color. Image must have an indexed color mode,
76+
// because Pi loads the palette from the sprite-sheet.png file itself. Please use a pixel-art editor
77+
// which supports indexed color mode, such as Aseprite (paid) or LibreSprite (free). Sprite-sheet
78+
// width and height must be multiplication of 8.
79+
//
80+
// custom-font.png must also have an indexed color mode. Color with index 0 is treated as background.
81+
// Any other color as foreground. The size of the image is fixed. It must be 128x128. Each char is 8x8.
82+
// Char 0 is in the top-left corner. Char 1 to the right.
7183
//
7284
// To acquire the resources object, the easiest way is to include the resources in the game binary
7385
// by using go:embed directive:

sprite_sheet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ func SprSheet() PixMap {
5858

5959
func newSpriteSheet(w int, h int) spriteSheet {
6060
if w%8 != 0 || w == 0 {
61-
panic(fmt.Sprintf("sprite sheet width %d is not a multiplcation of 8", w))
61+
panic(fmt.Sprintf("sprite sheet width %d is not a multiplication of 8", w))
6262
}
6363
if h%8 != 0 || h == 0 {
64-
panic(fmt.Sprintf("sprite sheet height %d is not a multiplcation of 8", h))
64+
panic(fmt.Sprintf("sprite sheet height %d is not a multiplication of 8", h))
6565
}
6666

6767
size := w * h

0 commit comments

Comments
 (0)