Compare commits

...

5 Commits

Author SHA1 Message Date
ea26db29f3 Added allegro build tag to the README. 2020-05-23 12:08:29 +02:00
d24b4eb376 Updated release script to produce Allegro build as well.
Moved zipping directly after the build folder is ready.
2020-05-23 12:03:45 +02:00
855db3375c Added build flag to switch to Allegro backend.
Added logs that print which backend is used.
2020-05-23 11:08:50 +02:00
822d8ab584 Fixed incorrect panning. 2020-05-23 11:02:30 +02:00
b7b663ddb5 Fixed bug where mouse was released outside terrain area when dragging it kept dragging. 2020-05-23 10:43:05 +02:00
6 changed files with 64 additions and 29 deletions

View File

@ -118,6 +118,11 @@ go generate opslag.de/schobers/tins2020/cmd/tins2020
go install opslag.de/schobers/tins2020/cmd/tins2020 -tags static -ldflags "-s -w"
```
If you want to use the Allegro backend you can add the build tag `allegro` to the `go install` command. E.g.:
```
go install opslag.de/schobers/tins2020/cmd/tins2020 -tags static,allegro -ldflags "-s -w"
```
## Sources
Can be found at https://opslag.de/schobers/tins2020 (Git repository).

View File

@ -12,9 +12,6 @@ import (
"opslag.de/schobers/zntg/play"
"opslag.de/schobers/zntg/ui"
_ "opslag.de/schobers/zntg/sdlui" // rendering backend
// _ "opslag.de/schobers/zntg/allg5ui" // rendering backend
rice "github.com/GeertJohan/go.rice"
"github.com/veandco/go-sdl2/sdl"
"opslag.de/schobers/tins2020"

View File

@ -0,0 +1,13 @@
// +build allegro
package main
import (
"log"
_ "opslag.de/schobers/zntg/allg5ui" // rendering backend
)
func init() {
log.Println("Using Allegro5 rendering backend")
}

View File

@ -0,0 +1,13 @@
// +build !allegro
package main
import (
"log"
_ "opslag.de/schobers/zntg/sdlui" // SDL rendering backend
)
func init() {
log.Println("Using SDL rendering backend")
}

View File

@ -12,28 +12,38 @@ echo "Creating ${version} release"
rm -rf build/linux*
rm -rf build/windows*
mkdir -p build/linux
mkdir -p build/windows
mkdir -p build/release
go generate ../cmd/tins2020
mkdir -p build/linux
go build -tags static -ldflags "-s -w" -o build/linux/botanim ../cmd/tins2020
cp ../README.md build/linux
CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -tags static -ldflags "-s -w" -o build/windows/botanim.exe ../cmd/tins2020
cp ../README.md build/windows
mkdir -p build/release
cd build
cd linux
cd build/linux
zip -9 -q ../release/botanim_${version}_linux_amd64.zip *
echo "Created Linux release: build/release/botanim_${version}_linux_amd64.zip"
cd ..
cd ../..
cd windows
mkdir -p build/linux-allegro
go build -tags static,allegro -ldflags "-s -w" -o build/linux-allegro/botanim ../cmd/tins2020
cp ../README.md build/linux-allegro
cd build/linux-allegro
zip -9 -q ../release/botanim_allegro_${version}_linux_amd64.zip *
echo "Created Linux (Allegro) release: build/release/botanim_allegro_${version}_linux_amd64.zip"
cd ../..
mkdir -p build/windows
CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -tags static -ldflags "-s -w" -o build/windows/botanim.exe ../cmd/tins2020
cp ../README.md build/windows
cd build/windows
zip -9 -q ../release/botanim_${version}_windows_amd64.zip *
echo "Created Windows release: build/release/botanim_${version}_windows_amd64.zip"
cd ..
cd ../..
mkdir -p build/windows-allegro
CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -tags static,allegro,mingw64_7_3 -ldflags "-s -w" -o build/windows-allegro/botanim.exe ../cmd/tins2020
cp ../README.md build/windows-allegro
cd build/windows-allegro
zip -9 -q ../release/botanim_allegro_${version}_windows_amd64.zip *
echo "Created Windows (Allegro) release: build/release/botanim_allegro_${version}_windows_amd64.zip"
cd ../..

View File

@ -63,12 +63,9 @@ func (r *terrainRenderer) Handle(ctx ui.Context, event ui.Event) bool {
}
}
case *ui.MouseButtonUpEvent:
pos := e.Pos()
if pos.In(r.interactBounds) {
if _, ok := r.drag.IsDragging(); ok {
r.game.Terrain.Center = r.isometric.TileInt(r.isometric.Center())
r.drag.Cancel()
}
if _, ok := r.drag.IsDragging(); ok {
r.game.Terrain.Center = r.isometric.TileInt(r.isometric.Center())
r.drag.Cancel()
}
case *ui.MouseMoveEvent:
pos := e.Pos()
@ -80,7 +77,7 @@ func (r *terrainRenderer) Handle(ctx ui.Context, event ui.Event) bool {
}
if _, ok := r.drag.IsDragging(); ok {
delta, _ := r.drag.Move(pos)
r.isometric.Pan(r.isometric.ViewToTileRelative(delta.Invert()))
r.isometric.Pan(delta.Invert())
}
if r.hover != nil {
if e.MouseWheel < 0 {
@ -100,13 +97,13 @@ func (r *terrainRenderer) Handle(ctx ui.Context, event ui.Event) bool {
case ui.KeyPadMinus:
r.isometric.ZoomOut(r.isometric.Center())
case ui.KeyW:
r.isometric.Pan(geom.PtF32(-1, -1))
r.isometric.PanTile(geom.PtF32(-1, -1))
case ui.KeyA:
r.isometric.Pan(geom.PtF32(-1, 1))
r.isometric.PanTile(geom.PtF32(-1, 1))
case ui.KeyS:
r.isometric.Pan(geom.PtF32(1, 1))
r.isometric.PanTile(geom.PtF32(1, 1))
case ui.KeyD:
r.isometric.Pan(geom.PtF32(1, -1))
r.isometric.PanTile(geom.PtF32(1, -1))
}
}
return false