basic mapgen

This commit is contained in:
2019-10-27 01:08:06 +03:00
parent ec9d3d9a73
commit b8c8a65fa7
6 changed files with 154 additions and 36 deletions

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

@ -0,0 +1,9 @@
package types
type Coords struct {
X, Y int
}
func (c *Coords) Get() (int,int) {
return c.X,c.Y
}

View File

@ -12,7 +12,7 @@ func NewRect(x, y, w, h int) *Rect {
return &Rect{x, y, w, h}
}
func (r *Rect) RenderToLayer(fillage RectFill, layer Putable) {
func (r *Rect) Blit(fillage RectFill, layer Putable) {
if fillage.Body != "" {
for i := r.X + 1; i < r.X+r.W; i++ {
@ -45,3 +45,17 @@ func (r *Rect) RenderToLayer(fillage RectFill, layer Putable) {
//lii.Put(X+W, Y-1, "L");
layer.Put(r.X+r.W, r.Y+r.H, fillage.BottomRight)
}
func (self *Rect) Intersects(other *Rect) bool {
if self.X <= (other.X+other.W) &&
(self.X+self.W) >= other.X &&
self.Y <= (other.Y+other.Y) &&
(self.Y+self.H) >= other.Y {
return true
}
return false
}
func (r *Rect) InBounds (x,y int) bool {
return x >= r.X && x <= (r.X + r.W) && y >= r.Y && y <= (r.Y + r.H)
}