~johanvandegriff/ruegolike

a1511129f4dd9993c80acccc3186c860d617834e — Johan Vandegriff 1 year, 4 months ago 4a406a5
fixed display of rooms giving extra information (still some edge cases)
4 files changed, 159 insertions(+), 5 deletions(-)

M chars.txt
M display.go
M dungeon.go
M main.go
M chars.txt => chars.txt +8 -1
@@ 1,1 1,8 @@
├ ┤ ┬ ┴ ┼ ╭┌ ╰└ ╮┐ ╯┘ ─ │ £
\ No newline at end of file
sharp (currently using):
├ ┤ ┬ ┴ ┼ ┌ └ ┐ ┘ ─ │

rounded:
╭ ╰ ╮ ╯

misc:
£
\ No newline at end of file

M display.go => display.go +141 -0
@@ 119,6 119,8 @@ func shadowcast(originX, originY, rangeLimit int, visible *[height][width]bool, 
			visible[y][x] = false
		}
	}
	visible[originY][originX] = true
	explored[originY][originX] = true
	//loop through each octant
	for octant := 0; octant < 8; octant++ {
		shadowcastAux(octant, originX, originY, rangeLimit, 1, slope{1, 1}, slope{0, 1}, visible, explored, level)


@@ 318,6 320,145 @@ func Display(s tcell.Screen, playerPos Position, visible *[height][width]bool, e
		for y := 0; y < height; y++ {
			if explored1[y][x] {
				char := level.GetChar(Point{x, y})
				if level.GetTile(Point{x, y}).IsRoom() {
					numFloors := 0
					for x2 := -1; x2 <= 1; x2++ {
						for y2 := -1; y2 <= 1; y2++ {
							if isXYInRange(x+x2, y+y2) && level.GetTile(Point{x + x2, y + y2}).IsRoomFloor() && explored1[y+y2][x+x2] {
								numFloors++
							}
						}
					}
					if numFloors == 0 {
						char = '#'
					} else if level.GetTile(Point{x, y}).IsCorner() { //corner cases :)
						// var isRoom [3][3]bool
						// for x2 := -1; x2 <= 1; x2++ {
						// 	for y2 := -1; y2 <= 1; y2++ {
						// 		isRoom[x2+1][y2+1] = isXYInRange(x+x2, y+y2) && level.GetTile(Point{x + x2, y + y2}).IsRoom() && explored1[y+y2][x+x2]
						// 	}
						// }
						isRoomAbove := isXYInRange(x, y-1) && level.GetTile(Point{x, y - 1}).IsRoom() && explored1[y-1][x]
						isRoomBelow := isXYInRange(x, y+1) && level.GetTile(Point{x, y + 1}).IsRoom() && explored1[y+1][x]
						isRoomLeft := isXYInRange(x-1, y) && level.GetTile(Point{x - 1, y}).IsRoom() && explored1[y][x-1]
						isRoomRight := isXYInRange(x+1, y) && level.GetTile(Point{x + 1, y}).IsRoom() && explored1[y][x+1]

						if char == '├' {
							if isRoomAbove && isRoomBelow && isRoomRight {
								// char = '├'
							} else if !isRoomAbove && isRoomBelow && isRoomRight {
								char = '┌'
							} else if isRoomAbove && !isRoomBelow && isRoomRight {
								char = '└'
							} else if !isRoomAbove && !isRoomBelow && isRoomRight {
								char = '─'
							} else if isRoomAbove && isRoomBelow && !isRoomRight {
								char = '│'
							} else if !isRoomAbove && isRoomBelow && !isRoomRight {
								char = '│'
							} else if isRoomAbove && !isRoomBelow && !isRoomRight {
								char = '│'
							} else if !isRoomAbove && !isRoomBelow && !isRoomRight {
								char = '#'
							}
						}
						if char == '┤' {
							if isRoomAbove && isRoomBelow && isRoomLeft {
								// char = '┤'
							} else if !isRoomAbove && isRoomBelow && isRoomLeft {
								char = '┐'
							} else if isRoomAbove && !isRoomBelow && isRoomLeft {
								char = '┘'
							} else if !isRoomAbove && !isRoomBelow && isRoomLeft {
								char = '─'
							} else if isRoomAbove && isRoomBelow && !isRoomLeft {
								char = '│'
							} else if !isRoomAbove && isRoomBelow && !isRoomLeft {
								char = '│'
							} else if isRoomAbove && !isRoomBelow && !isRoomLeft {
								char = '│'
							} else if !isRoomAbove && !isRoomBelow && !isRoomLeft {
								char = '#'
							}
						}
						if char == '┬' {
							if isRoomLeft && isRoomRight && isRoomBelow {
								// char = '┬'
							} else if !isRoomLeft && isRoomRight && isRoomBelow {
								char = '┌'
							} else if isRoomLeft && !isRoomRight && isRoomBelow {
								char = '┐'
							} else if !isRoomLeft && !isRoomRight && isRoomBelow {
								char = '│'
							} else if isRoomLeft && isRoomRight && !isRoomBelow {
								char = '─'
							} else if !isRoomLeft && isRoomRight && !isRoomBelow {
								char = '─'
							} else if isRoomLeft && !isRoomRight && !isRoomBelow {
								char = '─'
							} else if !isRoomLeft && !isRoomRight && !isRoomBelow {
								char = '#'
							}
						}
						if char == '┴' {
							if isRoomLeft && isRoomRight && isRoomAbove {
								// char = '┴'
							} else if !isRoomLeft && isRoomRight && isRoomAbove {
								char = '└'
							} else if isRoomLeft && !isRoomRight && isRoomAbove {
								char = '┘'
							} else if !isRoomLeft && !isRoomRight && isRoomAbove {
								char = '│'
							} else if isRoomLeft && isRoomRight && !isRoomAbove {
								char = '─'
							} else if !isRoomLeft && isRoomRight && !isRoomAbove {
								char = '─'
							} else if isRoomLeft && !isRoomRight && !isRoomAbove {
								char = '─'
							} else if !isRoomLeft && !isRoomRight && !isRoomAbove {
								char = '#'
							}
						}
						if char == '┼' {
							if isRoomLeft && isRoomRight && isRoomAbove && isRoomBelow {
								// char = '┼'
							} else if !isRoomLeft && isRoomRight && isRoomAbove && isRoomBelow {
								char = '├'
							} else if isRoomLeft && !isRoomRight && isRoomAbove && isRoomBelow {
								char = '┤'
							} else if !isRoomLeft && !isRoomRight && isRoomAbove && isRoomBelow {
								char = '│'
							} else if isRoomLeft && isRoomRight && !isRoomAbove && isRoomBelow {
								char = '┬'
							} else if !isRoomLeft && isRoomRight && !isRoomAbove && isRoomBelow {
								char = '┌'
							} else if isRoomLeft && !isRoomRight && !isRoomAbove && isRoomBelow {
								char = '┐'
							} else if !isRoomLeft && !isRoomRight && !isRoomAbove && isRoomBelow {
								char = '│'
							} else if isRoomLeft && isRoomRight && isRoomAbove && !isRoomBelow {
								char = '┴'
							} else if !isRoomLeft && isRoomRight && isRoomAbove && !isRoomBelow {
								char = '└'
							} else if isRoomLeft && !isRoomRight && isRoomAbove && !isRoomBelow {
								char = '┘'
							} else if !isRoomLeft && !isRoomRight && isRoomAbove && !isRoomBelow {
								char = '│'
							} else if isRoomLeft && isRoomRight && !isRoomAbove && !isRoomBelow {
								char = '─'
							} else if !isRoomLeft && isRoomRight && !isRoomAbove && !isRoomBelow {
								char = '─'
							} else if isRoomLeft && !isRoomRight && !isRoomAbove && !isRoomBelow {
								char = '─'
							} else if !isRoomLeft && !isRoomRight && !isRoomAbove && !isRoomBelow {
								char = '#'
							}
						}
					}
				}
				// if char == '#' {
				// 	char = ' '
				// }
				if visible[y][x] {
					s.SetContent(x+offsetX, y+offsetY, char, nil, style1)
				} else {

M dungeon.go => dungeon.go +9 -3
@@ 60,7 60,7 @@ func (l *Level) GetChar(p Point) int32 {
//IsSolid - returns whether or not a creature can move through the tile
func (t *Tile) IsSolid() bool {
	c := t.char
	return c == '#' || t.IsRoom()
	return c == '#' || c == '─' || c == '│' || t.IsCorner()
}

//IsCorner - is the tile the corner of a room border?


@@ 69,10 69,16 @@ func (t *Tile) IsCorner() bool {
	return c == '├' || c == '┤' || c == '┬' || c == '┴' || c == '┼' || c == '┌' || c == '└' || c == '┐' || c == '┘'
}

//IsRoom - is the tile part of a room border?
//IsRoom - is the tile part of a room border, including doors?
func (t *Tile) IsRoom() bool {
	c := t.char
	return c == '─' || c == '│' || t.IsCorner()
	return c == '─' || c == '│' || c == '*' || t.IsCorner()
}

//IsRoomFloor - is the tile one that is normally generated inside a room?
func (t *Tile) IsRoomFloor() bool {
	c := t.char
	return c == '.' || c == '>' || c == '<' //|| c == '*'
}

//BlocksLight - returns whether or not a creature can see through the tile

M main.go => main.go +1 -1
@@ 11,7 11,7 @@ import (

const width, height, depth = 48, 16, 32
const offsetX, offsetY = 1, 2
const debug = false
const debug = true

func main() {
	rand.Seed(time.Now().UnixNano())