2021-12-21 01:28:56 +00:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.rocketnine.space/tslocum/brownboxbatman/asset"
|
|
|
|
"code.rocketnine.space/tslocum/brownboxbatman/component"
|
|
|
|
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
|
|
|
|
"code.rocketnine.space/tslocum/gohan"
|
|
|
|
)
|
|
|
|
|
2021-12-26 23:13:32 +00:00
|
|
|
func NewPlayerBullet(x, y, xSpeed, ySpeed float64) gohan.Entity {
|
2021-12-21 01:28:56 +00:00
|
|
|
bullet := ECS.NewEntity()
|
|
|
|
|
|
|
|
ECS.AddComponent(bullet, &component.PositionComponent{
|
|
|
|
X: x,
|
|
|
|
Y: y,
|
|
|
|
})
|
|
|
|
|
|
|
|
ECS.AddComponent(bullet, &component.VelocityComponent{
|
|
|
|
X: xSpeed,
|
|
|
|
Y: ySpeed,
|
|
|
|
})
|
|
|
|
|
|
|
|
ECS.AddComponent(bullet, &component.SpriteComponent{
|
2021-12-26 23:13:32 +00:00
|
|
|
Image: asset.ImgBlackSquare,
|
2021-12-21 01:28:56 +00:00
|
|
|
})
|
|
|
|
|
2021-12-26 23:13:32 +00:00
|
|
|
ECS.AddComponent(bullet, &component.PlayerBulletComponent{})
|
2021-12-21 01:28:56 +00:00
|
|
|
|
|
|
|
return bullet
|
|
|
|
}
|