Jump to content
  • Advertisement
Sign in to follow this  
tomsh

c++ code

This topic is 2560 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

Advertisement
it looks good and readable.

but i would change the formating slightly like:

for bracketed statements i like to add a space to either side like so

if( foo > bar )
{
fooed();
}

and.

if( foo[ 0 ] > foo[ 1 ] )
{
fooed( foo[ 0 ] );
}


one change i would do to your code is in "rectangle.cpp".
you have

if(xSpeed < 0 && xSpeed+sAce/sSlip < 0)
xSpeed += sAce/sSlip;
else if(xSpeed > 0 && xSpeed-sAce/sSlip > 0)
xSpeed -= sAce/sSlip;
else
xSpeed = 0.f;


and i would add extra brackets for readability.

if( ( xSpeed < 0 ) && ( xSpeed + sAce/sSlip < 0 ) )
xSpeed += sAce/sSlip;
...

Share this post


Link to post
Share on other sites
An incomplete set of comments on your program:


  • Your header files lack include guards. This will become a problem as your project becomes more complex.

  • You depend heavily on public members. Public members should be the exception, not the rule. They generally make most sense for types with no intrinsic invariants, such as your "vector" class.

  • Your naming convention is confusing and inconsistent.

  • It is generally preferable to use a constainer such as std::vector or std::list rather than implement an instrusive linked list.

  • It is spelled "Camera", not "cemra".

  • Your SfWin::rect member should be a local variable in each function it is used.

  • You could use your vector class in more places, rather than passing x,y pairs and having them as members.

  • There is no need to pass the texture to the rectangle, as it doesn't use it.

  • I see no code to cleanup the rectangles you allocate.

Share this post


Link to post
Share on other sites
Thank you a lot!
From your comment I learned a lot of things.
Actually, the reason I didn't use include guards, it because I didn't know it. So you learned me something new :D

I will try to do the things you said.

ryan20fun what you said, is it something personally to you, or something known?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!