Formalise a bit in each cell as an "IsActive()" bit
This commit is contained in:
@@ -52,7 +52,7 @@ var transparent = color.RGBA{0, 0, 0, 0}
|
||||
func spriteToPic(name string, idx int, sprite *data.Sprite) *pixel.PictureData {
|
||||
pic := pixel.MakePictureData(pixel.R(float64(0), float64(0), float64(sprite.Width), float64(sprite.Height)))
|
||||
|
||||
log.Printf("%v %v: width=%v height=%v", name, idx, sprite.Width, sprite.Height)
|
||||
//log.Printf("%v %v: width=%v height=%v", name, idx, sprite.Width, sprite.Height)
|
||||
|
||||
for y := 0; y < int(sprite.Height); y++ {
|
||||
// Start with all bytes transparent
|
||||
@@ -61,7 +61,7 @@ func spriteToPic(name string, idx int, sprite *data.Sprite) *pixel.PictureData {
|
||||
}
|
||||
|
||||
row := sprite.Rows[y]
|
||||
log.Printf("%#v", row)
|
||||
//log.Printf("%#v", row)
|
||||
pixels := row[0 : len(row)-1] // Strip off the record separator (0x00)
|
||||
|
||||
// Not really clear on what this does yet. Aligned with sprite width in
|
||||
@@ -79,7 +79,7 @@ func spriteToPic(name string, idx int, sprite *data.Sprite) *pixel.PictureData {
|
||||
|
||||
// Do nothing if we're out of pixels
|
||||
if u0 == 0x80 {
|
||||
log.Printf("Handling 0x80: %#v", pixels)
|
||||
//log.Printf("Handling 0x80: %#v", pixels)
|
||||
xOffset = int(pixels[0])
|
||||
pixels = pixels[1:len(pixels)]
|
||||
|
||||
@@ -98,10 +98,10 @@ func spriteToPic(name string, idx int, sprite *data.Sprite) *pixel.PictureData {
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf(
|
||||
"%v %d: len(row)=%v, len(pixels)=%v sprWidth=%v u0=%v xOffset=%v",
|
||||
name, idx, len(row), len(pixels), sprite.Width, u0, xOffset,
|
||||
)
|
||||
//log.Printf(
|
||||
// "%v %d: len(row)=%v, len(pixels)=%v sprWidth=%v u0=%v xOffset=%v",
|
||||
// name, idx, len(row), len(pixels), sprite.Width, u0, xOffset,
|
||||
//)
|
||||
|
||||
for x, b := range pixels {
|
||||
vec := pixel.V(float64(xOffset+x), float64(y))
|
||||
|
@@ -69,8 +69,8 @@ func (h Header) MapSetFilename() string {
|
||||
}
|
||||
|
||||
type ObjRef struct {
|
||||
AreaByte byte
|
||||
FrameAndUnknownByte byte
|
||||
AreaByte byte
|
||||
SpriteAndFlagByte byte
|
||||
}
|
||||
|
||||
// The index into a set palette to retrieve the object
|
||||
@@ -78,8 +78,14 @@ func (o ObjRef) Index() int {
|
||||
return int(o.AreaByte)
|
||||
}
|
||||
|
||||
func (o ObjRef) Frame() int {
|
||||
return int(o.FrameAndUnknownByte - 0x80)
|
||||
func (o ObjRef) Sprite() int {
|
||||
// The top bit seems to be a flag of some kind
|
||||
return int(o.SpriteAndFlagByte & 0x7f)
|
||||
}
|
||||
|
||||
// The top bit seems to say whether we should draw or not.
|
||||
func (o ObjRef) IsActive() bool {
|
||||
return (o.SpriteAndFlagByte & 0x80) == 0x80
|
||||
}
|
||||
|
||||
type Cell struct {
|
||||
@@ -108,19 +114,19 @@ func (c *Cell) At(n int) byte {
|
||||
case 3:
|
||||
return c.Surface.AreaByte
|
||||
case 4:
|
||||
return c.Surface.FrameAndUnknownByte
|
||||
return c.Surface.SpriteAndFlagByte
|
||||
case 5:
|
||||
return c.Left.AreaByte
|
||||
case 6:
|
||||
return c.Left.FrameAndUnknownByte
|
||||
return c.Left.SpriteAndFlagByte
|
||||
case 7:
|
||||
return c.Right.AreaByte
|
||||
case 8:
|
||||
return c.Right.FrameAndUnknownByte
|
||||
return c.Right.SpriteAndFlagByte
|
||||
case 9:
|
||||
return c.Center.AreaByte
|
||||
case 10:
|
||||
return c.Center.FrameAndUnknownByte
|
||||
return c.Center.SpriteAndFlagByte
|
||||
case 11:
|
||||
return c.Unknown11
|
||||
case 12:
|
||||
@@ -139,7 +145,6 @@ func (c *Cell) At(n int) byte {
|
||||
// Cells is always a fixed size; use At to get a cell according to x,y,z
|
||||
type Cells []Cell
|
||||
|
||||
// FIXME: Ordering may be incorrect? I assume z,y,x for now...
|
||||
func (c Cells) At(x, y, z int) Cell {
|
||||
return c[(z*MaxLength*MaxWidth)+(y*MaxWidth)+x]
|
||||
}
|
||||
|
Reference in New Issue
Block a user