Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10

    Unanswered: Making a funky dice ;D

    Hey guys and gals, here's one for you!

    I'm playing about with the idea of making a visual dice by using VBA (and by visual, I mean I want the numbers to "spin" past as the dice rolls (or something equally pretty).

    So far, very simply:
    Code:
    Dim i As Long
    Dim x As Integer
    
        Randomize
        i = 1
    
        Do While i > 0
            x = Fix(Rnd * 6) + 1
            Me.txtResult.Value = x
            Pause (i / 50)
            i = i - 0.5
        Loop
    -------------
    Public Function Pause(NumberOfSeconds As Variant)
        
        Dim PauseTime As Variant, Start As Variant
        
        PauseTime = NumberOfSeconds
        Start = Timer
        
        Do While Timer < Start + PauseTime
            DoEvents
        Loop
    Any suggestions on how to improve the rubbish above? I want it to look much prettier than it already does

    I know it's not loads of information, but hey, I figured it was a nice idea to simply play with...

    Any suggestions and comments are welcomed
    George
    Home | Blog

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    another technique may to use an image library and either clip the image or preloads the images and turn the required image on/off.
    that way round you have the dinky image of the dice.

    potential problems are if you try to simulate the rolling of the die.. you may need to consider if thats what you want ie "rolling the die" moves the images as well as changing the image. image scaling in VBA can be a problem, unless you went for an initially huge oversized image that would scale OK. A conventional die has opposite sides adding up to 7.. that coudl be difficult to simulate, including the amount of spin which causes the die to flip to the 'other' two sides.

    If you are interested I think I have some dice images as PNG's, and I may even have a single large image with all the die in to allow you to use a clip library... PM if you are interested
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I don't think I want to go into too much detail with this - perhaps not a spin... more of a "roll" (you can only see one face at a time).

    I'd be very greatful (and interested) in these image you mention - can you either upload them here or I'll send you my e-mail via PM.

    I was just playing about with how to simulate a roulette kind of effect (starts of fast and slows down) but I'm struggling with a formula to make that look right.

    I like the idea of flicking images (instead of just the numbers I currently use) which shouldn't be a problem to implement - good shout.

    Rhubarb.
    George
    Home | Blog

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Dice Game

    Attached is a design I made based on an old game where you eliminate the numbers (1-9) from the numbers on the dice.
    Attached Files Attached Files
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Dice Game

    Attached is the same game I converted to Visual Basic. I've uploaded the source code for this on this website in the past. I end up playing it a few days a week (never been addicted to a game I developed before.)
    Attached Files Attached Files
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I have to say Paul, that's an addictive little game there! I'll have a proper look into the source code later today if I can!

    So far I'm working with some images that healdem kindly sent to me and I am cycling through the images based on a random number produced. Currently just changing the pictures source (which is causing some latency when trying to roll more than one dice)... So I've decided to put all the relevant photos on the page and change their visible properties (this will result in a "slower" form load time, but a "seamless" rolling of multiple dice.


    Quick question that I should know the answer to (was answered about a month ago in the access forum but I simply can't find it!)
    I want to do something similar to the following:
    Code:
    Dim x as string
    dim y as string
    x = blue
    y = img & x
    
    me.y.picture = "C:\Bluedice.jpg"
    Any suggestions? Cheers
    George
    Home | Blog

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    You can have a slower response depending on what kind of image you insert into the form. For example, I would use Word to resize some of the images and then copy/paste them into a form. After about 10 images, the form loaded extremely slow. But if I did the resizing in Paint and saved them as a *.bmp, inserted the *.bmp, I got a much faster response of loading the form. You may want to test the speed of a *.jpg verses a *.bmp. You may find a *.bmp could be faster. I used bitmaps in the previously attached MSAccess dice game. Be sure to upload your dice game when you're done. I'm curious to try it.
    Last edited by pkstormy; 05-10-07 at 10:50.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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