Print side | Luk vindue

Oplæg til nyt terningespil

Udskrevet fra: Dansk Regneark Forum
Kategori: Hjælp til regneark.
Forum navn: Makro og VBA
Forum beskrivelse: Hjælp til Makroer og VBA-programmering
Web-adresse: https://forum.excel-regneark.dk/forum_posts.asp?TID=4711
Udskrevet den: 30.Apr.2024 kl. 14:24


Emne: Oplæg til nyt terningespil
Besked fra: Harald
Emne: Oplæg til nyt terningespil
Posteringsdato: 15.Apr.2022 kl. 19:02
2-5 deltagere.
Spillerne starter med at placere sin brik på hver sit felt med et NUL.
Du kan nu være med til at afgøre, hvad der skal ske derefter.
Sub spil()
  ActiveWindow.DisplayGridlines = False
  ActiveSheet.Shapes.AddShape(msoShapeOval, 20, 20, 1060, 1060).Select
  Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
  Selection.ShapeRange.Fill.ForeColor.RGB = RGB(200, 255, 200)
  Pi = 3.1415926
  afstand2 = 60 * (Cos(36 * Pi / 180) + Sin(36 * Pi / 180) / Tan(18 * Pi / 180))
  afstand1 = 60 * (Sin(18 * Pi / 180) + Cos(18 * Pi / 180) / Tan(36 * Pi / 180)) + afstand2
  For v1 = 0 To 288 Step 72
    x1 = 550 + afstand1 * Cos(v1 * Pi / 180)
    y1 = 550 + afstand1 * Sin(v1 * Pi / 180)
    For v2 = v1 To 324 + v1 Step 36
      x2 = x1 + afstand2 * Cos(v2 * Pi / 180)
      y2 = y1 + afstand2 * Sin(v2 * Pi / 180)
      For v3 = v2 To 360 + v2 Step 72
        x3 = x2 + 60 * Cos(v3 * Pi / 180)
        y3 = y2 + 60 * Sin(v3 * Pi / 180)
        If v3 > v2 Then
          ActiveSheet.Shapes.AddConnector(msoConnectorStraight, x3, y3, x4, y4).Select
          Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
        End If
        x4 = x3
        y4 = y3
      Next v3
    Next v2
  Next v1
  n = 21
  For v1 = 0 To 288 Step 72
    x1 = 550 + afstand1 * Cos(v1 * Pi / 180)
    y1 = 550 + afstand1 * Sin(v1 * Pi / 180)
    For v2 = v1 - 72 To v1 + 180 Step 36
      x2 = x1 + afstand2 * Cos(v2 * Pi / 180)
      y2 = y1 + afstand2 * Sin(v2 * Pi / 180)
      For v3 = v2 To v2 + 144 Step 72
        If v2 < v1 + 180 Or v3 = v2 Then
          n = (n + 19) Mod 22
          x3 = x2 + 60 * Cos(v3 * Pi / 180)
          y3 = y2 + 60 * Sin(v3 * Pi / 180)
          ActiveSheet.Shapes.AddShape(msoShapeOval, x3 - 15, y3 - 15, 30, 30).Select
          Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
          Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 255, 255)
          Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorMiddle
          Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = n
          Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, Len(n)).Font.Fill.ForeColor.RGB = RGB(0, 0, 0)
          Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, Len(n)).ParagraphFormat.Alignment = msoAlignCenter
          Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, Len(n)).Font.Size = 12
          Selection.ShapeRange(1).TextFrame2.MarginLeft = 0
          Selection.ShapeRange(1).TextFrame2.MarginRight = 0
          Selection.ShapeRange(1).TextFrame2.MarginTop = 0
          Selection.ShapeRange(1).TextFrame2.MarginBottom = 0
          v4 = 90: If v3 > v2 Then v4 = 108
          If n = 1 Then v4 = v4 - 54
          If n = 5 Then v4 = v4 + 54
          If n = 8 Then v4 = v4 + 126
          If n = 14 Then v4 = v4 + 180
          If n = 17 Then v4 = v4 + 234
          Selection.ShapeRange(1).Rotation = v2 + v4
        End If
      Next v3
    Next v2
  Next v1
End Sub



Print side | Luk vindue