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
787 B
36 lines
787 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.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 |
|
}
|
|
|