# 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.

## Recommended Posts

Hello!!!!!!!

I started to program kind of a game... with sfml and opengl
For now, you can move up down left and right... And change with q and e who is the

CPP:

main.cpp

cemra.cpp

rectangle.cpp

SfWin.cpp

vector.h

SfWin.h

rectangle.h

cemra.h

##### Share on other sites

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; 

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

##### Share on other sites

• 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 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

I will try to do the things you said.

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

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013300
×