Entity Component System framework for Ebitengine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
781 B

//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.Entity {
player := gohan.NewEntity()
// 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
}