Ejemplo n.º 1
0
func (c *HideSystem) Update(e *ecs.Entity, dt float32) {
	var render *engi.RenderComponent
	if !e.Component(&render) {
		return
	}
	if rand.Int()%10 == 0 {
		render.SetPriority(engi.Hidden)
	} else {
		render.SetPriority(engi.MiddleGround)
	}
}
Ejemplo n.º 2
0
func (c *ScoreSystem) Update(entity *ecs.Entity, dt float32) {
	var render *engi.RenderComponent
	var space *engi.SpaceComponent

	if !entity.Component(&render) || !entity.Component(&space) {
		return
	}

	if !c.upToDate {
		c.scoreLock.RLock()
		render.Label = fmt.Sprintf("%v vs %v", c.PlayerOneScore, c.PlayerTwoScore)
		c.upToDate = true
		c.scoreLock.RUnlock()

		render.SetDrawable(basicFont.Render(render.Label))
		width := len(render.Label) * 20

		space.Position.X = float32(400 - (width / 2))
	}
}
Ejemplo n.º 3
0
func (c *ScaleSystem) Update(e *ecs.Entity, dt float32) {
	var render *engi.RenderComponent
	if !e.Component(&render) {
		return
	}
	var mod float32

	if rand.Int()%2 == 0 {
		mod = 0.1
	} else {
		mod = -0.1
	}

	if render.Scale().X+mod >= 15 || render.Scale().X+mod <= 1 {
		mod *= -1
	}

	newScale := render.Scale()
	newScale.AddScalar(mod)
	render.SetScale(newScale)
}