func (nm *networkManager) Give(ctx *context.T, call rpc.ServerCall, t spec.Triangle) error { if ctx.V(3) { blessings, rejected := security.RemoteBlessingNames(ctx, call.Security()) ctx.Infof("Took a triangle from %v@%v (rejected blessings: %v)", blessings, call.RemoteEndpoint().Name(), rejected) } // Transform from sender's coordinates to our coordinates. // The assumption is that if the triangle was to the left of the // sender's coordinate system, then it will appear on our right and // vice-versa. switch { case t.X < -1: t.X += 2 case t.X > 1: t.X -= 2 } nm.myScreen <- &t return nil }
func moveTriangle(t *spec.Triangle) { t.Dy = t.Dy - gravity t.X = t.X + t.Dx*timeBetweenPaints t.Y = t.Y + t.Dy*timeBetweenPaints if t.Y <= -1 { t.Dy = -1 * t.Dy t.Y = -1 } else if maxY := 1 - triangleCenterHeight; t.Y >= maxY { t.Dy = -1 * t.Dy t.Y = maxY } }