Skip to content

Commit

Permalink
Bump donburi
Browse files Browse the repository at this point in the history
  • Loading branch information
m110 committed Nov 6, 2022
1 parent 77999d4 commit bcda8f0
Show file tree
Hide file tree
Showing 58 changed files with 141 additions and 229 deletions.
8 changes: 4 additions & 4 deletions archetype/airbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewAirbaseAirplane(w donburi.World, position math.Vec2, faction component.P

originalRotation := -90.0

t := transform.GetTransform(airplane)
t := transform.Transform.Get(airplane)
t.LocalPosition = position
t.LocalRotation = originalRotation

Expand All @@ -41,7 +41,7 @@ func NewAirbaseAirplane(w donburi.World, position math.Vec2, faction component.P
NewCrosshair(w, airplane)

shadow := NewShadow(w, airplane)
transform.GetTransform(shadow).LocalPosition = math.Vec2{}
transform.Transform.Get(shadow).LocalPosition = math.Vec2{}
}

func NewCrosshair(w donburi.World, parent *donburi.Entry) {
Expand All @@ -52,7 +52,7 @@ func NewCrosshair(w donburi.World, parent *donburi.Entry) {
),
)

transform.GetTransform(crosshair).LocalScale = math.Vec2{X: 2.5, Y: 2.5}
transform.Transform.Get(crosshair).LocalScale = math.Vec2{X: 2.5, Y: 2.5}

transform.AppendChild(parent, crosshair, false)

Expand All @@ -76,5 +76,5 @@ func NewCrosshair(w donburi.World, parent *donburi.Entry) {
})

transform.AppendChild(crosshair, label, false)
transform.GetTransform(label).LocalPosition = math.Vec2{X: -25, Y: 30}
transform.Transform.Get(label).LocalPosition = math.Vec2{X: -25, Y: 30}
}
4 changes: 2 additions & 2 deletions archetype/bullet.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func newPlayerBullet(w donburi.World, position math.Vec2, localRotation float64)

originalRotation := -90.0

t := transform.GetTransform(bullet)
t := transform.Transform.Get(bullet)
t.LocalPosition = position
t.LocalRotation = originalRotation + localRotation

Expand Down Expand Up @@ -115,7 +115,7 @@ func NewEnemyBullet(w donburi.World, position math.Vec2, rotation float64) {

image := assets.Rocket

t := transform.GetTransform(bullet)
t := transform.Transform.Get(bullet)
t.LocalPosition = position
t.LocalRotation = rotation

Expand Down
4 changes: 2 additions & 2 deletions archetype/camera.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func NewCamera(w donburi.World, startPosition math.Vec2) *donburi.Entry {
),
)

cameraCamera := component.GetCamera(camera)
cameraCamera := component.Camera.Get(camera)
cameraCamera.MoveTimer = engine.NewTimer(time.Second * 3)
transform.GetTransform(camera).LocalPosition = startPosition
transform.Transform.Get(camera).LocalPosition = startPosition

return camera
}
Expand Down
2 changes: 1 addition & 1 deletion archetype/collectible.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewRandomCollectible(w donburi.World, position math.Vec2) {
collectibleType = component.CollectibleTypeHealth
}

transform.GetTransform(collectible).LocalPosition = position
transform.Transform.Get(collectible).LocalPosition = position

donburi.SetValue(collectible, component.Sprite, component.SpriteData{
Image: image,
Expand Down
14 changes: 7 additions & 7 deletions archetype/enemy.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func NewEnemySpawn(w donburi.World, position math.Vec2, spawnFunc component.Spaw
),
)

transform.GetTransform(spawn).LocalPosition = position
component.GetSpawnable(spawn).SpawnFunc = spawnFunc
transform.Transform.Get(spawn).LocalPosition = position
component.Spawnable.Get(spawn).SpawnFunc = spawnFunc
}

