Moved tile & entity type to separate code unit.

This commit is contained in:
Sander Schobers 2020-01-15 19:06:06 +01:00
parent a4058df9c8
commit cb81ced655
3 changed files with 44 additions and 41 deletions

23
soko/entitytype.go Normal file
View File

@ -0,0 +1,23 @@
package soko
type EntityType byte
const (
EntityTypeInvalid EntityType = EntityType(0)
EntityTypeNone = '_'
EntityTypeCharacter = '@'
EntityTypeEgg = 'X'
EntityTypeBrick = 'B'
)
func (e EntityType) IsValid() bool {
switch e {
case EntityTypeNone:
case EntityTypeCharacter:
case EntityTypeEgg:
case EntityTypeBrick:
default:
return false
}
return true
}

View File

@ -4,47 +4,6 @@ import (
"opslag.de/schobers/geom" "opslag.de/schobers/geom"
) )
type EntityType byte
type Tile byte
const (
EntityTypeInvalid EntityType = EntityType(0)
EntityTypeNone = '_'
EntityTypeCharacter = '@'
EntityTypeEgg = 'X'
EntityTypeBrick = 'B'
)
func (e EntityType) IsValid() bool {
switch e {
case EntityTypeNone:
case EntityTypeCharacter:
case EntityTypeEgg:
case EntityTypeBrick:
default:
return false
}
return true
}
const (
TileInvalid Tile = Tile(0)
TileNothing = '.'
TileBasic = '#'
TileMagma = '~'
)
func (t Tile) IsValid() bool {
switch t {
case TileNothing:
case TileBasic:
case TileMagma:
default:
return false
}
return true
}
type Level struct { type Level struct {
Width int Width int
Height int Height int

21
soko/tile.go Normal file
View File

@ -0,0 +1,21 @@
package soko
type Tile byte
const (
TileInvalid Tile = Tile(0)
TileNothing = '.'
TileBasic = '#'
TileMagma = '~'
)
func (t Tile) IsValid() bool {
switch t {
case TileNothing:
case TileBasic:
case TileMagma:
default:
return false
}
return true
}