2023-12-23 00:09:07 +03:00
|
|
|
package main
|
|
|
|
|
2024-05-19 21:11:58 +03:00
|
|
|
import "surdeus.su/core/gg"
|
2023-12-23 00:09:07 +03:00
|
|
|
|
|
|
|
type Rect struct {
|
|
|
|
gg.DrawableRectangle
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewRect() *Rect {
|
|
|
|
ret := &Rect{}
|
2024-01-22 10:23:47 +03:00
|
|
|
ret.SetScale(gg.V(5, 5))
|
2023-12-23 00:09:07 +03:00
|
|
|
ret.Color = gg.Color{
|
|
|
|
gg.MaxColorV,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
gg.MaxColorV,
|
|
|
|
}
|
|
|
|
ret.Layer = RectL
|
2024-01-08 06:09:36 +03:00
|
|
|
ret.Visible = true
|
2024-01-22 20:08:50 +03:00
|
|
|
//ret.Collidable = true
|
2024-01-16 04:11:42 +03:00
|
|
|
ret.Width = 100
|
|
|
|
ret.Height = 200
|
2023-12-23 00:09:07 +03:00
|
|
|
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2024-01-16 07:37:53 +03:00
|
|
|
func (r *Rect) CollisionType() gg.CollisionType {
|
|
|
|
return gg.CollisionStaticPhysics
|
|
|
|
}
|
|
|
|
|
2023-12-23 00:09:07 +03:00
|
|
|
func (r *Rect) Update(c *Context) {
|
|
|
|
//r.R += 0.3 * e.DT()
|
2024-01-21 16:34:23 +03:00
|
|
|
dt := c.Dt().Seconds()
|
2023-12-23 00:09:07 +03:00
|
|
|
//r.Position = c.AbsCursorPosition()
|
2024-05-19 21:11:58 +03:00
|
|
|
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))
|
|
|
|
}
|
|
|
|
}
|
2023-12-23 00:09:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Rect) Event(c *Context) {
|
|
|
|
}
|