Jump to content

  • Log In with Google      Sign In   
  • Create Account


Peer review of some sort.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Crusable   Members   -  Reputation: 592

Like
0Likes
Like

Posted 24 February 2013 - 02:17 AM

Hello, I just finished my first game, a pong clone and It would be awesome if someone( or more) could review my code and design choice. There are some known issues such as the collision, when the ball hits the top or bottom of the players paddle it will disappear or rattle around and get spit out. If this happens to the enemy then the ball will get stuck inside. Also, the AI is very bad, as far I I have seen, the AI will never lose. Lastly, there is no sound or text, however there is a working score system, you just don't know the score unless you count. I will probably fix these in the next day or so. The reason I would like the peer review is because if I am making big mistakes, or using bad programming practices  they can be fixed asap. I have included a link to the project with working exe's (they work on my PC, windows 7 laptop) however if you are not comfortable downloading the files, pm me and I will just put them in chat. Thank you in advance for any help.

 

Link: https://docs.google.com/file/d/0BzAXLewFU0RnTzJFaG5CNkFVRTA/edit?usp=sharing


"C spilled his beer all over C++'s shirt. Outraged, C++ shouted, "Good god, man! Have you no class?"

"Your mother is so fat that the recursive function that was used to calculate her mass created a stack overflow"

 

 


Sponsor:

#2 CRYP7IK   Members   -  Reputation: 804

Like
0Likes
Like

Posted 24 February 2013 - 07:04 AM

I had a quick squiz and these are parts that imo need fixing:

 

  1. Your game class has static values for some reason when they could in fact be given in the constructor (Screen width, height, bpp and max fps).
    1. You could then also load those values from an ini file or something to stop having any kind of magic numbers
  2. You aren't dealing with the fact that your game might run at an fps lower or higher than 60. Have a look at delta time in regards to games or physics simulations or if you want something more advanced google Fix your timestep.
  3. You are manually calling move and draw on your entities, what if you wanted multiple balls in the game? Have a generic update and draw method which entities can implement and just loop through them calling those two methods.
  4. All entities have a score, I don't know why. Should be in your game class or in a paddle class.
  5. You are using a string to decide between a ball and paddle in your base entity class. I don't think that's the best way, you could have something like Entity->MoveableEntity->ChaseObjectEntity. (I start making things complicated here...)
    1. You could also then have a Controllable->PlayerController and AIController. That way you could have an ai controller attached to a paddle class so two AI's could vs eachother or have EasyAI and HardAI controllers.
    2. Plus a Collidable class where collidables are inside the collision class and all get looped through and checked for collisions, the ball would reverse it's velocity on collision. Collidables would need an OnCollision function.
  6. You need to make sure you keep to the same naming convention (KeyState and Collid vs mPlayer etc)

 

Well...I got a little carried away and this seems a little overkill for this game but it would make it more generic and give you the ability to add more things easier! Something I did like was the simplicity of your code it all does what it needs which is fine, remember that!

 

 


To accomplish great things we must first dream, then visualize, then plan...believe... act! - Alfred A. Montapert
Gold Coast Studio Manager, Lead Programmer and IT Admin at Valhalla Studios Bifrost.

#3 BinaryPhysics   Members   -  Reputation: 294

Like
1Likes
Like

Posted 24 February 2013 - 09:11 AM

Something that'd make life easier for sharing code like this would be GitHub; it'd also mean you wouldn't need anyone to worry about mentally filtering out object files or generated executables. But that's completely off topic.

 

It's nice to see somewhat consistent formatting. Definitely a great start.

 

Only thing I can really see is the use of the 'TYPE' enumeration in 'entity.h'. You've tied the entity class quite heavily to it but you've kept the enumeration outside of the class. I'd recommend putting the definition of the enumeration as a public member of the class. It means if you copied the class you'd not accidently forget about including it.

 

EDIT: Also, Bjarne Stroustrup recommends making base classes take care of themselves. You've provided an interface for tracking member changes but you've also made all the members 'protected' giving derived classes access anyway. Make them private and force access through through functions; at least that way you can enforce value ranges, etc in an easier fashion.
 


Edited by BinaryPhysics, 24 February 2013 - 09:14 AM.


#4 Crusable   Members   -  Reputation: 592

Like
0Likes
Like

Posted 24 February 2013 - 03:58 PM

The enum Type in entity class is a mistake, for some reason I decided not to do that and I forgot to remove it apparently. Thanks for the feedback.


"C spilled his beer all over C++'s shirt. Outraged, C++ shouted, "Good god, man! Have you no class?"

"Your mother is so fat that the recursive function that was used to calculate her mass created a stack overflow"

 

 





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS