Latest Diablo 3 News
DiabloWiki Updates
Support the site! Become a Diablo: IncGamers PAL - Remove ads and more!

vb help

Discussion in 'Off-Topic' started by P2blr, Jun 16, 2005.

  1. P2blr

    P2blr IncGamers Member

    Joined:
    Jun 21, 2003
    Messages:
    784
    Likes Received:
    0
    Trophy Points:
    165
    vb help

    I know that there are a plethora of knowledgable peoples in this forum and I call upon you now to help me make.... Minesweeper!
    I've got as much as I can going, but what I can just not figure out how to do is when you click on a square with no mines around it, to make it disappear and also take out all the other ones around it, that's the only hard part I can think about it; I've got a pseudo 2d array of command buttons acting as the squares(duh) but I just don't know how to start even thinking about the problem, any of you smart people I would greatly appreciate your help

    Dankeschuen
     
  2. DrunkPotHead

    DrunkPotHead IncGamers Member

    Joined:
    Jun 22, 2003
    Messages:
    2,801
    Likes Received:
    0
    Trophy Points:
    466
    I'd be able to help u if u used java... i haven't programmed in vb for 4 years, and when i did, it was relatively elementary.

    Do you have to do this in vb? If not, i suggest u switch to java.
     
  3. Oscuro

    Oscuro IncGamers Site Pal

    Joined:
    Oct 6, 2003
    Messages:
    1,538
    Likes Received:
    0
    Trophy Points:
    105
    Can you set a property to make the button invisible or change its style or something? Sorry, it's been about 5 years since I've touched VB.

    If this doesn't have to be VB and you know C++, I'd suggest looking at the FLTK toolkit.

    Edit:
    <total hack solution>
    Change the button's position to somewhere where it can't be seen. This is by no means a good solution, but it might make things look ok while you work on getting the rest of your program to work.
    </total hack solution>
     
  4. Jeda

    Jeda IncGamers Member

    Joined:
    Jun 22, 2003
    Messages:
    95
    Likes Received:
    0
    Trophy Points:
    18
    no clue about vb, but i cannot see the difference to the other buttons.

    What happens if the user clicks on a button? I would guess some kind of function is called like
    [pseudocode]
    function click:
    if (mine) then new game
    else if (1) then buttontext = 1
    ...
    else if (8) then buttontext = 8
    [/pseudocode]

    now if you click an empty field, all you would have to to is make the text empty, and call the function on the fields around the one clicked.
     
  5. P2blr

    P2blr IncGamers Member

    Joined:
    Jun 21, 2003
    Messages:
    784
    Likes Received:
    0
    Trophy Points:
    165
    heh, to be honest it wasn't the vb which was giving me trouble, it was the theory behind it, and yea, I am forced to use vb.
    I *think* I can work it, I'll try Jeda's solution, and get back to you people on it later today
     
  6. Steel_Avatar

    Steel_Avatar IncGamers Member

    Joined:
    Jun 22, 2003
    Messages:
    3,087
    Likes Received:
    0
    Trophy Points:
    255
    It's called the inside blank rule.

    I actually had to program Minesweeper in a VB class years ago. What you do is this: If a square is clicked, and it's a mine, game over. If there's no mine, you check all the surrounding squares. Add and subtract 1 from the coordinates of the current square to easily check the surrounding ones, making sure of course not to attempt to check squares that don't exist.

    If there are mines surrounding the square, you tally them up and then flip the tile, revealing the number of mines surrounding it.

    Here's where it gets tricky. If there are no mines, the tile flips and displays a blank. Then you recursively call your 'mine check / tile flip function' on all the tiles surrounding the original click. So if you write that into the function, it'll automatically go until there are no more tiles to reveal.

    Hope that helps!
     
  7. P2blr

    P2blr IncGamers Member

    Joined:
    Jun 21, 2003
    Messages:
    784
    Likes Received:
    0
    Trophy Points:
    165
    the way I've got it is it checks all the mines and makes the appropriate images to the squares when each new "level" loads, i just forget where, if anywhere, I have it recorded, what would be great in actual vb code would be to get an image's source file, cause that's all that's needed, but I'll do the try all the ones around it, too bad I'm not that good at recursion... I'll try it when I get back from prom, or wake up tomorrow, whichever

    thanks people
     
  8. UserMathias

    UserMathias IncGamers Member

    Joined:
    Dec 22, 2003
    Messages:
    1,724
    Likes Received:
    0
    Trophy Points:
    165
  9. Jeda

    Jeda IncGamers Member

    Joined:
    Jun 22, 2003
    Messages:
    95
    Likes Received:
    0
    Trophy Points:
    18
    omg he dares to have a postcount related to "the game" in the otf. :uhhuh: burn him alive...

    errr another thing why did you also mark the "vb" part of the topic, vb appreviates something else beside visual basic?

    edit: ah missed the microsoft headline... ;)

    back to topic: there's no need to be scared by recursion, in most cases a sheet of paper helps to look through the algorithm really easy
     
  10. Steel_Avatar

    Steel_Avatar IncGamers Member

    Joined:
    Jun 22, 2003
    Messages:
    3,087
    Likes Received:
    0
    Trophy Points:
    255
    No no dude. VB = Evil, and 666 is the mark of the devil. Geez, calm down :)
     
  11. P2blr

    P2blr IncGamers Member

    Joined:
    Jun 21, 2003
    Messages:
    784
    Likes Received:
    0
    Trophy Points:
    165
    haha

    I use 1 function to help with searching around where you click based on where you are(in the middle or a side) and it places the pictures appropriately, but when used in the exact same fashion it doesn't work for other things
     
  12. P2blr

    P2blr IncGamers Member

    Joined:
    Jun 21, 2003
    Messages:
    784
    Likes Received:
    0
    Trophy Points:
    165
    this is quite angering


    using the function to find which squares are searchable around a square.... it'll go backwards, it'll do all crazy crap
     

Share This Page