Advertisement

C++ SFML Code Review

Started by November 13, 2013 06:52 AM
11 comments, last by naughtyusername 11 years, 3 months ago

I don't like the switch or Alvaro's code ;)

The switch is better behaved since it wont do anything if passed a value not in the range 0 to 4. I'd put in a default case that asserts or something though. All switch statements should have a default case!

Alvaro's code doesn't do any range checking at all sad.png

You're right about the default case, i should of put those in. thinking back on it i decided not too because i didn't think it through fully. but now i will add them so i wont have to independently choose a variable outside of the function to give it a default value. its ok that he didn't do range checking, i do that already in my code and would of implemented it when needed.

there are lots of things to take atention :

interesting int to string conversation :) there is functions for that,

several game loops with duplicating code,

all code that makes different things could be moved to functions draw initialize mousehandling and etc,

som drawing objects are initializing every loop - initialize them before main loop,

magic numbers,

instead of switch with cases 0 1 2 3... posible better to use array[]

maybe start using vectors sfVector2d or similar

....

Advertisement

there are lots of things to take atention :

interesting int to string conversation smile.png there is functions for that,

several game loops with duplicating code,

all code that makes different things could be moved to functions draw initialize mousehandling and etc,

som drawing objects are initializing every loop - initialize them before main loop,

magic numbers,

instead of switch with cases 0 1 2 3... posible better to use array[]

maybe start using vectors sfVector2d or similar

....

Thanks! put your post in my ToDo file and will get working on it! :)

This topic is closed to new replies.

Advertisement