Results 1 to 3 of 3

Thread: 3D spinning die

  1. #1

    Thread Starter
    Lively Member anycoder's Avatar
    Join Date
    Jan 2025
    Posts
    67

    3D spinning die

    The following code generates random numbers (1-6) for an animated die that could be used in a game.
    The code was partially generated with Claude assistance.
    Attached Files Attached Files

  2. #2
    Hyperactive Member gilman's Avatar
    Join Date
    Jan 2017
    Location
    Bilbao
    Posts
    273

    Re: 3D spinning die

    The die is poorly designed; the sum of the value of one face and the opposite face is always 7. In the image, you can see that the 6 is adjacent to the 1.

  3. #3

    Thread Starter
    Lively Member anycoder's Avatar
    Join Date
    Jan 2025
    Posts
    67

    Re: 3D spinning die

    Thanks for your remarque, I admit I didn't check the order of the faces since it doesn't really affect the random selection process, but I agree that it should look like a real die.

    I put new order for faces (in DrawRotatedCube)
    Code:
        DrawPoly p, Array(4, 5, 6, 7), 5
        DrawPoly p, Array(2, 3, 7, 6), 3
        DrawPoly p, Array(3, 2, 1, 0), 2
        DrawPoly p, Array(0, 1, 5, 4), 4
        DrawPoly p, Array(3, 0, 4, 7), 1
        DrawPoly p, Array(1, 2, 6, 5), 6
    And to display the correct face label:
    in RandomFace
    Code:
      Dim labels
        labels = Array(5, 3, 2, 4, 1, 6)
     ..
        List1.AddItem labels(fs)
    Hope this works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width