Results 1 to 8 of 8

Thread: [RESOLVED] Image database

  1. #1

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Resolved [RESOLVED] Image database

    I am making a small card game, which will require cards to appear at random times.

    Here is my code:
    VB Code:
    1. Private Sub cmdRoll_Click()
    2. Randomize
    3. Dim x
    4. For x = 0 To 5
    5. a% = Int(Rnd * 5) + 1
    6. Call pict
    7. Next
    8. End Sub
    9.  
    10. Public Sub pict()
    11. Dim i
    12. For i = 0 To 5
    13. If a% = 1 Then
    14. ???
    15. End Sub

    I have 5 images called "card" with indexes of (0) to (4)
    On the line "If a% = 1 Then" i am trying to mmake it so if the random value "a%" is 1, then a 10 will appear, if "a%" is 4 then an Ace will appear etc.

    however, i cant find a way of getting the cards to show. I would need some kind of image database to store all of the images inside the project but how would i do that?

    Thanks in advance

  2. #2
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Re: Image database

    http://www.vbexplorer.com/VBExplorer/gdi2.asp
    download the examples and look at the animation one i think. This might help if not i have another idea

  3. #3

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Re: Image database

    That makes no relevance or sense to my project. Thanks anyway.

    I asked whether there was a way of getting an image database in VB, so i could write (after a button gets pressed for example) "card(0).picture=ace.bmp" or something along those lines

  4. #4
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Re: Image database

    ok this attachment should explain how to do it. It shows how to load images into the image array and how to call them back and display them. If any questions just ask.
    It is a vb6 source code and some images
    O just noticed when you exit you get an error
    VB Code:
    1. Unload form1
    2. Set frmMemoryDC = Nothing
    3.  
    4. 'shold be only
    5.  
    6. unload me
    sorry
    Attached Files Attached Files
    Last edited by damasterjo; Nov 27th, 2005 at 12:59 PM.

  5. #5

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Re: Image database

    Hmm... I didnt really understand that. Is there a way of only showing one of the bitmaps at a time, or even better, show them randomly?

  6. #6
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Re: Image database

    i uploaded two attachment, one and then i made an upgrade, try one more time. Did you have 5 command buttons ? If not upload it again it is different.

    Also throw this code in there it will display them randomly
    VB Code:
    1. Private Sub Command6_Click()
    2. Randomize
    3. a% = Int(Rnd * 5) + 1
    4. BitBlt Me.hdc, 0, 0, SpriteWidth, SpriteHeight, card(a%), 0, 0, vbSrcCopy
    5. Me.Refresh
    6. End Sub
    also add a command button obiously
    Last edited by damasterjo; Nov 27th, 2005 at 01:17 PM.

  7. #7

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Re: Image database

    As I have asked again and again, is there a way of getting the images To be implemented into my project, so, instead of having to go through all the trouble of externally loading images, just being able to have the images ready at runtime

  8. #8
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Re: Image database

    Thats what the animation example shows you how to do.

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