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.

Dark GDK / MineSweeper Clone

Author
Message
Charles Thompson
16
Years of Service
User Offline
Joined: 30th Jul 2008
Location:
Posted: 4th Aug 2008 22:02
Well I finished my first game with Dark GDK. It's pretty basic. I've attached an installer of the game which you can run to grab the images that the source code below needs. Any feedback, suggestions, complaints are much appreciated.
Main.cpp-


Board.cpp-

Matrix.cpp-

Enum.h-


Charles Thompson

Attachments

Login to view attachments
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 4th Aug 2008 22:03
Nice Looking Code Man! Organization is key! Good Job!

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 5th Aug 2008 09:19
Looks great. Only thing: I don't think including .cpp files is good practice. I would make use of headers instead.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Charles Thompson
16
Years of Service
User Offline
Joined: 30th Jul 2008
Location:
Posted: 5th Aug 2008 19:20
Can you give me an example of how that would work and why you say do it that way?

Charles Thompson
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 5th Aug 2008 20:13
I've never seen includes for cpp files. It's just not common practice. I've not programmed professionally, so I don't know for sure. But, in the bit of professional code I've looked over, there were only includes for headers.

Replace Matrix.cpp with this Matrix.h:



Then replace Board.cpp with this Board.h:



Also, you should probably define class member functions in a separate cpp file, not the header.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Charles Thompson
16
Years of Service
User Offline
Joined: 30th Jul 2008
Location:
Posted: 5th Aug 2008 21:17
You're just putting in a .h .... No real difference there. I think maybe the .h is supposed to declare the functions and prototype them? That would make a bit more sense.

Charles Thompson
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 5th Aug 2008 22:43
Prototyping in a header then defining in a cpp file is the preferred method.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 5th Aug 2008 22:53
What Mahoney said. The reasoning behind this is that if you have other source files in your project that require knowledge of your class you're going to have to include the header for the class so that it knows what the nature of the class is. There's not much sense in reading in the entire class definition, especially if multiple modules need to know the nature of the class. It also runs the risk of trying to recompile code that's already been done.

Typically what I've seen is the header holding the class declarations and, for some reason, including the constructor and destructor, while the .cpp file holds the definitions. At the very least it helps cut down on clutter.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 5th Aug 2008 22:57
I didn't take the time to put all of the definitions in a separate cpp file, but you should for organization.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 5th Aug 2008 23:56
just a comment about
Quote: "Prototyping in a header then defining in a cpp file is the preferred method."


Agreed ...but... there is (of course) an exception...

!!!!!! TEMPLATES !!!!!!!!!

Here is my Array class "template" single header file! why? Templates make it so you MUST do it this way - but offer a neat flexible tool to write some crazy stuff IMHO Now some would say - why *.h? Not *.cpp? Its got all the code in there! I agree - but the reason is simple to me - even if not mainstream. I INCLUDE "headers" in my C++ files(*.h and *.cpp) not the other way around. thats it. My reason


jfc_array.h


P.S. At first - it took me a couple "tries" to get this whole template thing down but I knew I had to to understand the c++ compilers better and all that "Std lib" stuff. so - I finally got it right. By the way - I just didn't get it until I tried a few times writing my own - trying to follow "StdLib" code - and use it like they suggest "just because" just doesn't cut the mustard with me - I need to understand it thoroughly before I can REALLY get fancy with anything.

--Jason

elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 10th Aug 2008 05:32
At the age of 17 I've been programming for about 3 or 4 years now..

And I look at some of your guys' stuff

And I feel like I'm in the presence of GOD

~you can call me lantz~
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 10th Aug 2008 05:37
Quote: "And I look at some of your guys' stuff

And I feel like I'm in the presence of GOD"


I know how you feel. It's the same with me.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 11th Aug 2008 03:30
Me too.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office

Login to post a reply

Server time is: 2024-09-30 03:36:44
Your offset time is: 2024-09-30 03:36:44