Fixing up scaling

This commit is contained in:
Sarah Jamie Lewis 2019-08-03 17:08:38 -07:00
parent 6f714b5545
commit c0a11bc2da
2 changed files with 8 additions and 4 deletions

View File

@ -6,7 +6,7 @@ import (
"github.com/veandco/go-sdl2/sdl"
"math"
"os"
"strconv"
//"strconv"
)
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)
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))
}
}
@ -81,7 +83,7 @@ func (g *Graphics) Render(env *core.Environment, turtles []*core.Turtle) {
g.renderer.Present()
g.window.UpdateSurface()
surface, _ := g.window.GetSurface()
surface.SaveBMP("./images/" + strconv.Itoa(g.t) + ".bmp")
// surface, _ := g.window.GetSurface()
// surface.SaveBMP("./images/" + strconv.Itoa(g.t) + ".bmp")
g.t++
}

View File

@ -89,6 +89,8 @@ func main() {
for i := 0; i < *numTurtles; i++ {
turtles[i] = core.NewTurtle(env, &actors.SlimeMold{SniffDistance: 20})
}
env.InitPheromone("trail")
g.ColorPheromone("trail", [4]uint8{0x81, 0, 0x81, 0x00})
}
running := true