예제 #1
0
func (o *hfence) HandleEvent(ev tcell.Event) bool {
	if o.dead {
		return false
	}
	switch ev := ev.(type) {
	case *EventCollision:
		switch ev.Collider().Layer() {
		case LayerPlayer:
			switch ev.Target() {
			case o.lemit:
				o.destroy(o.lemit, o.remit)
			case o.remit:
				o.destroy(o.remit, o.lemit)
			}
		case LayerShot:
			switch ev.Target() {
			case o.lemit:
				o.destroy(o.lemit, o.remit)
			case o.remit:
				o.destroy(o.remit, o.lemit)
			case o.beam:
				x, y, _, _ := ev.Collider().Bounds()
				props := GameObjectProps{}
				props.PropSetInt("x", x)
				props.PropSetInt("y", y)
				props.PropSetInt("count", 1)
				props.PropSetString("sprite", "TinyExplosion")
				MakeGameObject(o.level, "explosion", props)
			}
		}
	}
	return false
}