This commit is contained in:
Andrey Parhomenko 2023-12-28 14:34:52 +03:00
parent 14f0db2d40
commit 2821ffd442
2 changed files with 9 additions and 6 deletions

View file

@ -56,9 +56,12 @@ func (p *Player) Update(c *Context) {
cam := c.Camera cam := c.Camera
keys := c.Keys() keys := c.Keys()
shift := c.IsPressed(gg.KeyShift)
//p.Uniforms["Random"] = any(rand.Float32()) //p.Uniforms["Random"] = any(rand.Float32())
for _, v := range keys { for _, v := range keys {
switch v { switch v {
case gg.KeyQ :
p.Scale = p.Scale.Add(gg.V(p.ScaleSpeed * dt, 0))
case gg.KeyArrowUp: case gg.KeyArrowUp:
cam.Position.Y += p.MoveSpeed * dt cam.Position.Y += p.MoveSpeed * dt
case gg.KeyArrowLeft: case gg.KeyArrowLeft:
@ -80,31 +83,31 @@ func (p *Player) Update(c *Context) {
case gg.KeyT: case gg.KeyT:
cam.Rotation -= gg.Pi * p.ScaleSpeed * dt cam.Rotation -= gg.Pi * p.ScaleSpeed * dt
case gg.KeyRightBracket: case gg.KeyRightBracket:
if c.IsPressed(gg.KeyShift) { if shift {
p.Rotation -= gg.Pi * 0.3 * dt p.Rotation -= gg.Pi * 0.3 * dt
} else { } else {
p.Rotation += gg.Pi * 0.3 * dt p.Rotation += gg.Pi * 0.3 * dt
} }
case gg.KeyF: case gg.KeyF:
if c.IsPressed(gg.KeyShift) { if shift {
cam.Scale = cam.Scale.Add(gg.V2(p.ScaleSpeed * dt)) cam.Scale = cam.Scale.Add(gg.V2(p.ScaleSpeed * dt))
} else { } else {
cam.Scale = cam.Scale.Add(gg.V2(-p.ScaleSpeed * dt)) cam.Scale = cam.Scale.Add(gg.V2(-p.ScaleSpeed * dt))
} }
case gg.KeyG: case gg.KeyG:
if c.IsPressed(gg.KeyShift) { if shift {
cam.Scale.Y -= gg.Pi * p.ScaleSpeed * dt cam.Scale.Y -= gg.Pi * p.ScaleSpeed * dt
} else { } else {
cam.Scale.Y += gg.Pi * p.ScaleSpeed * dt cam.Scale.Y += gg.Pi * p.ScaleSpeed * dt
} }
case gg.KeyV: case gg.KeyV:
if c.IsPressed(gg.KeyShift) { if shift {
tri.Rotation -= gg.Pi * 0.3 * dt tri.Rotation -= gg.Pi * 0.3 * dt
} else { } else {
tri.Rotation += gg.Pi * 0.3 * dt tri.Rotation += gg.Pi * 0.3 * dt
} }
case gg.KeyLeftBracket: case gg.KeyLeftBracket:
if c.IsPressed(gg.KeyShift) { if shift {
rect.Rotation -= gg.Pi * 0.3 * dt rect.Rotation -= gg.Pi * 0.3 * dt
} else { } else {
rect.Rotation += gg.Pi * 0.3 * dt rect.Rotation += gg.Pi * 0.3 * dt

View file

@ -10,7 +10,6 @@ type Tri struct {
func NewTri() *Tri { func NewTri() *Tri {
ret := &Tri{} ret := &Tri{}
ret.Parent = player
ret.Transform.Scale = gg.V2(1) ret.Transform.Scale = gg.V2(1)
ret.Triangles = gg.Triangles{ ret.Triangles = gg.Triangles{
@ -23,6 +22,7 @@ func NewTri() *Tri {
ret.Color = gg.Rgba(1, 1, 0, 1) ret.Color = gg.Rgba(1, 1, 0, 1)
ret.Visible = true ret.Visible = true
ret.Layer = TriangleL ret.Layer = TriangleL
ret.Connect(player)
return ret return ret
} }