Skip to content

Commit

Permalink
Move pi.Palette to palette.go file
Browse files Browse the repository at this point in the history
Add type to pi.Palette var, even though it can be inferred by compiler. This is needed to generate better godoc documentation.
  • Loading branch information
elgopher committed Aug 13, 2023
1 parent 9c29c3b commit 441b859
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
10 changes: 10 additions & 0 deletions palette.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@

package pi

import "github.com/elgopher/pi/image"

// Palette has all colors available in the game. Up to 256.
// Palette is taken from loaded sprite sheet (which must be
// a PNG file with indexed color mode). If sprite-sheet.png was not
// found, then default 16 color palette is used.
//
// Can be freely read and updated when the game is running. Changes will be visible immediately.
var Palette [256]image.RGB = defaultPalette

// Palette swapping variables. Use them to generate new graphics by swapping colors.
var (
// Pal (draw palette) contains mapping of colors used to replace color with
Expand Down
16 changes: 4 additions & 12 deletions pi.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
"github.com/elgopher/pi/font"
)

// User parameters
// Game-loop function callbacks
var (
// Update is a user provided function executed each frame (30 times per second).
//
Expand All @@ -53,19 +53,11 @@ var (
//
// The purpose of this function is to draw on screen.
Draw func()

// Palette has all colors available in the game. Up to 256.
// Palette is taken from loaded sprite sheet (which must be
// a PNG file with indexed color mode). If sprite-sheet.png was not
// found, then default 16 color palette is used.
//
// Can be freely read and updated when the game is running. Changes will be visible immediately.
Palette = defaultPalette

// Camera has camera offset used for all subsequent draw operations.
Camera Position
)

// Camera has camera offset used for all subsequent draw operations.
var Camera Position

// Time returns the amount of time since game was run, as a (fractional) number of seconds
//
// Time is updated each frame.
Expand Down

0 comments on commit 441b859

Please sign in to comment.