Results 1 to 8 of 8

Thread: minesweeper game

  1. #1

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    minesweeper game

    hi guys i'm making a minesweeper game in vb in the start of the program want it a random image box to set its picture as the mine picture (mine.jpg)
    any ideas on how to do this ?

  2. #2
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: minesweeper game

    you could add an array of image boxes, give each a picture, set each to imgRnd(x).visible = false then use this:
    VB Code:
    1. Dim lRnd As Long
    2.    
    3.     lRnd = Int(imgRnd.UBound * Rnd)
    4.     imgMine.Picture = imgRnd(lRnd).Picture

  3. #3

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: minesweeper game

    hey thanx for the reply i got it working but i got another problem

    i use the following code to generate the inage of the mine randomly but i dont know how to have it loop to it does it until i specify to stop

    VB Code:
    1. Dim i As Integer
    2. Randomize
    3. i = Int(Rnd * 87 + 1)
    4. Image1(i).Picture = LoadPicture(App.Path & "/blown.bmp")
    5. Me.Image1(Index).Visible = True
    6. End Sub

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

    Re: minesweeper game

    Dim i As Integer
    dim o as integer
    Randomize
    for o = 1 to 87
    i = Int(Rnd * 87 + 1)
    Image1(i).Picture = LoadPicture(App.Path & "/blown.bmp")
    Me.Image1(Index).Visible = True
    next
    End Sub
    Software languages known:
    Qbasic - TI-Basic - Liberty Basic - Visual Basic 6
    Software API's known:
    Directx 7 and 8
    Internet languages, in the process of learning:
    HTML - JAVASCRIPT - PHP - CSS - MYSQL - AJAX

  5. #5

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: minesweeper game

    damasterjo thanx for the code the only problem is that it it generates way too many mines is there any way i can stop it after so many have been created and second how can i check when i click the a button that doesnt have a mine under it that it shows how far away it is from a mine

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

    Re: minesweeper game

    ok so you havent thought of how to program it yet, alright let me explain the ins and outs of programming mine sweeper. First set up an array that will be the width and height of the tiles, like 10 by 10. So there are 100 tiles, then think of a number of bombs, lets say 20. Then use the random code to put them randomly inside the array somewhere, then you would have to read through the array one by one, Then when you read a array spot and no bomb is there read the top left, top, top right, right, bottom right, bottom, bottom left, left, all 8 surrounding spot, out of those 8 spots count how many bombs there are, assign that number to the array, then move to the next tile, repeat this through the whole array, skipping those which have bombs.

    There now your bombs and numbers have been stored into an array, this has to be set up before the game is started or say at the first tile click.
    Software languages known:
    Qbasic - TI-Basic - Liberty Basic - Visual Basic 6
    Software API's known:
    Directx 7 and 8
    Internet languages, in the process of learning:
    HTML - JAVASCRIPT - PHP - CSS - MYSQL - AJAX

  7. #7

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: minesweeper game

    alright there's my first problem lol i wasnt even thinking an actual array ( i've never used them) i was attempting with just a control array of command buttons ( tiles) and imageboxes( for dispalying the mine and numbers)

    i'll do some research on arrays and get back to you guys if i have any problems thanx alot

  8. #8
    Hyperactive Member Vishalgiri's Avatar
    Join Date
    Oct 2003
    Location
    India
    Posts
    345

    Re: minesweeper game

    I didn't like the way you develop the program, I think you don't know about SDLC or Waterflow model, so in design phaze you should design your app.

    You first think the logic so that you won't find any logic problem while programing

    also you have to think the logic of the digit show while the button pressed

    I prefers OO aproch if i would be you then i would make a ocx insted of pic.
    Regards,
    Vishalgiri Goswami
    Gujarat, ( INDIA ).
    ---------------------

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