This commit is contained in:
Andrey Parhomenko 2024-05-19 23:11:58 +05:00
parent e78a0d9881
commit e697383867
10 changed files with 136 additions and 128 deletions

3
btest.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
#
go build -o ./exe/ ./cmd/test/

View file

@ -1,10 +1,11 @@
package main package main
import ( import (
"vultras.su/core/gg" "surdeus.su/core/gg"
"fmt" "fmt"
"encoding/json" "encoding/json"
) )
type Float = gg.Float type Float = gg.Float
func EdgesFromVals(vals ...Float) gg.Edges { func EdgesFromVals(vals ...Float) gg.Edges {

View file

@ -1,6 +1,6 @@
package main package main
import "vultras.su/core/gg" import "surdeus.su/core/gg"
import ( import (
"strings" "strings"
@ -13,13 +13,15 @@ type Debug struct {
} }
func (d *Debug) Update(c *Context) { func (d *Debug) Update(c *Context) {
for _, e := range c.Events { switch ec := e.(type) { for _, e := range c.Events {
switch ec := e.(type) {
case *gg.KeyDown: case *gg.KeyDown:
switch ec.Key { switch ec.Key {
case gg.KeyF11: case gg.KeyF11:
d.Visible = !d.Visible d.Visible = !d.Visible
} }
}} }
}
} }
func (d *Debug) Draw(c *Context) []gg.EVertex { func (d *Debug) Draw(c *Context) []gg.EVertex {
@ -97,4 +99,3 @@ func (d *Debug) Draw(c *Context) []gg.EVertex {
return nil return nil
} }

View file

@ -1,7 +1,7 @@
package main package main
import ( import (
"vultras.su/core/gg" "surdeus.su/core/gg"
"github.com/hajimehoshi/ebiten/v2/examples/resources/images" "github.com/hajimehoshi/ebiten/v2/examples/resources/images"
"github.com/hajimehoshi/ebiten/v2/examples/resources/fonts" "github.com/hajimehoshi/ebiten/v2/examples/resources/fonts"
//_ "github.com/silbinarywolf/preferdiscretegpu" //_ "github.com/silbinarywolf/preferdiscretegpu"
@ -19,15 +19,19 @@ type Grid struct {
func (grid *Grid) Update(c *Context) { func (grid *Grid) Update(c *Context) {
//d := c.IsPressed(gg.KeyShift) //d := c.IsPressed(gg.KeyShift)
for _, ev := range c.Events { switch e := ev.(type){ for _, ev := range c.Events {
case *gg.KeyDown : switch e.Key { switch e := ev.(type) {
case *gg.KeyDown:
switch e.Key {
case gg.Key9: case gg.Key9:
grid.Cage /= 10 grid.Cage /= 10
grid.Width /= 5 grid.Width /= 5
case gg.Key0: case gg.Key0:
grid.Cage *= 10 grid.Cage *= 10
grid.Width *= 5 grid.Width *= 5
}}} }
}
}
} }
func (grid *Grid) Draw(c *Context) []gg.EVertex { func (grid *Grid) Draw(c *Context) []gg.EVertex {

View file

@ -6,7 +6,7 @@ import (
"time" "time"
) )
import "vultras.su/core/gg" import "surdeus.su/core/gg"
type Player struct { type Player struct {
gg.AnimatedSprite gg.AnimatedSprite
@ -32,7 +32,6 @@ func NewPlayer() *Player {
//ret.Collidable = true //ret.Collidable = true
//ret.Resolvable = true //ret.Resolvable = true
return ret return ret
} }
@ -155,7 +154,8 @@ func (p *Player) Update(c *Context) {
c.Camera.AddScale(gg.V2( c.Camera.AddScale(gg.V2(
ec.Offset.Y * dt * p.ScaleSpeed * 40, ec.Offset.Y * dt * p.ScaleSpeed * 40,
)) ))
}} }
}
} }
@ -173,7 +173,8 @@ func (p *Player) Resolve(c *Context) {
c.Frame(), len(c.Collisions), col.What, col.With, len(col.Crosses), len(col.Points), c.Frame(), len(c.Collisions), col.What, col.With, len(col.Crosses), len(col.Points),
) )
} }
for _, col := range c.Collisions {switch col.Type{ for _, col := range c.Collisions {
switch col.Type {
case gg.CollisionStaticPhysics: case gg.CollisionStaticPhysics:
LOOP: LOOP:
for { for {
@ -183,6 +184,6 @@ func (p *Player) Resolve(c *Context) {
break LOOP break LOOP
} }
} }
}}
} }
}
}

View file

@ -1,6 +1,6 @@
package main package main
import "vultras.su/core/gg" import "surdeus.su/core/gg"
type Rect struct { type Rect struct {
gg.DrawableRectangle gg.DrawableRectangle
@ -32,7 +32,8 @@ func (r *Rect) Update(c *Context) {
//r.R += 0.3 * e.DT() //r.R += 0.3 * e.DT()
dt := c.Dt().Seconds() dt := c.Dt().Seconds()
//r.Position = c.AbsCursorPosition() //r.Position = c.AbsCursorPosition()
for _, v := range c.Keys() { switch v { for _, v := range c.Keys() {
switch v {
case gg.KeyArrowUp: case gg.KeyArrowUp:
r.Move(gg.Y(-10 * dt)) r.Move(gg.Y(-10 * dt))
case gg.KeyArrowDown: case gg.KeyArrowDown:
@ -41,7 +42,8 @@ func (r *Rect) Update(c *Context) {
r.Move(gg.X(-10 * dt)) r.Move(gg.X(-10 * dt))
case gg.KeyArrowRight: case gg.KeyArrowRight:
r.Move(gg.X(10 * dt)) r.Move(gg.X(10 * dt))
}} }
}
} }
func (r *Rect) Event(c *Context) { func (r *Rect) Event(c *Context) {

View file

@ -1,7 +1,7 @@
package main package main
import ( import (
"vultras.su/core/gg" "surdeus.su/core/gg"
//"fmt" //"fmt"
) )

View file

@ -1,6 +1,6 @@
package main package main
import "vultras.su/core/gg" import "surdeus.su/core/gg"
import "fmt" import "fmt"
var ( var (
@ -63,7 +63,8 @@ func (t *Tri) Update(c *Context) {
d = -1 d = -1
} }
for _, key := range keys { switch key { for _, key := range keys {
switch key {
case gg.KeyM: case gg.KeyM:
t.Move(gg.Y(100 * dt * d)) t.Move(gg.Y(100 * dt * d))
@ -91,10 +92,12 @@ func (t *Tri) Update(c *Context) {
if c.Spawn(&tt) == nil { if c.Spawn(&tt) == nil {
counter++ counter++
} }
}} }
}
for _, event := range c.Events { for _, event := range c.Events {
switch e := event.(type) { case *gg.KeyDown: switch e := event.(type) {
case *gg.KeyDown:
switch e.Key { switch e.Key {
case gg.Key1: case gg.Key1:
if t.Connected() { if t.Connected() {
@ -102,6 +105,7 @@ func (t *Tri) Update(c *Context) {
} else { } else {
t.Connect(player) t.Connect(player)
} }
}}}
} }
}
}
}

2
go.mod
View file

@ -1,4 +1,4 @@
module vultras.su/core/gg module surdeus.su/core/gg
go 1.21 go 1.21

View file

@ -1,8 +0,0 @@
version: 3
tasks:
btest:
cmds:
- go build ./cmd/test/
bmath:
cmds:
- go build ./cmd/math/