Advertisement

My first good C++ project

Started by December 23, 2004 10:12 PM
30 comments, last by Spudder 20 years, 1 month ago
Okay, but what do you think about my code here? What does all the build version mean, like which number means what. I beieve its major.minor.?.build. someone please tell me what I put in fo the ? and when will I know when to be at 0.6?
I made 0.5.4 into 0.6.0 because adding score keeping was a big step. I also made 0.6.1 which makes the border thicker and a line through the midle giving it a bit of a more pongy look.
Advertisement

First of all i want to commend you on your game.


I recommend you learn all the programming constructs, as once youve learnt them they become very powerful tools.


		while ( SDL_PollEvent(&event) ){			if ( event.type == SDL_QUIT ){ //Bacically if they press the red X.				SDL_FreeSurface(lpaddle); //				SDL_FreeSurface(rpaddle); //Free the surfaces.				SDL_FreeSurface(ballimg); //				Mix_FreeChunk(tap); //Free the				Mix_FreeChunk(out); //sound chunks.				Mix_CloseAudio();	//Close SDL_mixer.				TTF_Quit();			//Close SDL_ttf.				SDL_Quit();			//Close SDL.				exit(0); //Exit the program safely.			}			if ( event.type == SDL_KEYDOWN ){  //If they press a key,				if ( event.key.keysym.sym == SDLK_ESCAPE ){  //and the key is ESC,					SDL_FreeSurface(lpaddle); //					SDL_FreeSurface(rpaddle); //Free the surfaces.					SDL_FreeSurface(ballimg); //					Mix_FreeChunk(tap); //Free the					Mix_FreeChunk(out); //sound chunks.					Mix_CloseAudio();	//Close SDL_mixer.					TTF_Quit();			//Close SDL_ttf.					SDL_Quit();			//Close SDL.					exit(0); //Exit the program safely.				}			}		}

becomes


              if(QuitEvent())                      Exit();

and in your mind you can map out program execution alot easier.


As for versioning systems I use for my projects A Note on Linux Version Numbers (People can spend ages on projects that are just about or not at v1.0)

Still haven't added functions but made it so when the ball goes out it is trapped in the posession of the person who got the point until the spacebar is pressed.
Reminds me of mine, everything in one source file and really bad coding however mine didn't have sound but it did have AI.
______________________________________________________________________________________With the flesh of a cow.
i lol @ the source code. you obviously have a talent for programming but you gotta learn better programming techniques at least to make it readable.
Advertisement
Yeah that's the worst part. I never really learned from a good textbook or anything on how to program, just soprt of asked a lot of questions. What should I do, should I make my variables global and have functions use the globals or should I have my main function feed into my other functions?
I used globals in my pong game. I don't see why not...
http://sourceforge.net/projects/pingux/ <-- you know you wanna see my 2D Engine which supports DirectX and OpenGL or insert your renderer here :)
Well done, man! It's very nicely polished.
Jason Arorajason@pubism.comhttp://www.pubism.com
I think I did a sloppy job doin that. I turned everything back to normal. I plan on making paddle and bal classes.

This topic is closed to new replies.

Advertisement