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.
27 lines
529 B
27 lines
529 B
//go:build example |
|
// +build example |
|
|
|
package component |
|
|
|
import ( |
|
"code.rocketnine.space/tslocum/gohan" |
|
"code.rocketnine.space/tslocum/gohan/examples/twinstick/world" |
|
) |
|
|
|
type VelocityComponent struct { |
|
X, Y float64 |
|
} |
|
|
|
var VelocityComponentID = world.World.NewComponentID() |
|
|
|
func (c *VelocityComponent) ComponentID() gohan.ComponentID { |
|
return VelocityComponentID |
|
} |
|
|
|
func Velocity(ctx *gohan.Context) *VelocityComponent { |
|
c, ok := ctx.Component(VelocityComponentID).(*VelocityComponent) |
|
if !ok { |
|
return nil |
|
} |
|
return c |
|
}
|
|
|