Skip to content

Commit 781a8e2

Browse files
committed
[godoc] Update docs
1 parent 376b235 commit 781a8e2

File tree

6 files changed

+42
-11
lines changed

6 files changed

+42
-11
lines changed

image/image.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Image struct {
2424
Pixels []byte
2525
}
2626

27+
// String returns Image as string for debugging purposes.
2728
func (i Image) String() string {
2829
return fmt.Sprintf("{width:%d, height:%d, palette: %+v, pixels:%s}",
2930
i.Width, i.Height, sfmt.FormatBigSlice(i.Palette[:], 32), sfmt.FormatBigSlice(i.Pixels, 1000))

pi.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,31 @@
33

44
// Package pi provides API to develop retro games.
55
//
6+
// Like other game development engines, Pi runs your game in a loop:
7+
//
8+
// for {
9+
// pi.Update()
10+
// pi.Draw()
11+
// sleep() // sleep until next frame (30 frames per second)
12+
// }
13+
//
14+
// Both pi.Update and pi.Draw functions are provided by you. By default,
15+
// they do nothing. You can set them by using:
16+
//
17+
// pi.Draw = func() {
18+
// pi.Print("HELLO WORLD", 40, 60, 7)
19+
// }
20+
//
21+
// To run the game please use the ebitengine back-end by calling
22+
// ebitengine.Run or ebitengine.MustRun.
23+
//
24+
// During development, you might want to use dev-tools which provide tools
25+
// for screen inspection and REPL terminal, where you can write Go code
26+
// live when your game is running. To start the game with dev-tools
27+
// please use:
28+
//
29+
// devtools.MustRun(ebitengine.Run)
30+
//
631
// Please note that the entire pi package is not concurrency-safe.
732
// This means that it is unsafe to run functions and access package
833
// variables from go-routines started by your code.
@@ -15,7 +40,7 @@ import (
1540
"github.com/elgopher/pi/font"
1641
)
1742

18-
// User parameters.
43+
// User parameters
1944
var (
2045
// Update is a user provided function executed each frame (30 times per second).
2146
//
@@ -38,6 +63,7 @@ var (
3863
Palette = defaultPalette
3964
)
4065

66+
// Global state
4167
var (
4268
// DrawPalette contains mapping of colors used to replace color with
4369
// another one for all subsequent drawings.

pixmap.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ type PixMap struct {
2727
wholeLinePix []byte
2828
}
2929

30-
func (p PixMap) String() string {
31-
return fmt.Sprintf("{width:%d, height:%d, clip:%+v, pix:%s}",
32-
p.width, p.height, p.clip, sfmt.FormatBigSlice(p.pix, 1024))
33-
}
34-
3530
// NewPixMap creates new instance of PixMap with specified size.
3631
// Width and height cannot be negative.
3732
func NewPixMap(width, height int) PixMap {
@@ -378,3 +373,9 @@ func addY(p Pointer, n int, lineWidth int) Pointer {
378373
p.Pix = p.Pix[n*lineWidth:]
379374
return p
380375
}
376+
377+
// String returns PixMap as string for debugging purposes.
378+
func (p PixMap) String() string {
379+
return fmt.Sprintf("{width:%d, height:%d, clip:%+v, pix:%s}",
380+
p.width, p.height, p.clip, sfmt.FormatBigSlice(p.pix, 1024))
381+
}

print.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ type Font struct {
6262
Height int
6363
}
6464

65-
func (f Font) String() string {
66-
return fmt.Sprintf("{width: %d, specialWidth: %d, height: %d, data: %s}",
67-
f.Width, f.SpecialWidth, f.Height, sfmt.FormatBigSlice(f.Data, 512))
68-
}
69-
7065
// Print prints text on the screen at given coordinates. It takes into account
7166
// clipping region and camera position.
7267
//
@@ -132,6 +127,12 @@ func (f Font) printRune(r rune, sx, sy int, color byte) int {
132127
}
133128
}
134129

130+
// String returns Font as string for debugging purposes.
131+
func (f Font) String() string {
132+
return fmt.Sprintf("{width: %d, specialWidth: %d, height: %d, data: %s}",
133+
f.Width, f.SpecialWidth, f.Height, sfmt.FormatBigSlice(f.Data, 512))
134+
}
135+
135136
// Print prints text on the screen using system font. It takes into consideration
136137
// clipping region and camera position.
137138
//

screen.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ func PalReset() {
219219
DisplayPalette = notSwappedPalette
220220
}
221221

222+
// Scr returns the Screen PixMap
222223
func Scr() PixMap {
223224
return screen
224225
}

sprite_sheet.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type spriteSheet struct {
6060
spritesInLine int
6161
}
6262

63+
// SprSheet returns the sprite-sheet PixMap
6364
func SprSheet() PixMap {
6465
return sprSheet.PixMap
6566
}

0 commit comments

Comments
 (0)