+ Reply to Thread
Results 1 to 13 of 13

image array, referencing images

  1. #1
    Registered User
    Join Date
    03-24-2011
    Location
    Bristol
    MS-Off Ver
    Excel 2000
    Posts
    36

    image array, referencing images

    Hi and thanks for your time

    I'm not quite a newbie, but I am totally flummoxed on image manipulation.

    I am writing a card game using office 2000(excel/ vba),

    I have 53 images (52 faces and 1 back) and I am trying to place these into 38 places on my user form.

    basically how do I go about it?

    Please Login or Register  to view this content.
    ...is the essence of what I want to do, and I appreciate my method is most probably way off the mark, which would account for my not finding an answer after several days of searching.

    ..and just to save another post could you point me in the right direction for animating the cards across the table..I don't mind reading up on the subject, I just can't find a starting point other than the zombie paper clip that will not die.

    I suppose I must stress this project is just for fun and if you would like to play with the end result I'd be happy to make it freely available to anyone. It isn't a solitaire game, the computer will play against you. The game is 2 player Don, a trick taking game based on Don a partnership game not too dissimilar to whist/trumps/bridge. Maybe the next project would be the 4 player game with 3 AI's..then again I need to learn how to walk these graphics first.

    again, thank you for your time

    col
    Last edited by col12345; 03-29-2011 at 01:55 PM. Reason: code tags for newbie pm rule

  2. #2
    Registered User
    Join Date
    03-24-2011
    Location
    Bristol
    MS-Off Ver
    Excel 2000
    Posts
    36

    Re: image array, referencing images

    Err, my apologies if I gave the impression I wanted you to do my shopping, I just want to know where the shops are.

  3. #3
    Registered User
    Join Date
    03-24-2011
    Location
    Bristol
    MS-Off Ver
    Excel 2000
    Posts
    36

    Re: image array, referencing images

    I think I've tracked sown the answer.

    Something called SHAPE gives the user more options to manipulate images, hopefully I can report back when I've read up some more on how to use it.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: image array, referencing images

    Maybe you will find inspiration from these existing games.
    http://www.dzikosoft.com/gmexcel/library.html
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    03-24-2011
    Location
    Bristol
    MS-Off Ver
    Excel 2000
    Posts
    36

    Re: image array, referencing images

    Thanks for your help Andy.

    I have looked at the coding used in several card games and the answer now seems obvious.

    It can't be done using Excel, well not in the way I was looking to do it.

    The games use the system assigned names "Image1", "Image2", etc and use repeating code to manage each Image directly, rather than assign the images to an array and use generic routines to manipulate the images. i.e. playing_card_image(x) = such and such.

    Although this hasn't given me the answer I was looking for, it has saved me more weeks of searching for an answer that doesn't exist.

    Many thanks to all who have took the time to read my question and especially Andy Pope for pointing me in the right direction.

    I will leave this post open for a few days, just in case anyone has a cunning work around.

  6. #6
    Registered User
    Join Date
    03-24-2011
    Location
    Bristol
    MS-Off Ver
    Excel 2000
    Posts
    36

    Re: image array, referencing images

    While pulling what little of my hair out and randomly hitting my head on the keyboard in the help section of Excel I found I could do this.

    Dim card( 0 to 52) as Image
    set card(0) = Image53 ; Card Back
    set card(1) = image1 ; Ace of Clubs
    .
    .
    set card(52) = image52 ;King of Spades
    Which now means I can assign the shuffled cards images to specific images in my userform.

    and as for animating the cards, a simple loop, incrementing the LEFT and TOP values will suffice.

    Well that's enough to get me on my way, thanks all.

    cheers

    col

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: image array, referencing images

    Did you have a glance at this post ?



  8. #8
    Registered User
    Join Date
    03-24-2011
    Location
    Bristol
    MS-Off Ver
    Excel 2000
    Posts
    36

    Re: image array, referencing images

    Hi snb

    I'm afraid your link is dead, or at least seems to be unavailable, but thanks for the try.

    err hold that, it's now working.

    cheers I'll have a good read.
    Last edited by col12345; 03-29-2011 at 12:49 PM. Reason: Link now available

  9. #9
    Registered User
    Join Date
    03-24-2011
    Location
    Bristol
    MS-Off Ver
    Excel 2000
    Posts
    36

    Re: image array, referencing images

    Cheers snb

    Not quite my problem, but it has given me ideas.

    basically my problem is I can't see a way of referring to image objects other than by explicitly calling them by name as in "Image1", "Image2", etc.

    For example

    If the user clicks on the ace of clubs, which is image1 (out of 36 on the sheet) the click event checks to see if this is a valid choice, moves the image in discreet steps to a play area, sets the zorder based on value against other played cards and updates various AI components.

    This code, with my current understanding, will need to be replicated for each image (that's 36 times)
    As passing an image object as a variable to a subroutine doesn't appear possible.

    but still, I like your code and will keep this in mind for future projects.

    many thanks

    col

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: image array, referencing images

    Quote Originally Posted by col12345 View Post
    basically my problem is I can't see a way of referring to image objects other than by explicitly calling them by name as in "Image1", "Image2", etc.

    For example

    If the user clicks on the ace of clubs, which is image1 (out of 36 on the sheet) the click event checks to see if this is a valid choice, moves the image in discreet steps to a play area, sets the zorder based on value against other played cards and updates various AI components.

    This code, with my current understanding, will need to be replicated for each image (that's 36 times)
    As passing an image object as a variable to a subroutine doesn't appear possible.
    Quod non.
    Just post an example with 5 pictures and the code you want to be applied to 36 images. Then we'll have a try.

  11. #11
    Registered User
    Join Date
    03-24-2011
    Location
    Bristol
    MS-Off Ver
    Excel 2000
    Posts
    36

    Re: image array, referencing images

    Thanks for the interest snb.

    I've run off a quick example as you suggested.

    It's probably wise to assume I am a complete novice and that the obvious route isn't that obvious to me as I come from a spaghetti basic background, not object orientated and certainly not structured.

    What-ever you suggest will be welcome, even if it's a curt "Read book xyz"
    Attached Files Attached Files

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: image array, referencing images

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    12-07-2013
    Location
    Application.visible=false
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: image array, referencing images

    i know this is an old topic, but the answers are not satisfying, so:

    to put a picture from a workbook's sheet to a form, i first save it to the disk, and then to the form (i use a ssd, on standard hard drive might be slow).

    this code in a module (code not modified, can be shorter)

    Please Login or Register  to view this content.


    and then in the userform : (code can be made shorter, ajust names of control forms)

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1