show velocity projection at turn end

This commit is contained in:
Luke Meyers 2020-02-08 19:08:33 -08:00
parent 2d32cb9e1d
commit bed8e58489
1 changed files with 19 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import (
"image" "image"
"image/color" "image/color"
_ "image/png" _ "image/png"
"log"
"math" "math"
"math/rand" "math/rand"
"os" "os"
@ -147,16 +148,29 @@ func renderRacer(ctx context, oldRacer, racer game.Racer, active bool, c pixel.R
projC.A = alpha projC.A = alpha
im.Color = projC im.Color = projC
w := pic.Bounds().W() * 0.65 w := pic.Bounds().W() * 0.65
ll := pixel.Vec{ ll := pixel.Vec{
X: pos.X + w, X: pos.X + w,
Y: pos.Y - w, Y: pos.Y - w,
} }
ur := pixel.Vec{
X: pos.X + w*float64(racer.Kinetics.V+1), var ur pixel.Vec
Y: pos.Y + w, if ctx.tween == 1 {
ur = pixel.Vec{
X: pos.X + w*float64(racer.Kinetics.V+1),
Y: pos.Y + w,
}
log.Printf("ur: %+v", ur)
ur.X = math.Max(ur.X, ll.X)
} else {
ur = pixel.Vec{
X: pos.X + w*float64(racer.Kinetics.V+1),
Y: pos.Y + w,
}
ur.X = math.Min(ur.X, newPos.X+racerWidth)
ur.X = math.Max(ur.X, ll.X)
} }
ur.X = math.Min(ur.X, newPos.X+racerWidth)
ur.X = math.Max(ur.X, ll.X)
im.Push(ll) im.Push(ll)
im.Push(ur) im.Push(ur)
im.Rectangle(0) im.Rectangle(0)