This commit is contained in:
Andrey Parhomenko 2024-01-04 17:05:51 +03:00
parent 2821ffd442
commit 3f441641e4
6 changed files with 14 additions and 15 deletions

View file

@ -1,6 +1,6 @@
package main package main
import "github.com/di4f/gg" import "github.com/vultras/gg"
import ( import (
"strings" "strings"

View file

@ -1,7 +1,7 @@
package main package main
import ( import (
"github.com/di4f/gg" "github.com/vultras/gg"
"github.com/hajimehoshi/ebiten/v2/examples/resources/images" "github.com/hajimehoshi/ebiten/v2/examples/resources/images"
"bytes" "bytes"
"log" "log"

View file

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
) )
import "github.com/di4f/gg" import "github.com/vultras/gg"
type Player struct { type Player struct {
gg.Sprite gg.Sprite
@ -60,8 +60,8 @@ func (p *Player) Update(c *Context) {
//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 : case gg.KeyQ:
p.Scale = p.Scale.Add(gg.V(p.ScaleSpeed * dt, 0)) 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:
@ -131,17 +131,16 @@ func (p *Player) Event(c *gg.Context) {
p.Layer = HighestL p.Layer = HighestL
} }
} }
case *gg.MouseMove : case *gg.MouseMove:
if !c.IsButtoned(gg.MouseButtonRight) { if !c.IsButtoned(gg.MouseButtonRight) {
break break
} }
pos := c.Camera.Position pos := c.Camera.Position
c.Camera.Position = pos.Sub(ec.Abs) c.Camera.Position = pos.Sub(ec.Abs)
case *gg.WheelChange : case *gg.WheelChange:
c.Camera.Scale = c.Camera.Scale.Add(gg.V2( c.Camera.Scale = c.Camera.Scale.Add(gg.V2(
ec.Offset.Y * c.DT() * p.ScaleSpeed * 40, ec.Offset.Y * c.DT() * p.ScaleSpeed * 40,
)) ))
} }
} }

View file

@ -1,6 +1,6 @@
package main package main
import "github.com/di4f/gg" import "github.com/vultras/gg"
type Rect struct { type Rect struct {
gg.DrawableRectangle gg.DrawableRectangle

View file

@ -1,6 +1,6 @@
package main package main
import "github.com/di4f/gg" import "github.com/vultras/gg"
import "fmt" import "fmt"
type Tri struct { type Tri struct {
@ -41,20 +41,20 @@ func (t *Tri) Update(c *Context) {
if c.IsPressed(gg.KeyM) { if c.IsPressed(gg.KeyM) {
absPos := tri.AbsPosition() absPos := tri.AbsPosition()
tri.SetAbsPosition( tri.SetAbsPosition(
absPos.Add(gg.V(0, 100 * c.DT() * d)), absPos.Add(gg.V(0, 100*c.DT()*d)),
) )
} }
if c.IsPressed(gg.KeyN) { if c.IsPressed(gg.KeyN) {
absPos := tri.AbsPosition() absPos := tri.AbsPosition()
tri.SetAbsPosition( tri.SetAbsPosition(
absPos.Add(gg.V(100 * c.DT() * d, 0)), absPos.Add(gg.V(100*c.DT()*d, 0)),
) )
} }
} }
func (t *Tri) Event(c *Context) { func (t *Tri) Event(c *Context) {
switch e := c.Event.(type) { switch e := c.Event.(type) {
case *gg.KeyDown : case *gg.KeyDown:
if e.Key != gg.Key1 { if e.Key != gg.Key1 {
break break
} }

2
go.mod
View file

@ -1,4 +1,4 @@
module github.com/di4f/gg module github.com/vultras/gg
go 1.21 go 1.21