Documentation ¶
Index ¶
- Variables
- type DCamera
- type DSprite
- type DTransform
- func (c *DTransform) GetPosition() (x, y float64)
- func (c *DTransform) GetRotation() float64
- func (c *DTransform) GetScale() (x, y float64)
- func (c *DTransform) IsEnabled() bool
- func (c *DTransform) MoveBy(dx, dy float64)
- func (c *DTransform) MoveTo(x, y float64)
- func (c *DTransform) Reset()
- func (c *DTransform) RotateBy(deg float64)
- func (c *DTransform) RotateTo(deg float64)
- func (c *DTransform) ScaleBothTo(s float64)
- func (c *DTransform) ScaleBy(dx, dy float64)
- func (c *DTransform) ScaleTo(x, y float64)
- func (c *DTransform) SetEnabled(enabled bool)
- func (c *DTransform) X() float64
- func (c *DTransform) Y() float64
- type SpriteRendererResult
Constants ¶
This section is empty.
Variables ¶
View Source
var Camera = sk.NewComponentWithOptions(sk.ComponentOptions[DCamera]{ Dependencies: sk.Components{Transform}, OnCreated: func(d *DCamera) { d.Size = sk.Vec2{X: sk.SCREEN_WIDTH, Y: sk.SCREEN_HEIGHT} d.Surface = ebiten.NewImage(int(d.Size.X), int(d.Size.Y)) d.Zoom = 1 }, })
View Source
var SCREEN_FLIGHT_MOVE_SPEED float64 = 10
View Source
var SCREEN_FLIGHT_ROTATE_SPEED float64 = 90
View Source
var ScreenFlight = sk.NewSystem(func(g *sk.Game) error { dt := g.Timer.DeltaTime if inputs.KeyW.IsDown() { g.Screen.Move(0, -SCREEN_FLIGHT_MOVE_SPEED*dt) } else if inputs.KeyS.IsDown() { g.Screen.Move(0, SCREEN_FLIGHT_MOVE_SPEED*dt) } if inputs.KeyA.IsDown() { g.Screen.Move(-SCREEN_FLIGHT_MOVE_SPEED*dt, 0) } else if inputs.KeyD.IsDown() { g.Screen.Move(SCREEN_FLIGHT_MOVE_SPEED*dt, 0) } if inputs.KeyQ.IsDown() { g.Screen.Rotate(-SCREEN_FLIGHT_ROTATE_SPEED * dt) } else if inputs.KeyE.IsDown() { g.Screen.Rotate(SCREEN_FLIGHT_ROTATE_SPEED * dt) } return nil })
View Source
var ScreenZoom = sk.NewSystem(func(g *sk.Game) error { if inputs.MouseWheelY.IsDown() { wheel := inputs.MouseWheelY.GetFloat() g.Screen.Zoom(wheel) } return nil })
View Source
var Sprite = sk.NewComponent[DSprite]()
View Source
var SpriteRenderer = sk.NewSystem(func(g *sk.Game) error { for _, r := range SpriteRendererQuery.Query() { if !r.Transform.enabled { continue } bounds := r.Sprite.Texture.Image.Bounds() halfX, halfY := float64(bounds.Max.X)/2, float64(bounds.Max.Y)/2 var ops *ebiten.DrawImageOptions if r.Transform.version == r.Sprite.transformVersion { ops = r.Sprite.ops } else { ops = &ebiten.DrawImageOptions{} ops.GeoM.Translate(-halfX, -halfY) ops.GeoM.Scale(r.Transform.scaleX, r.Transform.scaleY) ops.GeoM.Rotate(r.Transform.rotation * mathf.Deg2Rad) ops.GeoM.Translate(r.Transform.posX*g.Screen.PixelsPerUnit, r.Transform.posY*g.Screen.PixelsPerUnit) r.Sprite.transformVersion = r.Transform.version r.Sprite.ops = ops } g.Renderer.Queue(r.Sprite.Layer, r.Sprite.ZIndex, r.Sprite.Texture.Image, ops) } return nil }, SpriteRendererQuery)
View Source
var SpriteRendererQuery = sk.NewQuery[SpriteRendererResult]()
View Source
var Transform = sk.NewComponentWithOptions(sk.ComponentOptions[DTransform]{ OnCreated: func(c *DTransform) { c.enabled = true c.Reset() }, })
Functions ¶
This section is empty.
Types ¶
type DTransform ¶
type DTransform struct {
// contains filtered or unexported fields
}
func (*DTransform) GetPosition ¶
func (c *DTransform) GetPosition() (x, y float64)
func (*DTransform) GetRotation ¶
func (c *DTransform) GetRotation() float64
func (*DTransform) GetScale ¶
func (c *DTransform) GetScale() (x, y float64)
func (*DTransform) IsEnabled ¶
func (c *DTransform) IsEnabled() bool
func (*DTransform) MoveBy ¶
func (c *DTransform) MoveBy(dx, dy float64)
func (*DTransform) MoveTo ¶
func (c *DTransform) MoveTo(x, y float64)
func (*DTransform) Reset ¶
func (c *DTransform) Reset()
func (*DTransform) RotateBy ¶
func (c *DTransform) RotateBy(deg float64)
func (*DTransform) RotateTo ¶
func (c *DTransform) RotateTo(deg float64)
func (*DTransform) ScaleBothTo ¶
func (c *DTransform) ScaleBothTo(s float64)
func (*DTransform) ScaleBy ¶
func (c *DTransform) ScaleBy(dx, dy float64)
func (*DTransform) ScaleTo ¶
func (c *DTransform) ScaleTo(x, y float64)
func (*DTransform) SetEnabled ¶
func (c *DTransform) SetEnabled(enabled bool)
func (*DTransform) X ¶
func (c *DTransform) X() float64
func (*DTransform) Y ¶
func (c *DTransform) Y() float64
type SpriteRendererResult ¶
type SpriteRendererResult struct { Transform *DTransform Sprite *DSprite }
Click to show internal directories.
Click to hide internal directories.