This commit is contained in:
thefish 2019-10-31 22:47:36 +03:00
parent cddc5fa70f
commit a91351d3dc
6 changed files with 31 additions and 61 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
.idea/*
tmp/*
logs/*
dist/*
*.swp

View File

@ -2,26 +2,27 @@ PROJECT_NAME := "alchemyst-go"
PKG := "lab.zaar.be/thefish/$(PROJECT_NAME)"
GO=$(shell which go)
CWD=$(shell pwd)
DISTFOLDER=$(CWD)/dist
CP=$(shell cp)
GLIDE=$(shell which glide)
LDFLAGS="-X \"main.versionInfo=${PKG_VER}-${CI_PIPELINE_ID} built at $(shell date) on $(shell hostname) with $(shell go version)\""
.PHONY: all build test get-dep
.PHONY: all build test
all: build test
#build: build.spec build.server
build: build.server
build: build.game
#build.spec:
# $(CWD)/bin/oapi-codegen --generate types,spec -o $(CWD)/api/inner/inner.gen.go $(CWD)/public/schema/api.yaml
build.deps:
GIT_SSL_NO_VERIFY=true $(GO) mod vendor
build.server:
$(GO) build -ldflags $(LDFLAGS) -o $(CWD)/bin/game $(CWD)/cmd/game/main.go
build.game:
cp $(CWD)/vendor/lab.zaar.be/thefish/bearlibterminal/libBearLibTerminal.so $(DISTFOLDER)
cp $(CWD)/config.json $(DISTFOLDER)
cp -r $(CWD)/resources $(DISTFOLDER)
$(GO) build -ldflags $(LDFLAGS) -o $(DISTFOLDER)/game $(CWD)/cmd/game/main.go
test:
$(GO) test -v $(go list ./... | grep -v /vendor/)
get-dep:
GIT_SSL_NO_VERIFY=true go mod vendor

View File

@ -116,12 +116,19 @@ func setupLayers(mainwindow *mainwindow.MainWindow) {
func decodeInput(ctx util.ClientCtx, baseLayer *mainwindow.Layer) {
var exit = false
var waitForWCspam = true
for !exit{
select {
case keycode := <-State.rawInput:
if keycode == blt.TK_NONE {
continue
}
if keycode == blt.TK_CLOSE && !waitForWCspam {
ctx.Logger().Warn().Msg("exiting on window close...")
State.exit <- struct{}{}
ctx.Logger().Warn().Msg("...done")
return
}
var pressed= ""
var isModifier, _= util.InArray(keycode, modifiers)
if !isModifier {
@ -153,6 +160,7 @@ func decodeInput(ctx util.ClientCtx, baseLayer *mainwindow.Layer) {
exit = true
return
default:
waitForWCspam = false;
State.input <- pressed
}
}

0
dist/.gitkeep vendored Normal file
View File

View File

@ -1,2 +1,2 @@
#!/bin/bash
ln -s src/bearlibterminal/libBearLibTerminal.so .
ln -s vendor/lab.zaar.be/thefish/bearlibterminal/libBearLibTerminal.so .

View File

@ -125,61 +125,21 @@ func (vp *ViewPort) Render() {
vp.layer.Clear(vp.Rect)
fovRecompute = false
redraw = true
//fixme
vp.Fov.ComputeFov(vp.level, vp.playerCoords, vp.playerTorchRadius)
}
//for y := 0; y < vp.H; y++ {
// for x := 0; x < vp.W; x++ {
// mapCoords := types.Coords{vp.X + x, vp.Y + y}
// tile := vp.level.Tiles[mapCoords.X][mapCoords.Y]
//
// if tile.Visible {
// if tile.MustDraw {
// //darkened version of landscape
// vp.layer.WithRawColor(tile.ColorSet.DarkFg()).
// PutWithRawBackground(mapCoords.X, mapCoords.Y, tile.Char, tile.ColorSet.DarkBg())
// }
// } else {
// if redraw == true || tile.Colordance {
// vp.layer.WithRawColor(tile.ColorSet.Fg()).
// PutWithRawBackground(mapCoords.X, mapCoords.Y, tile.Char, tile.ColorSet.Bg())
// tile.Explored = true
// tile.MustDraw = true
// }
// }
// }
//}
if redraw {
for y := 0; y < vp.H; y++ {
for x := 0; x < vp.W; x++ {
mapCoords := types.Coords{vp.X + x, vp.Y + y}
for y := 0; y < vp.H; y++ {
for x := 0; x < vp.W; x++ {
mapCoords := types.Coords{vp.X + x, vp.Y + y}
//vp.level.GetTile(mapCoords).Render()
tile := vp.level.GetTile(mapCoords)
//vp.layer.
// WithRawColor(tile.GetRawColor()).
// PutWithBackground(mapCoords.X, mapCoords.Y, tile.GetChar(), "grey")
vp.layer.PutToBase(mapCoords.X,mapCoords.Y,tile.GetChar(), tile.GetRawColor(), tile.GetRawBgColor())
//if tile.Visible {
// if tile.MustDraw {
// //darkened version of landscape
// vp.layer.WithColor("green").
// Put(mapCoords.X, mapCoords.Y, tile.Char)
// }
//} else {
// if redraw == true || tile.Colordance {
// vp.layer.WithColor("grey").
// Put(mapCoords.X, mapCoords.Y, tile.Char)
// tile.Explored = true
// tile.MustDraw = true
// }
//}
tile := vp.level.GetTile(mapCoords)
if tile.Explored || tile.MustDraw || tile.Visible {
vp.layer.PutToBase(mapCoords.X, mapCoords.Y, tile.GetChar(), tile.GetRawColor(), tile.GetRawBgColor())
}
}
}
//redraw = false
}
}