Jump to content
  • Advertisement
Sign in to follow this  
wioneo

My First Time

This topic is 3008 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just finished my first complete project with C++ and even though it seems a bit unrealistic to expect anyone to take the time to look through the source critically...I would greatly appreciate anyone if they did.

Tetrish

I've also included an executable.
This is, as you can see, a Tetris clone as per the main site's suggestion, and my code was heavily influenced by this example. I'm using SDL for input/output.

Download link

You use the up arrow to spin, other arrows for movement, P key to pause, escape key to exit, and the spacebar to drop pieces immediately.

Any feedback, constructive or otherwise is welcome, and I think that I will try to make something more interesting now.

Suggestions for drawing text would be especially welcome.

Thank you for your time.

EDIT: Also it has just occured to me that I forgot to add a restarting feature near the end...

Share this post


Link to post
Share on other sites
Advertisement
I tried running the app, but got 'This application has failed to start because MSVCR100.dll was not found'. (This is on Windows XP.)

It would take me a while to really go through the code thoroughly, but from a quick once-over, it looks quite good. Here are some random observations:

- You seem to be going for an object-oriented, C++-style approach in general. In keeping with that, I'd suggest replacing your various #define's with named constants or enums.

- Don't write empty non-virtual destructors (the compiler-generated destructor will suffice).

- It looks like all the member data in c_control is public (not sure if that was intentional).

- If s_screen is the SDL_Surface for the window itself, I don't think you need to free it at shutdown (you might check the SDL docs to make sure).

Again, this was only a very cursory once-over; I didn't really get into the program logic or overall design. What I saw looked nice and clean though.

As for rendering text, you might look into the SDL_ttf library (or whatever it's called).

Share this post


Link to post
Share on other sites
Thank you for taking the time to reply, I suppose it would be nice if you were able to actually run it, but I'm not skilled enough toa dd anything you wouldn't see in any other Tetris clone.

I'm assuming that I downloaded whatever DLL that is at some point and have forgotten, hm...

So enumerations are better then? I will look into changing that...

About the public members...I realy have some issues with the whole public/private bit...and Visual Studio isn't helping by automatically making things public lol.

I will definately look into "SDL_ttf"...now, thank you for the suggestion.

Share this post


Link to post
Share on other sites
Quote:
Original post by wioneo
I will definately look into "SDL_ttf"...now, thank you for the suggestion.
Lazy Foo's tutorial 7 describes how to use SDL_ttf (and install it by refering to another tutorial for installing libraries).

Share this post


Link to post
Share on other sites
Quote:
Original post by Ezbez
I just want to say nice work! While I'm sure you weren't focusing on this, I do suggest that you pick nicer colors in the future. For the MSVCR100.dll, you'll probably need to look into the Visual C++ 2010 redistributables.


Thank you, and about the colors, is there a better way than searching for/copying hex colors to define colors? If not, what variable type should I use to stor '0xFFFFFFff' and the like to pass? I tried character constant but that did not work.

EDIT: Thank you for suggesting that tutorial site, I'm going through 3 or 4 tutorial lists at the moment lol so I will definately need to move that set up.

Share this post


Link to post
Share on other sites
Quote:
Original post by wioneo
Thank you, and about the colors, is there a better way than searching for/copying hex colors to define colors? If not, what variable type should I use to stor '0xFFFFFFff' and the like to pass? I tried character constant but that did not work.
What functions are you using to create surfaces? In any case, you have some options here that might be better than using a 32-bit hex value. For example, SDL_MapRGB may enable you to more easily specify colors based on their red, green, and blue components. Or maybe you can switch and load images for your surfaces using SDL_LoadBMP you can just make some bitmaps that are colors the way you want them.

But to answer your specific question, most compilers will use an unsigned int to store a hex value like 0xFFFFFFFF. Actually, most compilers will include typedefs that allow you to specify the number of bits you want in your type. The C++ standard header for this is cstdint and you would use a uint32_t in this case.

Share this post


Link to post
Share on other sites
The only surface that I used in that case was the screen surface, and I used...
s_screen=SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE | SDL_DOUBLEBUF);




I used boxColor from the gfx library for alll of the drawing, but I will try to lear about the 'SDL_image' that was mentioned...

THANK YOU for telling me about the User defined types, I've beenw ondering what all the Uint's in the libraries were, that makes sense. I think that I will finish those tutorials before I try another project.

Do you know how to create c++ project templates in VS10 via the custom wizard by chance? My recent files are a bit confusing because every solution is called 'sdl_base.'

EDIT: I think that I'm misreading the 'Microsoft Visual C++ 2010 Redistributable Package' description, does installing that change how executables are created? or does it allow the person installing to run exe's that I created?

EDIT:: Completely random, but do 'object_names' listed after a class declarations closing bracket but before the semi-colon count as a global declaration for an identifier for the class? Also, does it actually create the object or just declare it?

EDIT::: I was messing around with global variabels to just test some things and returned...

1>blabla\c_piece.cpp(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>blabla\c_piece.cpp(10): error C2086: 'int iii' : redefinition

Don't those two errors directly contradict each other? If it is missing a type specifier, than when was it originally defined to be illegally defiend here?

[Edited by - wioneo on July 18, 2010 9:44:07 PM]

Share this post


Link to post
Share on other sites
Well done in completing your first game in C++. I know the first one is hard because I'm still trying to my first game in C++.

I've never actually used SDL before but I have heard of it how much different is it to using the Win32 API?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!