//go:build example // +build example package entity import ( "math" "time" "code.rocketnine.space/tslocum/gohan" "code.rocketnine.space/tslocum/gohan/_examples/twinstick/component" ) func NewPlayer() gohan.EntityID { player := gohan.NextEntityID() // 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{ X: -1, Y: -1, }) player.AddComponent(&component.VelocityComponent{}) weapon := &component.WeaponComponent{ Ammo: math.MaxInt64, Damage: 1, FireRate: 100 * time.Millisecond, BulletSpeed: 15, } player.AddComponent(weapon) return player }