Fixing up scaling
This commit is contained in:
parent
6f714b5545
commit
c0a11bc2da
|
@ -6,7 +6,7 @@ import (
|
||||||
"github.com/veandco/go-sdl2/sdl"
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
//"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Graphics struct {
|
type Graphics struct {
|
||||||
|
@ -55,7 +55,9 @@ func (g *Graphics) Render(env *core.Environment, turtles []*core.Turtle) {
|
||||||
amount := math.Min(float64(env.Sniff(name, x, y)), 255)
|
amount := math.Min(float64(env.Sniff(name, x, y)), 255)
|
||||||
|
|
||||||
if amount > 0 {
|
if amount > 0 {
|
||||||
g.renderer.SetDrawColor(color[0]*uint8(amount), color[1]*uint8(amount), color[2]*uint8(amount), uint8(255))
|
// TODO explictly define this scale
|
||||||
|
scaledamount := uint8(float64(color[0]) * (amount/2))
|
||||||
|
g.renderer.SetDrawColor(scaledamount,0,scaledamount, uint8(0xF0))
|
||||||
g.renderer.DrawPoint(int32(x), int32(y))
|
g.renderer.DrawPoint(int32(x), int32(y))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +83,7 @@ func (g *Graphics) Render(env *core.Environment, turtles []*core.Turtle) {
|
||||||
|
|
||||||
g.renderer.Present()
|
g.renderer.Present()
|
||||||
g.window.UpdateSurface()
|
g.window.UpdateSurface()
|
||||||
surface, _ := g.window.GetSurface()
|
// surface, _ := g.window.GetSurface()
|
||||||
surface.SaveBMP("./images/" + strconv.Itoa(g.t) + ".bmp")
|
// surface.SaveBMP("./images/" + strconv.Itoa(g.t) + ".bmp")
|
||||||
g.t++
|
g.t++
|
||||||
}
|
}
|
||||||
|
|
2
main.go
2
main.go
|
@ -89,6 +89,8 @@ func main() {
|
||||||
for i := 0; i < *numTurtles; i++ {
|
for i := 0; i < *numTurtles; i++ {
|
||||||
turtles[i] = core.NewTurtle(env, &actors.SlimeMold{SniffDistance: 20})
|
turtles[i] = core.NewTurtle(env, &actors.SlimeMold{SniffDistance: 20})
|
||||||
}
|
}
|
||||||
|
env.InitPheromone("trail")
|
||||||
|
g.ColorPheromone("trail", [4]uint8{0x81, 0, 0x81, 0x00})
|
||||||
}
|
}
|
||||||
|
|
||||||
running := true
|
running := true
|
||||||
|
|
Loading…
Reference in New Issue