Rename example components

This commit is contained in:
Trevor Slocum 2022-02-02 22:27:29 -08:00
parent 193532a951
commit 5cd926a1b2
15 changed files with 25 additions and 25 deletions

View File

@ -3,5 +3,5 @@
package component
type BulletComponent struct {
type Bullet struct {
}

View File

@ -3,6 +3,6 @@
package component
type PositionComponent struct {
type Position struct {
X, Y float64
}

View File

@ -3,6 +3,6 @@
package component
type VelocityComponent struct {
type Velocity struct {
X, Y float64
}

View File

@ -7,7 +7,7 @@ import (
"time"
)
type WeaponComponent struct {
type Weapon struct {
Ammo int
Damage int

View File

@ -11,17 +11,17 @@ import (
func NewBullet(x, y, xSpeed, ySpeed float64) gohan.Entity {
bullet := gohan.NewEntity()
bullet.AddComponent(&component.PositionComponent{
bullet.AddComponent(&component.Position{
X: x,
Y: y,
})
bullet.AddComponent(&component.VelocityComponent{
bullet.AddComponent(&component.Velocity{
X: xSpeed,
Y: ySpeed,
})
bullet.AddComponent(&component.BulletComponent{})
bullet.AddComponent(&component.Bullet{})
return bullet
}

View File

@ -17,14 +17,14 @@ func NewPlayer() gohan.Entity {
// Set position to -1,-1 to indicate the player has not been assigned a
// position yet. We will place the player in the center of the screen when
// we receive the screen dimensions for the first time.
player.AddComponent(&component.PositionComponent{
player.AddComponent(&component.Position{
X: -1,
Y: -1,
})
player.AddComponent(&component.VelocityComponent{})
player.AddComponent(&component.Velocity{})
weapon := &component.WeaponComponent{
weapon := &component.Weapon{
Ammo: math.MaxInt64,
Damage: 1,
FireRate: 100 * time.Millisecond,

View File

@ -11,8 +11,8 @@ import (
)
type DrawBulletsSystem struct {
Position *component.PositionComponent
Bullet *component.BulletComponent
Position *component.Position
Bullet *component.Bullet
op *ebiten.DrawImageOptions
}

View File

@ -11,8 +11,8 @@ import (
)
type drawPlayerSystem struct {
Position *component.PositionComponent
Weapon *component.WeaponComponent
Position *component.Position
Weapon *component.Weapon
op *ebiten.DrawImageOptions
}

View File

@ -18,8 +18,8 @@ func angle(x1, y1, x2, y2 float64) float64 {
}
type fireInputSystem struct {
Position *component.PositionComponent
Weapon *component.WeaponComponent
Position *component.Position
Weapon *component.Weapon
}
func NewFireInputSystem() *fireInputSystem {

View File

@ -10,8 +10,8 @@ import (
)
type movementInputSystem struct {
Velocity *component.VelocityComponent
Weapon *component.WeaponComponent
Velocity *component.Velocity
Weapon *component.Weapon
}
func NewMovementInputSystem() *movementInputSystem {

View File

@ -18,7 +18,7 @@ import (
)
type profileSystem struct {
Weapon *component.WeaponComponent
Weapon *component.Weapon
cpuProfile *os.File
}

View File

@ -11,8 +11,8 @@ import (
)
type MovementSystem struct {
Position *component.PositionComponent
Velocity *component.VelocityComponent
Position *component.Position
Velocity *component.Velocity
}
func NewMovementSystem() *MovementSystem {

View File

@ -14,7 +14,7 @@ import (
)
type printInfoSystem struct {
Weapon *component.WeaponComponent
Weapon *component.Weapon
img *ebiten.Image
op *ebiten.DrawImageOptions

2
go.mod
View File

@ -2,7 +2,7 @@ module code.rocketnine.space/tslocum/gohan
go 1.17
require github.com/hajimehoshi/ebiten/v2 v2.2.3
require github.com/hajimehoshi/ebiten/v2 v2.2.4
require (
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210727001814-0db043d8d5be // indirect

4
go.sum
View File

@ -2,8 +2,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210727001814-0db043d8d5be h1:vEIVIuBApEBQTEJt19GfhoU+zFSV+sNTa9E9FdnRYfk=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210727001814-0db043d8d5be/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/hajimehoshi/bitmapfont/v2 v2.1.3/go.mod h1:2BnYrkTQGThpr/CY6LorYtt/zEPNzvE/ND69CRTaHMs=
github.com/hajimehoshi/ebiten/v2 v2.2.3 h1:jZUP3XWP6mXaw9SCrjWT5Pl6EPuz6FY737dZQgN1KJ4=
github.com/hajimehoshi/ebiten/v2 v2.2.3/go.mod h1:olKl/qqhMBBAm2oI7Zy292nCtE+nitlmYKNF3UpbFn0=
github.com/hajimehoshi/ebiten/v2 v2.2.4 h1:/+qrmbv+W6scgVWwQJ7IyiI2z4y8QM2n0JDHStNC+Ns=
github.com/hajimehoshi/ebiten/v2 v2.2.4/go.mod h1:olKl/qqhMBBAm2oI7Zy292nCtE+nitlmYKNF3UpbFn0=
github.com/hajimehoshi/file2byteslice v0.0.0-20210813153925-5340248a8f41/go.mod h1:CqqAHp7Dk/AqQiwuhV1yT2334qbA/tFWQW0MD2dGqUE=
github.com/hajimehoshi/go-mp3 v0.3.2/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM=
github.com/hajimehoshi/oto v0.6.1/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=