Ejemplo n.º 1
0
func (pu *PowerUp) OnCollisionEnter(arbiter engine.Arbiter) bool {
	if pu.GameObject() != nil && (arbiter.GameObjectA() == Player || arbiter.GameObjectB() == Player) {
		PowerUpShip(pu.Type)
		pu.GameObject().Destroy()
	}
	return true
}
Ejemplo n.º 2
0
func (s *Enemy) OnCollisionPostSolve(arbiter engine.Arbiter) {
	if arbiter.GameObjectB() != nil {
		if arbiter.GameObjectB().Tag != "lader" && arbiter.GameObjectA().Tag != "lader" {
			count := 0
			for _, con := range arbiter.Contacts {
				if arbiter.Normal(con).Y < -0.9 {
					count++

				}
			}
			if count >= 1 {
				if s.GameObject().Sprite.CurrentAnimation() == "enemy_jump" {
					s.GameObject().Sprite.SetAnimation("enemy_stand")
				}
				s.LastFloor = arbiter.GameObjectB()

				s.OnGround = true
			}
			count = 0
			for _, con := range arbiter.Contacts {
				if math.Abs(float64(arbiter.Normal(con).X)) > 0.9 {
					count++

				}
			}
			if count >= 1 {
				s.jump = true
			}
			if arbiter.GameObjectB().Tag == "player" {
				if Player.PlComp.Hitable && s.Attack {
					Player.PlComp.Hit()
				}
				if s.hitable && Player.PlComp.Attack {
					s.Hit()
				}
			}
		}
	}

}
Ejemplo n.º 3
0
func (pl *Player) OnCollisionPostSolve(arbiter engine.Arbiter) {
	if arbiter.GameObjectB() == nil {
		return
	}
	if arbiter.GameObjectB().Tag != "lader" && arbiter.GameObjectA().Tag != "lader" {
		count := 0
		for _, con := range arbiter.Contacts {
			if arbiter.Normal(con).Y < -0.9 {
				count++

			}
		}
		if count >= 1 {
			if pl.GameObject().Sprite.CurrentAnimation() == "player_jump" {
				pl.GameObject().Sprite.SetAnimation("player_stand")
			}
			pl.LastFloor = arbiter.GameObjectB()

			pl.OnGround = true
		}
	}

}