+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3
Results 31 to 37 of 37

Thread: Minesweeper

  1. #31
    Probably A Mammal
    Points: 19,108, Level: 87
    Level completed: 52%, Points required for next Level: 242
    bryangoodrich's Avatar
    Location
    Sacramento, California, United States
    Posts
    2,205
    Thanks
    292
    Thanked 495 Times in 450 Posts

    Re: Minesweeper




    Honestly, I have no idea. I remember seeing something about having one R instance activate another through which you interact with it, and the one would constantly update the output it had while still allowing user input. I don't think I need anything that complicated, but it all comes down to handling user input on a dynamically updated plot. The rest of the Snakes print out and movement is pretty procedural. Hell, once adequate user input can be established, it just isn't that complicated of a program! That is part of why I wanted to do it way back when.

  2. #32
    Beep
    Points: 62,666, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardCommunity AwardMaster TaggerFrequent Poster
    Dason's Avatar
    Location
    Ames, IA
    Posts
    11,239
    Thanks
    264
    Thanked 2,187 Times in 1,866 Posts
    I agree. It shouldn't be that bad. It really is the constantly grabbing the keyboard input that is what will be tricky.

    The one way I was thinking of doing it would be using gWidgets. You could have a handler on a gedit widget which grabs any keyboard input and then have something with either an idleHandler or just a constant while loop after that. So I guess what I'm saying is that it can be done - but I'm interested in ways of doing it without gWidgets.

    Although my newest version of mines requires gWidgetsRGtk2 so I guess requiring gWidgets isn't too bad...
    Last edited by Dason; 06-26-2011 at 08:23 PM.

  3. #33
    Beep
    Points: 62,666, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardCommunity AwardMaster TaggerFrequent Poster
    Dason's Avatar
    Location
    Ames, IA
    Posts
    11,239
    Thanks
    264
    Thanked 2,187 Times in 1,866 Posts

    Re: Minesweeper

    If you have gWidgetsRGtk2 you can give the newest version a try. On my Ubuntu machine it looks really nice. I tried it on one of the university servers with Windows and ... it's not as nice there. At least for me all the buttons were quite spaced out even though in the code I specify a spacing of 0.

    I thought that gWidgets looked nicer on my mac but I must have been mistaken. It looks ok and the spacing is fine on the mac but it's not as sleek as when using Ubuntu. It might just be the Gtk theme set on the mac though (that's probably it now that I think about it...).

    Well give it a whirl and let me know what you think. If there's any bug that sticks out let me know.

    I want to add a reset button at some point so you don't have to start a new instance through the command line everytime and if I do that it might actually speed up the creation time after a reset because not as much would need to be created.

    Edit: Blarg! To get a nice Gtk theme on my mac it appears I need Macports. To get macports I need to have Xcode. To get Xcode I need 5 dollars. NOOOOOOOO.
    Attached Files
    Last edited by Dason; 06-24-2011 at 01:24 PM.

  4. #34
    Beep
    Points: 62,666, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardCommunity AwardMaster TaggerFrequent Poster
    Dason's Avatar
    Location
    Ames, IA
    Posts
    11,239
    Thanks
    264
    Thanked 2,187 Times in 1,866 Posts

    Re: Minesweeper

    Slight update:
    - Added a reset button so you don't have to use the command line to play a game on the same difficulty.
    - Automatically reset after a game is won/lost.
    - Fixed a few bugs.
    - More consistent tabs/spaces.
    Attached Files

  5. #35
    Super Moderator
    Points: 19,821, Level: 88
    Level completed: 95%, Points required for next Level: 29
    bugman's Avatar
    Posts
    1,882
    Thanks
    200
    Thanked 230 Times in 184 Posts

    Re: Minesweeper

    Works beautifully, great job Dason!
    The earth is round: P<0.05

  6. #36
    Beep
    Points: 62,666, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardCommunity AwardMaster TaggerFrequent Poster
    Dason's Avatar
    Location
    Ames, IA
    Posts
    11,239
    Thanks
    264
    Thanked 2,187 Times in 1,866 Posts
    Thanks!

    And any feedback you can give would be greatly appreciated.

    I applied for an R-forge project page. We'll see if we get it. If so then I guess I'll have to learn SVN.

    I also added a few features:
    - Menu with options to start a new game or quit
    - Menu to change the size of the board
    - Changed the dialog after you win/lose to give you the option of quitting
    - Added a hint system...

    Any ideas for the best way to implement a high score system? Although that question doesn't adequately represent my problem. It's not the system I have a problem with so much as where I should store the file. Clearly to keep high scores across sessions I'll need to save the high scores in some format somewhere. The problem I have is that I don't know how I should deal with this. The way I see it there are a few options - Let the user decide where the high scores should be saved (it is their system afterall) but if I do that then I either need to have them tell me where the high scores are every time they restart R or save a file in some set location telling me where they saved the scores (which defeats the purpose of asking them in the first place). I could just default to saving in their home directory (or making a hidden folder in their home directory and saving there). I don't know how good of a practice that is though. Is there a default location for packages to save files they want to keep persistent across sessions (maybe in the directory containing the code for the package itself)?
    Last edited by Dason; 06-26-2011 at 08:23 PM.

  7. #37
    Beep
    Points: 62,666, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardCommunity AwardMaster TaggerFrequent Poster
    Dason's Avatar
    Location
    Ames, IA
    Posts
    11,239
    Thanks
    264
    Thanked 2,187 Times in 1,866 Posts

    Re: Minesweeper


    I'm attaching the newest version. It's pretty much finished in terms of features I wanted to add. I finally got gWidgets installed on my wife's HP running Windows 7. I don't know exactly what's going on but the spacing is really weird. I specify in the code for there to be no spacing between the buttons but I get big gaps. It only happens on machines running windows though. On the mac and linux the spacing that I specify is honored so it looks nice. On windows... not so much.

    EDIT: Wooooooo. Figured it out. For some reason setting the spacing value inside the ggroup constructor doesn't work in windows and you need to explicitly set the spacing size using svalue after you construct the ggroup. At least if you're using windows. Which is frustrating. Oh well. It should be working reasonably well on all operating systems now. Enjoy!
    Attached Files
    Last edited by Dason; 06-26-2011 at 08:52 PM.

+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3

           




Posting Permissions

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






Advertise on Talk Stats