public void TimerEvent(QTimerEvent e) { // Don't move too far away QLineF lineToCenter = new QLineF(new QPointF(0, 0), MapFromScene(0, 0)); if (lineToCenter.Length() > 150) { double angleToCenter = Math.Acos(lineToCenter.Dx() / lineToCenter.Length()); if (lineToCenter.Dy() < 0) angleToCenter = TwoPi - angleToCenter; angleToCenter = NormalizeAngle((Pi - angleToCenter) + Pi / 2); if (angleToCenter < Pi && angleToCenter > Pi / 4) { // Rotate left angle += (angle < -Pi / 2) ? 0.25 : -0.25; } else if (angleToCenter >= Pi && angleToCenter < (Pi + Pi / 2 + Pi / 4)) { // Rotate right angle += (angle < Pi / 2) ? 0.25 : -0.25; } } else if (Math.Sin(angle) < 0) { angle += 0.25; } else if (Math.Sin(angle) > 0) { angle -= 0.25; } // Try not to crash with any other mice List<QPointF> list = new List<QPointF>(); list.Add(MapToScene(0, 0)); list.Add(MapToScene(-30, -50)); list.Add(MapToScene(30, -50)); List<IQGraphicsItem> dangerMice = Scene().Items(new QPolygonF(list)); foreach (QGraphicsItem item in dangerMice) { if (item == this) continue; QLineF lineToMouse = new QLineF(new QPointF(0, 0), MapFromItem(item, 0, 0)); double angleToMouse = Math.Acos(lineToMouse.Dx() / lineToMouse.Length()); if (lineToMouse.Length() == 0) { angleToMouse = 0; } if (lineToMouse.Dy() < 0) angleToMouse = TwoPi - angleToMouse; angleToMouse = NormalizeAngle((Pi - angleToMouse) + Pi / 2); if (angleToMouse >= 0 && angleToMouse < Pi / 2) { // Rotate right angle += 0.5; } else if (angleToMouse <= TwoPi && angleToMouse > (TwoPi - Pi / 2)) { // Rotate left angle -= 0.5; } } // Add some random movement if (dangerMice.Count > 1 && (random.Next(10)) == 0) { if (random.Next(1) == 1) angle += (random.Next(100)) / 500.0; else angle -= (random.Next(100)) / 500.0; } speed += (-50 + random.Next(100)) / 100.0; double dx = Math.Sin(angle) * 10; mouseEyeDirection = (Math.Abs(dx / 5) < 1) ? 0 : dx / 5; Rotate(dx); SetPos(MapToParent(0, -(3 + Math.Sin(speed) * 3))); }
public QGraphicsLineItem AddLine(QLineF line, QPen pen) { return((QGraphicsLineItem)interceptor.Invoke("addLine##", "addLine(const QLineF&, const QPen&)", typeof(QGraphicsLineItem), typeof(QLineF), line, typeof(QPen), pen)); }
public double Angle(QLineF l) { return((double)interceptor.Invoke("angle#", "angle(const QLineF&) const", typeof(double), typeof(QLineF), l)); }
public static QDataStream Read(QDataStream arg1, QLineF arg2) { return (QDataStream) staticInterceptor.Invoke("operator>>##", "operator>>(QDataStream&, QLineF&)", typeof(QDataStream), typeof(QDataStream), arg1, typeof(QLineF), arg2); }
public static QDataStream Write(QDataStream arg1, QLineF arg2) { return (QDataStream) staticInterceptor.Invoke("operator<<##", "operator<<(QDataStream&, const QLineF&)", typeof(QDataStream), typeof(QDataStream), arg1, typeof(QLineF), arg2); }
public double AngleTo(QLineF l) { return (double) interceptor.Invoke("angleTo#", "angleTo(const QLineF&) const", typeof(double), typeof(QLineF), l); }
public QGraphicsLineItem AddLine(QLineF line, QPen pen) { return (QGraphicsLineItem) interceptor.Invoke("addLine##", "addLine(const QLineF&, const QPen&)", typeof(QGraphicsLineItem), typeof(QLineF), line, typeof(QPen), pen); }
public void SetLine(QLineF line) { interceptor.Invoke("setLine#", "setLine(const QLineF&)", typeof(void), typeof(QLineF), line); }
public virtual void DrawLines(QLineF lines, int lineCount) { interceptor.Invoke("drawLines#$", "drawLines(const QLineF*, int)", typeof(void), typeof(QLineF), lines, typeof(int), lineCount); }
public QGraphicsLineItem(QLineF line, IQGraphicsItem parent) : this((Type)null) { CreateProxy(); interceptor.Invoke("QGraphicsLineItem##", "QGraphicsLineItem(const QLineF&, QGraphicsItem*)", typeof(void), typeof(QLineF), line, typeof(IQGraphicsItem), parent); }
public QGraphicsLineItem(QLineF line) : this((Type)null) { CreateProxy(); interceptor.Invoke("QGraphicsLineItem#", "QGraphicsLineItem(const QLineF&)", typeof(void), typeof(QLineF), line); }
public QVariant(QLineF line) : this((Type) null) { CreateProxy(); interceptor.Invoke("QVariant#", "QVariant(const QLineF&)", typeof(void), typeof(QLineF), line); }
public QLineF Map(QLineF l) { return((QLineF)interceptor.Invoke("map#", "map(const QLineF&) const", typeof(QLineF), typeof(QLineF), l)); }
public QGraphicsLineItem AddLine(QLineF line) { return((QGraphicsLineItem)interceptor.Invoke("addLine#", "addLine(const QLineF&)", typeof(QGraphicsLineItem), typeof(QLineF), line)); }
public void DrawLine(QLineF line) { interceptor.Invoke("drawLine#", "drawLine(const QLineF&)", typeof(void), typeof(QLineF), line); }
public QLineF Map(QLineF l) { return (QLineF) interceptor.Invoke("map#", "map(const QLineF&) const", typeof(QLineF), typeof(QLineF), l); }
public void DrawLines(QLineF lines, int lineCount) { interceptor.Invoke("drawLines#$", "drawLines(const QLineF*, int)", typeof(void), typeof(QLineF), lines, typeof(int), lineCount); }
public QLineF.IntersectType Intersect(QLineF l, QPointF intersectionPoint) { return (QLineF.IntersectType) interceptor.Invoke("intersect##", "intersect(const QLineF&, QPointF*) const", typeof(QLineF.IntersectType), typeof(QLineF), l, typeof(QPointF), intersectionPoint); }
public QGraphicsLineItem(QLineF line, IQGraphicsItem parent) : this((Type) null) { CreateProxy(); interceptor.Invoke("QGraphicsLineItem##", "QGraphicsLineItem(const QLineF&, QGraphicsItem*)", typeof(void), typeof(QLineF), line, typeof(IQGraphicsItem), parent); }
public QGraphicsLineItem AddLine(QLineF line) { return (QGraphicsLineItem) interceptor.Invoke("addLine#", "addLine(const QLineF&)", typeof(QGraphicsLineItem), typeof(QLineF), line); }
public QGraphicsLineItem(QLineF line) : this((Type) null) { CreateProxy(); interceptor.Invoke("QGraphicsLineItem#", "QGraphicsLineItem(const QLineF&)", typeof(void), typeof(QLineF), line); }
public static QDBusArgument Read(QDBusArgument a, QLineF line) { return (QDBusArgument) staticInterceptor.Invoke("operator>>##", "operator>>(const QDBusArgument&, QLineF&)", typeof(QDBusArgument), typeof(QDBusArgument), a, typeof(QLineF), line); }
public QLineF.IntersectType Intersect(QLineF l, QPointF intersectionPoint) { return((QLineF.IntersectType)interceptor.Invoke("intersect##", "intersect(const QLineF&, QPointF*) const", typeof(QLineF.IntersectType), typeof(QLineF), l, typeof(QPointF), intersectionPoint)); }
public static QDBusArgument Write(QDBusArgument a, QLineF line) { return (QDBusArgument) staticInterceptor.Invoke("operator<<##", "operator<<(QDBusArgument&, const QLineF&)", typeof(QDBusArgument), typeof(QDBusArgument), a, typeof(QLineF), line); }
public QVariant(QLineF line) : this((Type)null) { CreateProxy(); interceptor.Invoke("QVariant#", "QVariant(const QLineF&)", typeof(void), typeof(QLineF), line); }