tweak projection
This commit is contained in:
parent
9df7e73940
commit
a62363bcbc
|
@ -5,6 +5,7 @@ import (
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"relay/game"
|
"relay/game"
|
||||||
|
@ -145,7 +146,7 @@ func renderRacer(ctx context, oldRacer, racer game.Racer, active bool, c pixel.R
|
||||||
projC.B *= alpha
|
projC.B *= alpha
|
||||||
projC.A = alpha
|
projC.A = alpha
|
||||||
im.Color = projC
|
im.Color = projC
|
||||||
w := racerWidth * 2
|
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,
|
||||||
|
@ -154,6 +155,8 @@ func renderRacer(ctx context, oldRacer, racer game.Racer, active bool, c pixel.R
|
||||||
X: pos.X + w*float64(racer.Kinetics.V+1),
|
X: pos.X + w*float64(racer.Kinetics.V+1),
|
||||||
Y: pos.Y + w,
|
Y: pos.Y + w,
|
||||||
}
|
}
|
||||||
|
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)
|
||||||
|
@ -162,7 +165,7 @@ func renderRacer(ctx context, oldRacer, racer game.Racer, active bool, c pixel.R
|
||||||
|
|
||||||
bounds := pic.Bounds()
|
bounds := pic.Bounds()
|
||||||
sprite := pixel.NewSprite(pic, bounds)
|
sprite := pixel.NewSprite(pic, bounds)
|
||||||
sprite.DrawColorMask(ctx.w, pixel.IM.Moved(pos).ScaledXY(pos, pixel.Vec{2, 2}), c)
|
sprite.DrawColorMask(ctx.w, pixel.IM.Moved(pos).ScaledXY(pos, pixel.Vec{1.7, 1.7}), c)
|
||||||
|
|
||||||
im := imdraw.New(nil)
|
im := imdraw.New(nil)
|
||||||
for i := 0; i < racer.Battery.Capacity; i++ {
|
for i := 0; i < racer.Battery.Capacity; i++ {
|
||||||
|
|
2
main.go
2
main.go
|
@ -47,7 +47,7 @@ func run() error {
|
||||||
if !rs.Animating {
|
if !rs.Animating {
|
||||||
sOld = s
|
sOld = s
|
||||||
}
|
}
|
||||||
case w.Pressed(pixelgl.KeySpace) || true:
|
case w.Pressed(pixelgl.KeySpace):
|
||||||
log.Printf("TURN %d", turn)
|
log.Printf("TURN %d", turn)
|
||||||
rs.Animating = true
|
rs.Animating = true
|
||||||
rs.Frame = 0
|
rs.Frame = 0
|
||||||
|
|
Loading…
Reference in New Issue