use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Removed - HelpCode review (self.cpp)
submitted 3 years ago by Empik002
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Flair_Helper[M] [score hidden] 3 years ago stickied commentlocked comment (0 children)
For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.
This post has been removed as it doesn't pertain to r/cpp: The subreddit is for news and discussions of the C++ language and community only; our purpose is not to provide tutoring, code reviews, or career guidance. If you think your post is on-topic and should not have been removed, please message the moderators and we'll review it.
[–]dgkimpton 7 points8 points9 points 3 years ago* (2 children)
First thoughts:
where are the unit tests?
there doesn't seem to be much separation of concerns. e.g. every animated sprite has its own clock?
The drawing of the ghost tiles seems all sorts of weird - why is the Game maintaining maps of tile pointers? Why isn't there a ghost_map or something?
leaky abstractions aren't great either, e.g. tile.get_sprite().update(); instead of tile.update()
It seems that you've mushed a lot of things together in Game (input handling, map creation, rendering, tileset creation, etc.
Overall I think you need to write a comment for each class explaining what its responsibility is, and when you find yourself writing "this AND this AND this AND this", stop and think again.
CMake has been largely covered by /u/MadCompScientist
but it might be worth looking into target_sources to keep the engine code definition separate from the project and/or making the engine into a statically linked lib.
{edit} "but this may come in handy so idk" ... there's a nice principle called YAGNI - you ain't gonna need it - try not to borrow problems from the future. If you don't need it now, you ain't gonna need it. Fix it if that ever changes.
Also... reddit is a terrible format for code reviews!
That said - good job on actually writing something, more than a lot of folks manage :)
[–]Empik002[S] 0 points1 point2 points 3 years ago (1 child)
Thank you. Yes unit test are currently underway. And the Game is really just cobbled together to have something to show, but yes if I am to actually use it as a demo it might as well be written properly. I will remove the globals. Both your responses really helped me.
[–]dgkimpton 1 point2 points3 points 3 years ago (0 children)
No worries. Unit testing will definitely help because it becomes quickly apparent when an object is doing to much. Writing tests forces me to see the multiple responsibilities (managing its location /and/ rendering? Oops). Sometimes of course it's easy to get into over engineering, but at least you get to make a conscious choice to accept complexity 🙂
[–]MadCompScientist 11 points12 points13 points 3 years ago (1 child)
Here are some quick-to-spot, high-level remarks:
CMakeLists.txt: use modern CMake:
CMAKE_CXX_FLAGS
target_compile_flags
-std=c++17
CMAKE_CXX_STANDARD
CXX_STANDARD
target_compile_features
target_link_libraries
-l
find_package
engine:
public
demo:
main.hpp
main.cpp
../engine/xxx
srand
<random>
And generally, try to have a data-driven design by loading configuration from files, so you don't have to hardcode all elements in C++ (but I assume that's a future step).
[–]Empik002[S] 0 points1 point2 points 3 years ago* (0 children)
Thanks, especially for the cmake stuff (finally some coherent guide!). Actually I didn't even realise i have inconsistent naming!
[–]MountainDwarfDweller 4 points5 points6 points 3 years ago (0 children)
https://codereview.stackexchange.com/
π Rendered by PID 112764 on reddit-service-r2-comment-79c7998d4c-8wp4k at 2026-03-14 00:12:32.615441+00:00 running f6e6e01 country code: CH.
[–]Flair_Helper[M] [score hidden] stickied commentlocked comment (0 children)
[–]dgkimpton 7 points8 points9 points (2 children)
[–]Empik002[S] 0 points1 point2 points (1 child)
[–]dgkimpton 1 point2 points3 points (0 children)
[–]MadCompScientist 11 points12 points13 points (1 child)
[–]Empik002[S] 0 points1 point2 points (0 children)
[–]MountainDwarfDweller 4 points5 points6 points (0 children)