Skip to content

Commit

Permalink
Inverse video ready
Browse files Browse the repository at this point in the history
  • Loading branch information
bobtfish committed Jul 5, 2020
1 parent bae4852 commit 26a8cea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions render/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "github.com/bobtfish/mayhem/logical"

const CHAR_PIXELS = 64
const SPRITE_SIZE = 16
const INVERSE_VIDEO_OFFSET = 10

func MainScreenV() logical.Vec {
return logical.V(0, CHAR_PIXELS)
Expand Down
17 changes: 16 additions & 1 deletion render/sprite.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,22 @@ func GetSpriteSheet(io io.Reader) pixel.Picture {
if err != nil {
panic(err)
}
return pixel.PictureDataFromImage(img)

// Recreate an image of double the width of the sprite sheet.
// Copy the original sprite sheet, and then to the right copy
// all the same pixels but with the colours inverted.
// This allows us to draw inverse video :)
size := img.Bounds().Size()
wImg := image.NewNRGBA(image.Rect(0, 0, size.X, size.Y))
for x := 0; x < size.X*2; x++ {
for y := 0; y < size.Y; y++ {
pixel := img.At(x, y).(color.NRGBA)
newPixel := color.NRGBA{^pixel.R, ^pixel.G, ^pixel.B, pixel.A}
wImg.Set(x, y, pixel)
wImg.Set(x+size.X, y, newPixel)
}
}
return pixel.PictureDataFromImage(wImg)
}

func NewSpriteDrawer(ss pixel.Picture) SpriteDrawer {
Expand Down

0 comments on commit 26a8cea

Please sign in to comment.