ui starting, menu screen, ingame help

This commit is contained in:
2019-11-08 03:36:26 +03:00
parent 4532320ce3
commit cb7718860a
11 changed files with 271 additions and 40 deletions

View File

@ -12,10 +12,16 @@ func NewRect(x, y, w, h int) *Rect {
return &Rect{x, y, w, h}
}
func NewCenteredRect(source *Rect, w, h int) *Rect {
targetX := source.X + source.W / 2 - w / 2
targetY := source.Y + source.H / 2 - h / 2
return &Rect{targetX, targetY, w, h}
}
func (r *Rect) Blit(fillage RectFill, layer Putable) {
if fillage.Body != "" {
for i := r.X + 1; i < r.X+r.W; i++ {
for i := r.X+1; i < r.X+r.W - 1; i++ {
for j := r.Y + 1; j < r.Y+r.H; j++ {
layer.Put(i, j, fillage.Body)
//lii.Put(i, j, "X");
@ -23,27 +29,27 @@ func (r *Rect) Blit(fillage RectFill, layer Putable) {
}
}
for i := r.X + 1; i < r.X+r.W; i++ {
for i := r.X; i < r.X+r.W - 1; i++ {
layer.Put(i, r.Y, fillage.Top)
//lii.Put(i, Y-1, "Q");
layer.Put(i, r.Y+r.H, fillage.Bottom)
layer.Put(i, r.Y+r.H - 1, fillage.Bottom)
//lii.Put(i, Y+H, "H");
}
for j := r.Y + 1; j < r.Y+r.H; j++ {
for j := r.Y; 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)
layer.Put(r.X+r.W - 1, 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)
layer.Put(r.X, r.Y+r.H - 1, fillage.BottomLeft)
//lii.Put(X-1, Y+H, "q");
layer.Put(r.X+r.W, r.Y, fillage.TopRight)
layer.Put(r.X+r.W - 1, r.Y, fillage.TopRight)
//lii.Put(X+W, Y-1, "L");
layer.Put(r.X+r.W, r.Y+r.H, fillage.BottomRight)
layer.Put(r.X+r.W - 1, r.Y+r.H - 1, fillage.BottomRight)
}
func (self *Rect) Intersects(other *Rect) bool {