Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / My first Minesweeper game

Author
Message
Inaholler
19
Years of Service
User Offline
Joined: 31st Aug 2005
Location: A hollow in the woods
Posted: 21st Nov 2005 07:01
Hello -
For the sake of learning how to code in DarkBasic Classic, I did the attached coding of a text based version of MineSweeper with some help from a tutorial credited at the top of the code. A few parts I'm still working on which I mention in the comments. Any suggestions, comments would be appreciated.
Jim

MMORPG programs
19
Years of Service
User Offline
Joined: 12th Nov 2005
Location:
Posted: 21st Nov 2005 07:25
i think its really bad... no offense of course. I've seen better done in 5 lines... even though the only reason was because it was funny... but still, its unclear. Also when you get a zero all other zeros adjacent to that and adjacent to those should be cleared. The outside of the 0s should have 2s and ones in it.

There are only two types of people. The ones that agree with me and the ones that are wrong
Inaholler
19
Years of Service
User Offline
Joined: 31st Aug 2005
Location: A hollow in the woods
Posted: 21st Nov 2005 07:47
Medival games:
No offense taken. Do you have any specific suggestions regarding the code? I'm still working on clearing all the adjacent zeros and bordering numbered squares adjacent to mines. Any ideas on coding that?
Jim
Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 21st Nov 2005 15:25 Edited at: 21st Nov 2005 15:28
i would run it but i only have DBPro...

[edit] actually it worked in DBPro.. nvm

not bad, but it would be much nicer if you just let the user click on the squares... not sure how you do this in DBC but in DBPro to find the x position of the mouse you use
for y you just replace the x with y of course... then to see if it's clicking you use


but it may be different in DBC

"We make the worst games in the universe..."
Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 21st Nov 2005 17:29
you should realy make SPRITES of pictures (mines ) instead of numbers , if you can .


you are on the right path of makiing something.

you only live once , but you die twice
born and death!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Nov 2005 18:51
Quote: "I've seen better done in 5 lines"

Well, I dont know about 5 lines. But I did make a version in dbp with images and mouse with 3 levels of difficulty in about 170 lines compared to the 200lines seen here. As soon as I finished mine, there was a tutorial in the newsletter. Odd coincidence.

Inaholler, you're off to a good start. The only major problem I had was not being able to use the mouse. You can use 2 nested For loops to check for the mouse inside all of your squares:



mousex() and mouseclick() are the same in pro and classic.

As for clearing all adjacent "blank" tiles, you could use a breadth first search.

I've attached my DBP version so that you might get some ideas on how to improve certain aspects. It should work in DBC if you make a few changes, mainly the function declarations and the global variables. But you should be able to understand the code regardless of being able to make it run. Use it as a learning tool.


Deadly Night Assassins

Attachments

Login to view attachments
Big Man
19
Years of Service
User Offline
Joined: 4th Feb 2005
Location: BEHIND YOU!!!! (but I live in England)
Posted: 21st Nov 2005 19:16
confusing at first.
But for your first game it is better than what I did.

Our aim is to keep the loo's clean, your aim can help.
MMORPG programs
19
Years of Service
User Offline
Joined: 12th Nov 2005
Location:
Posted: 21st Nov 2005 19:52
lol, i'll work on the code.

There are only two types of people. The ones that agree with me and the ones that are wrong
Inaholler
19
Years of Service
User Offline
Joined: 31st Aug 2005
Location: A hollow in the woods
Posted: 21st Nov 2005 22:55
Everybody, thanks for all the feedback. I think I will start revising by making it mouse clickable instead of requiring text input. I actually did a verision using graphics but when I made the board say 24 x 18 - it was lazy dog slow, the mouse cursor jumped around and for some reason the graphics I used to 'cover' the minefield didn't always disappear when I clicked on them. That was when I decided to go 'back to the basics' and try buiding it as a text based game.
Jim
Inaholler
19
Years of Service
User Offline
Joined: 31st Aug 2005
Location: A hollow in the woods
Posted: 22nd Nov 2005 00:01
Here's a version that works with a mouse. Think I'll move on to trying to give player ability to flag potential bombs.
Jim
Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 22nd Nov 2005 14:57 Edited at: 22nd Nov 2005 14:57
Yay! i was actually able to beat it this time

It might be a good idea to get rid of those grid numbers now that you have mouse support... because the player doesn't need to know anymore

"We make the worst games in the universe..."
Inaholler
19
Years of Service
User Offline
Joined: 31st Aug 2005
Location: A hollow in the woods
Posted: 22nd Nov 2005 20:13
This is the code I added to Flag/Unflag squares.

For fun I coded the game a bit more efficiently but it developed a bug with the color - oh well...

Well onto getting rid of the numbers.
Jim
Inaholler
19
Years of Service
User Offline
Joined: 31st Aug 2005
Location: A hollow in the woods
Posted: 26th Nov 2005 06:53
This is about as far as I wanted to go with this minesweeper game for now. It is set up to work with graphics instead of text and you are able to use flags and question marks. Sprite sheet is attached for anyone interested.
Jim

Attachments

Login to view attachments
Inaholler
19
Years of Service
User Offline
Joined: 31st Aug 2005
Location: A hollow in the woods
Posted: 27th Nov 2005 23:39
When I make an executable file of this program and run the executable, the background and text flash in a most annoying way. Anyone have any idea what the problem might be? The program runs fine when executed directly from DB.
I revised the code, taking everything out of the main game loop that might cause it to flash but that didn't help. I am running DB on a PC with an XP professional OS and not having a problem with any other programs. Below is the current code.
Jim

Login to post a reply

Server time is: 2024-11-27 12:28:23
Your offset time is: 2024-11-27 12:28:23