Skip to content

Commit

Permalink
Revert "Adressing #23 - ie trying to make sure that Creatures with sm…
Browse files Browse the repository at this point in the history
…aller Layer won't be displayed under ones with bigger Layer (like corpses under player); it's not elegant solution, thought"

This reverts commit 667b9d0.
  • Loading branch information
VedVid committed Nov 14, 2018
1 parent 667b9d0 commit a6dc4ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
10 changes: 0 additions & 10 deletions monsters.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package main

import (
"errors"
"sort"
"unicode/utf8"
)

Expand Down Expand Up @@ -92,15 +91,6 @@ func NewCreature(layer, x, y int, character, color, colorDark string,
return creatureNew, err
}

func (c Creatures) SortByLayer() {
/* Method SortByLayer sorts its receiver
slice of *Creature by their Layers, from
highest to lowest. */
sort.Slice(c, func(i, j int) bool {
return c[i].Layer > c[j].Layer
})
}

func (c *Creature) MoveOrAttack(tx, ty int, b Board, all Creatures) bool {
/* Method MoveOrAttack decides if Creature will move or attack other Creature;
It has *Creature receiver, and takes tx, ty (coords) integers as arguments,
Expand Down
25 changes: 7 additions & 18 deletions render.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ freely, subject to the following restrictions:

package main

import (
blt "bearlibterminal"
)
import blt "bearlibterminal"

const (
/* Constant values for layers. Their usage is optional,
Expand Down Expand Up @@ -77,10 +75,6 @@ func PrintObjects(b Board, o Objects, c Creatures) {
for _, v := range o {
if (IsInFOV(b, c[0].X, c[0].Y, v.X, v.Y) == true) ||
(v.AlwaysVisible == true) {
for l := BaseLayer; l < v.Layer; l++ {
blt.Layer(l)
blt.ClearArea(v.X, v.Y, 1, 1)
}
blt.Layer(v.Layer)
glyph := "[color=" + v.Color + "]" + v.Char
blt.Print(v.X, v.Y, glyph)
Expand All @@ -91,20 +85,15 @@ func PrintObjects(b Board, o Objects, c Creatures) {
func PrintCreatures(b Board, c Creatures) {
/* Function PrintCreatures is used in RenderAll function.
Takes map of level and slice of Creatures as arguments.
Sorts Creatures by Layer, from highest to lowest.
Iterates through Creatures.
Checks for every creature on its coords if certain conditions are met:
AlwaysVisible bool is set to true, or is in player fov. */
c.SortByLayer()
for i := (len(c) - 1); i >= 0; i-- {
if (IsInFOV(b, c[0].X, c[0].Y, c[i].X, c[i].Y) == true) ||
(c[i].AlwaysVisible == true) {
for l := BaseLayer; l < c[i].Layer; l++ {
blt.Layer(l)
blt.ClearArea(c[i].X, c[i].Y, 1, 1)
}
glyph := "[color=" + c[i].Color + "]" + c[i].Char
blt.Print(c[i].X, c[i].Y, glyph)
for _, v := range c {
if (IsInFOV(b, c[0].X, c[0].Y, v.X, v.Y) == true) ||
(v.AlwaysVisible == true) {
blt.Layer(v.Layer)
glyph := "[color=" + v.Color + "]" + v.Char
blt.Print(v.X, v.Y, glyph)
}
}
}
Expand Down

0 comments on commit a6dc4ac

Please sign in to comment.