package main import "surdeus.su/core/gg" import "surdeus.su/core/gg/ox" import "surdeus.su/core/gg/mx" type Grid struct { ox.ObjectImpl ox.Sprite Cage, Width mx.Float } func (grid *Grid) OnUpdate(c Context) { //d := c.IsPressed(gg.KeyShift) for _, down := range c.Events().Keyboard.KeyDowns { switch down.Key { case gg.Key9: grid.Cage /= 10 grid.Width /= 5 case gg.Key0: grid.Cage *= 10 grid.Width *= 5 } } } func NewGrid() *Grid { grid := &Grid{} grid.Transform = ox.T() grid.SetAround(mx.V2(0)) grid.Layer = LayerBackground grid.Images[0] = gg.NewImage(720, 480) grid.Images[0].Fill(gg.RGBA(1, 1, 1, 1)) grid.Shader = bgShader grid.Uniforms = map[string]any{} //bg.Floating = true grid.Visible = true grid.Floating = true grid.Cage = 100 grid.Width = 5 return grid } func (grid *Grid) Draw(c Context) *gg.Drawing { scale := camera.GetScale() pos := camera.GetPosition() grid.Uniforms["Zoom"] = mx.Float(scale.X) grid.Uniforms["PosX"] = pos.X grid.Uniforms["PosY"] = pos.Y grid.Uniforms["Cage"] = grid.Cage grid.Uniforms["Width"] = grid.Width return grid.Sprite.Draw(c) }