Пример #1
0
func (m *MoveFlag) Do(obj gameObjectsBase.Activer) {
	dir := obj.GetDir()
	if dir == -1 {
		return
	}
	var newCenter geometry.Point
	collisionOccured := false
	shift := consts.VELOCITY
	passed := 0.0
	m.field.UnlinkFromCells(obj)
	for passed+consts.OBJECT_HALF < shift && !collisionOccured {
		collisionOccured, newCenter = m.calcNewCenterForActor(obj, dir, consts.OBJECT_HALF)
		obj.ForcePlace(newCenter)
		passed += consts.OBJECT_HALF
	}
	if shift-passed > 0 && !collisionOccured {
		collisionOccured, newCenter = m.calcNewCenterForActor(obj, dir, shift-passed)
		obj.ForcePlace(newCenter)
	}
	m.field.LinkToCells(obj)
	if collisionOccured {
		obj.NotifyAboutCollision()
	}
}