slight refactor, gofmt

This commit is contained in:
2019-10-26 23:32:32 +03:00
parent 32c598f9e0
commit ec9d3d9a73
20 changed files with 303 additions and 239 deletions

9
engine/types/ifaces.go Normal file
View File

@ -0,0 +1,9 @@
package types
type Renderable interface {
Render()
}
type Putable interface {
Put(x, y int, symbol interface{})
}

47
engine/types/rect.go Normal file
View File

@ -0,0 +1,47 @@
package types
type Rect struct {
X, Y, W, H int
}
type RectFill struct {
Top, Bottom, Left, Right, TopLeft, TopRight, BottomLeft, BottomRight, Body interface{}
}
func NewRect(x, y, w, h int) *Rect {
return &Rect{x, y, w, h}
}
func (r *Rect) RenderToLayer(fillage RectFill, layer Putable) {
if fillage.Body != "" {
for i := r.X + 1; i < r.X+r.W; i++ {
for j := r.Y + 1; j < r.Y+r.H; j++ {
layer.Put(i, j, fillage.Body)
//lii.Put(i, j, "X");
}
}
}
for i := r.X + 1; i < r.X+r.W; i++ {
layer.Put(i, r.Y, fillage.Top)
//lii.Put(i, Y-1, "Q");
layer.Put(i, r.Y+r.H, fillage.Bottom)
//lii.Put(i, Y+H, "H");
}
for j := r.Y + 1; j < r.Y+r.H; j++ {
layer.Put(r.X, j, fillage.Left)
//lii.Put(X-1, j, "U");
layer.Put(r.X+r.W, j, fillage.Right)
//lii.Put(X+W, j, "M");
}
layer.Put(r.X, r.Y, fillage.TopLeft)
//lii.Put(X-1, Y-1, "T");
layer.Put(r.X, r.Y+r.H, fillage.BottomLeft)
//lii.Put(X-1, Y+H, "q");
layer.Put(r.X+r.W, r.Y, fillage.TopRight)
//lii.Put(X+W, Y-1, "L");
layer.Put(r.X+r.W, r.Y+r.H, fillage.BottomRight)
}