func NewEnemyAirplane(
Expand All @@ -49,7 +49,7 @@ func NewEnemyAirplane(

originalRotation := -90.0

t := transform.GetTransform(airplane)
t := transform.Transform.Get(airplane)
t.LocalPosition = position
t.LocalRotation = originalRotation + rotation

Expand Down Expand Up @@ -112,7 +112,7 @@ func NewEnemyTank(
)

transform.Reset(tank)
t := transform.GetTransform(tank)
t := transform.Transform.Get(tank)
t.LocalPosition = position
t.LocalRotation = rotation

Expand Down Expand Up @@ -164,7 +164,7 @@ func NewEnemyTank(

originalRotation := 90.0
transform.Reset(gun)
gunT := transform.GetTransform(gun)
gunT := transform.Transform.Get(gun)
gunT.LocalPosition = position
gunT.LocalRotation = originalRotation + rotation

Expand Down Expand Up @@ -195,7 +195,7 @@ func newDamageIndicator(w donburi.World, parent *donburi.Entry) *component.Sprit
),
)

parentSprite := component.GetSprite(parent)
parentSprite := component.Sprite.Get(parent)

image := ebiten.NewImage(parentSprite.Image.Size())
op := &ebiten.DrawImageOptions{}
Expand All @@ -212,5 +212,5 @@ func newDamageIndicator(w donburi.World, parent *donburi.Entry) *component.Sprit

transform.AppendChild(parent, indicator, false)

return component.GetSprite(indicator)
return component.Sprite.Get(indicator)
}
10 changes: 5 additions & 5 deletions archetype/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var Players = map[int]PlayerSettings{

func playerSpawn(w donburi.World, playerNumber int) math.Vec2 {
game := component.MustFindGame(w)
cameraPos := transform.GetTransform(MustFindCamera(w)).LocalPosition
cameraPos := transform.Transform.Get(MustFindCamera(w)).LocalPosition

switch playerNumber {
case 1:
Expand Down Expand Up @@ -148,15 +148,15 @@ func NewPlayerAirplane(w donburi.World, player component.PlayerData, faction com
PlayerNumber: player.PlayerNumber,
Faction: faction,
InvulnerableTimer: engine.NewTimer(time.Second * 3),
InvulnerableIndicator: component.GetSprite(shield),
InvulnerableIndicator: component.Sprite.Get(shield),
})

component.GetPlayerAirplane(airplane).StartInvulnerability()
component.PlayerAirplane.Get(airplane).StartInvulnerability()

originalRotation := -90.0

pos := playerSpawn(w, player.PlayerNumber)
t := transform.GetTransform(airplane)
t := transform.Transform.Get(airplane)
t.LocalPosition = pos
t.LocalRotation = originalRotation

Expand Down Expand Up @@ -231,7 +231,7 @@ func NewPlayerAirplane(w donburi.World, player component.PlayerData, faction com
func MustFindPlayerByNumber(w donburi.World, playerNumber int) *component.PlayerData {
var foundPlayer *component.PlayerData
query.NewQuery(filter.Contains(component.Player)).EachEntity(w, func(e *donburi.Entry) {
player := component.GetPlayer(e)
player := component.Player.Get(e)
if player.PlayerNumber == playerNumber {
foundPlayer = player
}
Expand Down
4 changes: 2 additions & 2 deletions archetype/shadow.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ func NewShadow(w donburi.World, parent *donburi.Entry) *donburi.Entry {

transform.AppendChild(parent, shadow, false)

transform := transform.GetTransform(shadow)
transform := transform.Transform.Get(shadow)
transform.LocalPosition = math.Vec2{
X: -MaxShadowPosition,
Y: MaxShadowPosition,
}

parentSprite := component.GetSprite(parent)
parentSprite := component.Sprite.Get(parent)

spriteData := component.SpriteData{
Image: ShadowImage(parentSprite.Image),
Expand Down
2 changes: 1 addition & 1 deletion archetype/wreck.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func NewAirplaneWreck(w donburi.World, parent *donburi.Entry, sprite *component.
pos.X += p.X + p.Width/2
pos.Y += p.Y + p.Height/2

transform.GetTransform(wreck).LocalPosition = pos
transform.Transform.Get(wreck).LocalPosition = pos

donburi.SetValue(wreck, component.Sprite, component.SpriteData{
Image: img,
Expand Down
4 changes: 0 additions & 4 deletions component/ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,3 @@ type AIData struct {
}

var AI = donburi.NewComponentType[AIData]()

func GetAI(entry *donburi.Entry) *AIData {
return donburi.Get[AIData](entry, AI)
}
4 changes: 0 additions & 4 deletions component/altitude.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@ func (a *AltitudeData) Update() {
}

var Altitude = donburi.NewComponentType[AltitudeData]()

func GetAltitude(entry *donburi.Entry) *AltitudeData {
return donburi.Get[AltitudeData](entry, Altitude)
}
4 changes: 0 additions & 4 deletions component/bounds.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ type BoundsData struct {

// Bounds indicates that the entity can't move of out the screen.
var Bounds = donburi.NewComponentType[BoundsData]()

func GetBounds(entry *donburi.Entry) *BoundsData {
return donburi.Get[BoundsData](entry, Bounds)
}
4 changes: 0 additions & 4 deletions component/camera.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ type CameraData struct {
}

var Camera = donburi.NewComponentType[CameraData]()

func GetCamera(entry *donburi.Entry) *CameraData {
return donburi.Get[CameraData](entry, Camera)
}
4 changes: 0 additions & 4 deletions component/collectible.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ type CollectibleData struct {
}

var Collectible = donburi.NewComponentType[CollectibleData]()

func GetCollectible(entry *donburi.Entry) *CollectibleData {
return donburi.Get[CollectibleData](entry, Collectible)
}
4 changes: 0 additions & 4 deletions component/collider.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ type ColliderData struct {
}

var Collider = donburi.NewComponentType[ColliderData]()

func GetCollider(entry *donburi.Entry) *ColliderData {
return donburi.Get[ColliderData](entry, Collider)
}
4 changes: 0 additions & 4 deletions component/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@ type DebugData struct {
}

var Debug = donburi.NewComponentType[DebugData]()

func GetDebug(entry *donburi.Entry) *DebugData {
return donburi.Get[DebugData](entry, Debug)
}
4 changes: 0 additions & 4 deletions component/despawnable.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ type DespawnableData struct {
}

var Despawnable = donburi.NewComponentType[DespawnableData]()

func GetDespawnable(entry *donburi.Entry) *DespawnableData {
return donburi.Get[DespawnableData](entry, Despawnable)
}
4 changes: 0 additions & 4 deletions component/evolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,3 @@ func (e *EvolutionData) StopEvolving() {
}

var Evolution = donburi.NewComponentType[EvolutionData]()

func GetEvolution(entry *donburi.Entry) *EvolutionData {
return donburi.Get[EvolutionData](entry, Evolution)
}
6 changes: 1 addition & 5 deletions component/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,10 @@ type Settings struct {

var Game = donburi.NewComponentType[GameData]()

func GetGame(entry *donburi.Entry) *GameData {
return donburi.Get[GameData](entry, Game)
}

func MustFindGame(w donburi.World) *GameData {
game, ok := query.NewQuery(filter.Contains(Game)).FirstEntity(w)
if !ok {
panic("game not found")
}
return GetGame(game)
return Game.Get(game)
}
4 changes: 0 additions & 4 deletions component/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,3 @@ func (d *HealthData) HideDamageIndicator() {
}

var Health = donburi.NewComponentType[HealthData]()

func GetHealth(entry *donburi.Entry) *HealthData {
return donburi.Get[HealthData](entry, Health)
}
4 changes: 0 additions & 4 deletions component/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@ type InputData struct {
}

var Input = donburi.NewComponentType[InputData]()

func GetInput(entry *donburi.Entry) *InputData {
return donburi.Get[InputData](entry, Input)
}
4 changes: 0 additions & 4 deletions component/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ type LabelData struct {
}

var Label = donburi.NewComponentType[LabelData]()

func GetLabel(entry *donburi.Entry) *LabelData {
return donburi.Get[LabelData](entry, Label)
}
4 changes: 0 additions & 4 deletions component/level.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ type LevelData struct {

var Level = donburi.NewComponentType[LevelData]()

func GetLevel(entry *donburi.Entry) *LevelData {
return donburi.Get[LevelData](entry, Level)
}

func MustFindLevel(w donburi.World) *donburi.Entry {
level, ok := query.NewQuery(filter.Contains(Level)).FirstEntity(w)
if !ok {
Expand Down
4 changes: 0 additions & 4 deletions component/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ type ObserverData struct {
}

var Observer = donburi.NewComponentType[ObserverData]()

func GetObserver(entry *donburi.Entry) *ObserverData {
return donburi.Get[ObserverData](entry, Observer)
}
4 changes: 0 additions & 4 deletions component/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,3 @@ func (d *PlayerData) EvolutionLevel() int {
}

var Player = donburi.NewComponentType[PlayerData]()

func GetPlayer(entry *donburi.Entry) *PlayerData {
return donburi.Get[PlayerData](entry, Player)
}
4 changes: 0 additions & 4 deletions component/playerairplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,3 @@ func (d *PlayerAirplaneData) StopInvulnerability() {
}

var PlayerAirplane = donburi.NewComponentType[PlayerAirplaneData]()

func GetPlayerAirplane(entry *donburi.Entry) *PlayerAirplaneData {
return donburi.Get[PlayerAirplaneData](entry, PlayerAirplane)
}
4 changes: 0 additions & 4 deletions component/playerselect.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,3 @@ func (p *PlayerSelectData) Release() {
}

var PlayerSelect = donburi.NewComponentType[PlayerSelectData]()

func GetPlayerSelect(entry *donburi.Entry) *PlayerSelectData {
return donburi.Get[PlayerSelectData](entry, PlayerSelect)
}
4 changes: 0 additions & 4 deletions component/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@ type ScriptData struct {
}

var Script = donburi.NewComponentType[ScriptData]()

func GetScript(entry *donburi.Entry) *ScriptData {
return donburi.Get[ScriptData](entry, Script)
}
4 changes: 0 additions & 4 deletions component/shooter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,3 @@ type ShooterData struct {
}

var Shooter = donburi.NewComponentType[ShooterData]()

func GetShooter(entry *donburi.Entry) *ShooterData {
return donburi.Get[ShooterData](entry, Shooter)
}
4 changes: 0 additions & 4 deletions component/spawnable.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@ type SpawnableData struct {
}

var Spawnable = donburi.NewComponentType[SpawnableData]()

func GetSpawnable(entry *donburi.Entry) *SpawnableData {
return donburi.Get[SpawnableData](entry, Spawnable)
}
4 changes: 0 additions & 4 deletions component/sprite.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,3 @@ func (s *SpriteData) Hide() {
}

var Sprite = donburi.NewComponentType[SpriteData]()

func GetSprite(entry *donburi.Entry) *SpriteData {
return donburi.Get[SpriteData](entry, Sprite)
}
4 changes: 0 additions & 4 deletions component/velocity.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ type VelocityData struct {
}

var Velocity = donburi.NewComponentType[VelocityData]()

func GetVelocity(entry *donburi.Entry) *VelocityData {
return donburi.Get[VelocityData](entry, Velocity)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/hajimehoshi/ebiten/v2 v2.4.7
github.com/lafriks/go-tiled v0.10.0
github.com/samber/lo v1.30.0
github.com/yohamta/donburi v1.2.23
github.com/yohamta/donburi v1.3.0
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69
)

Expand Down
Loading

0 comments on commit bcda8f0

Please sign in to comment.