Checkpoint
This commit is contained in:
54 files changed
+6855
-526
No files matched your search
@@ -2,10 +2,18 @@ package display
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"go.maze.io/harmon/hardware"
|
||||
"image/draw"
|
||||
)
|
||||
|
||||
func DrawSprite(display hardware.Display, x, y int, sprite []byte, c color.Color) error {
|
||||
return nil
|
||||
func DrawSprite(p draw.Image, x, y int, sprite []uint8, c color.Color) {
|
||||
w, h, data := sprite[0], sprite[1], sprite[2:]
|
||||
for dy := 0; dy < int(h); dy++ {
|
||||
for dx := 0; dx < int(w); dx++ {
|
||||
byteOffset := int(dy/8)*int(w) + dx
|
||||
bitOffset := dy % 8
|
||||
if data[byteOffset]&(1<<bitOffset) != 0 {
|
||||
p.Set(x+dx, y+dy, c)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user