コード例 #1
0
func NewProjectile(id int64, start, finish *geometry.Point, damage int, prange float64, owner gameObjectsBase.Activer) *Projectile {
	shift := math.Sqrt(2)/2 + 1e-2
	alpha := math.Atan2(finish.Y-start.Y, finish.X-start.X)
	start.Move(shift*math.Cos(alpha), shift*math.Sin(alpha))
	return &Projectile{
		fightBase.NewBaseBlow(fightBase.BM_HIT, prange, "hit"),
		gameObjectsBase.NewGameObject(id, *start),
		*finish,
		damage,
		owner,
	}
}
コード例 #2
0
func (obj *ActiveObject) GetCollisionableSide(dir int, shift float64) (geometry.Segment, geometry.Point) {
	var p1, p2, p3 geometry.Point
	p1 = obj.GetShiftedCenter(dir, shift)
	p2 = p1
	p3 = p1
	switch dir {
	case consts.NORTH_DIR:
		p1.Move(-consts.OBJECT_HALF, -consts.OBJECT_HALF)
		p2.Move(consts.OBJECT_HALF, -consts.OBJECT_HALF)
	case consts.SOUTH_DIR:
		p1.Move(-consts.OBJECT_HALF, consts.OBJECT_HALF)
		p2.Move(consts.OBJECT_HALF, consts.OBJECT_HALF)
	case consts.EAST_DIR:
		p1.Move(consts.OBJECT_HALF, -consts.OBJECT_HALF)
		p2.Move(consts.OBJECT_HALF, consts.OBJECT_HALF)
	case consts.WEST_DIR:
		p1.Move(-consts.OBJECT_HALF, -consts.OBJECT_HALF)
		p2.Move(-consts.OBJECT_HALF, consts.OBJECT_HALF)
	}
	return geometry.Segment{p1, p2}, p3
}