wu algo
This commit is contained in:
parent
e738568c14
commit
2352ec4f0a
12
TODO
12
TODO
@ -83,3 +83,15 @@ Quest engine:
|
||||
- look at parsers like URQL etc
|
||||
- distorted Aschenputtel story / partisans / rapist prince / Grey Mountains / No gold
|
||||
|
||||
|
||||
No Gold in Gery Mountains / Kim Newman
|
||||
|
||||
- Drakenfells castle //location
|
||||
- Greteschele // char / rogue / charred zombie
|
||||
- Yom Lamprecht // char / rogue /
|
||||
- Tiley manor(?) // location / княжество
|
||||
- Melissa d'Acu // char / small girl
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ func (ts *GameScreen) UseEcs() bool { return true }
|
||||
func (ts *GameScreen) Enter() {
|
||||
ts.mw.GetLayer("overlay").ClearArea(0, ts.mw.H-3, 30, 3)
|
||||
ts.mw.GetLayer("overlay").WithColor("#77777777").
|
||||
Print(1, ts.mw.H-2, "Press [color=white]?[/color] for help")
|
||||
Print(ts.mw.W - 17 , 1, "Press [color=white]?[/color] for help")
|
||||
}
|
||||
func (ts *GameScreen) Exit() {
|
||||
//trs := ts.controller.GetSystem(ecs.LevelRenderSystem)
|
||||
|
78
util/wu/line.go
Normal file
78
util/wu/line.go
Normal file
@ -0,0 +1,78 @@
|
||||
package wu
|
||||
|
||||
import (
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/types"
|
||||
"math"
|
||||
)
|
||||
|
||||
func ipart(x float64) float64 {
|
||||
return math.Floor(x)
|
||||
}
|
||||
|
||||
func round(x float64) float64 {
|
||||
return ipart(x + .5)
|
||||
}
|
||||
|
||||
func fpart(x float64) float64 {
|
||||
return x - ipart(x)
|
||||
}
|
||||
|
||||
func rfpart(x float64) float64 {
|
||||
return 1 - fpart(x)
|
||||
}
|
||||
|
||||
func (Layer types.Putable) WuLine(x1, y1, x2, y2 float64, w int) {
|
||||
dx := x2 - x1
|
||||
dy := y2 - y1
|
||||
ax := dx
|
||||
if ax < 0 {
|
||||
ax = -ax
|
||||
}
|
||||
ay := dy
|
||||
if ay < 0 {
|
||||
ay = -ay
|
||||
}
|
||||
|
||||
var plot func(int, int, float64)
|
||||
|
||||
if ax < ay {
|
||||
x1, y1 = y1, x1
|
||||
x2, y2 = y2, x2
|
||||
dx, dy = dy, dx
|
||||
plot = func(x, y int, c float64) {
|
||||
Layer.Put(y, x, uint8(255 * c))
|
||||
}
|
||||
} else {
|
||||
plot = func(x, y int, c float64) {
|
||||
Layer.Put(x, y, uint8(255 * c))
|
||||
}
|
||||
}
|
||||
if x2 < x1 {
|
||||
x1, x2 = x2, x1
|
||||
y1, y2 = y2, y1
|
||||
}
|
||||
gradient := dy / dx
|
||||
|
||||
xend := round(x1)
|
||||
yend := y1 + gradient*(xend-x1)
|
||||
xgap := rfpart(x1 + .5)
|
||||
xpxl1 := int(xend)
|
||||
ypxl1 := int(ipart(yend))
|
||||
plot(xpxl1, ypxl1, rfpart(yend)*xgap)
|
||||
plot(xpxl1, ypxl1+1, fpart(yend)*xgap)
|
||||
intery := yend + gradient
|
||||
|
||||
xend = round(x2)
|
||||
yend = y2 + gradient*(xend-x2)
|
||||
xgap = fpart(x2 + 0.5)
|
||||
xpxl2 := int(xend)
|
||||
ypxl2 := int(ipart(yend))
|
||||
plot(xpxl2, ypxl2, rfpart(yend)*xgap)
|
||||
plot(xpxl2, ypxl2+1, fpart(yend)*xgap)
|
||||
|
||||
for x := xpxl1 + 1; x <= xpxl2-1; x++ {
|
||||
plot(x, int(ipart(intery)), rfpart(intery))
|
||||
plot(x, int(ipart(intery))+1, fpart(intery))
|
||||
intery = intery + gradient
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user