gg/cmd/test/rect.go
2024-05-19 23:11:58 +05:00

50 lines
830 B
Go

package main
import "surdeus.su/core/gg"
type Rect struct {
gg.DrawableRectangle
}
func NewRect() *Rect {
ret := &Rect{}
ret.SetScale(gg.V(5, 5))
ret.Color = gg.Color{
gg.MaxColorV,
0,
0,
gg.MaxColorV,
}
ret.Layer = RectL
ret.Visible = true
//ret.Collidable = true
ret.Width = 100
ret.Height = 200
return ret
}
func (r *Rect) CollisionType() gg.CollisionType {
return gg.CollisionStaticPhysics
}
func (r *Rect) Update(c *Context) {
//r.R += 0.3 * e.DT()
dt := c.Dt().Seconds()
//r.Position = c.AbsCursorPosition()
for _, v := range c.Keys() {
switch v {
case gg.KeyArrowUp:
r.Move(gg.Y(-10 * dt))
case gg.KeyArrowDown:
r.Move(gg.Y(10 * dt))
case gg.KeyArrowLeft:
r.Move(gg.X(-10 * dt))
case gg.KeyArrowRight:
r.Move(gg.X(10 * dt))
}
}
}
func (r *Rect) Event(c *Context) {
}