package main import "surdeus.su/core/gg" import "surdeus.su/core/gg/ox" import "surdeus.su/core/gg/mx" type Rect struct { ox.DrawableRectangle } func NewRect() *Rect { ret := &Rect{} ret.SetScale(mx.V(5, 5)) ret.Color = gg.RGBA(1, 0, 0, 1) ret.Layer = LayerRect ret.Visible = true //ret.Collidable = true ret.Width = 100 ret.Height = 200 return ret } func (r *Rect) OnUpdate(c Context) { //r.R += 0.3 * e.DT() e := c.Engine() dt := e.DT().Seconds() shiftPressed := e.IsPressed(gg.KeyShift) d := float64(1) if shiftPressed { d *= -1 } //r.Position = c.AbsCursorPosition() for _, v := range e.GetKeyboardKeys() { switch v { case gg.KeyArrowUp: r.Move(mx.VY(-10 * dt)) case gg.KeyArrowDown: r.Move(mx.VY(10 * dt)) case gg.KeyArrowLeft: r.Move(mx.VX(-10 * dt)) case gg.KeyArrowRight: r.Move(mx.VX(10 * dt)) case gg.KeyLeftBracket: r.Rotate(d*mx.Pi * 0.3 * dt) } } } /*func (r *Rect) CollisionType() gg.CollisionType { return gg.CollisionStaticPhysics }*/