Skip to main content
Share Your Experience: Take the 2024 Developer Survey
48 votes

Mandelbrot image generator and viewer

I see some things that may help you improve your code. Move loop invariants outside the loop To maximize performance, moving loop invariants outside the loop often helps. This is an optimization ...
Edward's user avatar
  • 66.4k
19 votes

Mandelbrot image generator and viewer

Namings Unlike in Python, all-caps names are usually left to macros (which you should avoid, by the way) in C++; for example: M_PI, ...
edmz's user avatar
  • 1,013
16 votes

2D Collision Detection in C++

const bool Game::isColliding(... This indicates that the returned type is const, and should not be modified by any part of your ...
JohnFilleau's user avatar
14 votes

Mandelbrot image generator and viewer

I'm going to comment mostly on performance aspects of your code here. Stylistic parts of your code should be improved upon by someone more conversant in C++ than I am. Magic Numbers You have factored ...
Tamoghna Chowdhury's user avatar
13 votes
Accepted

Pong game in C++

I see a number of things that may help you improve your program. Fix the formatting It's not clear to me if the code as posted is what you see when you look at it, or if there was a problem pasting ...
Edward's user avatar
  • 66.4k
12 votes
Accepted

2D Collision Detection in C++

SFML implements functionalities that allow you to determine if two rectangles intersect. You can significantly shorten your current code: ...
Dessus's user avatar
  • 300
10 votes

Mandelbrot image generator and viewer

Use library functionality Mandelbrot images are calculated with complex numbers. C++ offers the <complex> header which contains a template for generating ...
Nobody moving away from SE's user avatar
10 votes

2D Collision Detection in C++

John's answer is correct on programming matters. I want to comment on the logic of your code. I found the collision detection calculation difficult to interpret. Which point on the square is ...
Mark H's user avatar
  • 2,295
10 votes

High performance physics simulation - core class design

Missing #includes You are using std::vector, but did not #include <vector>. The code ...
G. Sliepen's user avatar
9 votes

Resource manager with SFML

Design - Singletons A singleton may be a reasonable choice for the logger (it's used everywhere and there should only be one of it). But for the other systems, it's best to stick with ordinary class ...
user673679's user avatar
  • 11.8k
8 votes

SFML snake game in C++

Here are some things that may help you improve your code. Don't declare enum const In ...
Edward's user avatar
  • 66.4k
8 votes

Improved snake game in SFML (C++)

Your program is definitely improved over the last version. Good job! Here are some ideas for you about further improvements. Make the object interface easy for the user The ...
Edward's user avatar
  • 66.4k
7 votes

Resource manager with SFML

No singletons The singleton pattern tries to solve exactly one problem and that is to make sure you always just have one single instance of an object. The issue with your code is, that this ...
Lukas's user avatar
  • 191
6 votes

Pong game in C++ SFML

Adding to what @BenjaminPhillipe has already mentioned: You shouldn't include math.h, but should include cmath instead. ...
Ben Steffan's user avatar
  • 5,228
6 votes
Accepted

Pong game in C++ SFML

I just want to say that your code is very readable and understandable! Things you could do better: Indentation The function and class definitions are not indented when they should be. I know it ...
Camto's user avatar
  • 175
6 votes
Accepted

SFML game with a sprite in a dungeon

Use Meaningful Names Rather than: dungeon.loadFromFile("/Users/danielrailic/Desktop/Xcode /NewGame/ExternalLibs/Sprites/DungeonBack.png"); I'd rather have ...
Jerry Coffin's user avatar
  • 33.6k
6 votes
Accepted

John Conway's Game of Life in C++

General Observations Not too bad if this is your very first C++ program. You need to become aware of the Standard Template Library which provides data structures such as std::array and std::vector. ...
pacmaninbw's user avatar
  • 23.9k
5 votes
Accepted

SMFL Dice class

I see some things that may help you improve your code and offer some suggestions regarding your main question. Think carefully about class design The main question you've asked here is about class ...
Edward's user avatar
  • 66.4k
5 votes

Mandelbrot image generator and viewer

I have to start with saying that this is a really cool and well made project! If you would like to improve the performance of your code, I recommend offloading work to GPU shaders. ...
jacwah's user avatar
  • 2,661
5 votes
Accepted

Sketch of Chutes and Ladders game

I'm a little bothered by the piecemeal conversion from rectangular to polar coordinates. I think I'd rather wrap them up into a little neater package: ...
Jerry Coffin's user avatar
  • 33.6k
5 votes
Accepted

The Last Lost Bubble Shooter - a Board game for children

...
Pimgd's user avatar
  • 22.3k
5 votes
Accepted

2D falling snow animation

Tween is not a very good name. How about Snowflake? And why is it a struct and exposing all ...
Summer's user avatar
  • 2,334
5 votes

2D falling snow animation

I see some things that may help you improve your program. Use objects The Tween struct is a start, but this code would really benefit from the use of actual ...
Edward's user avatar
  • 66.4k
5 votes
Accepted

Snowflakes in C++

Welcome to C++. Nice and readable C++ code! I'm not familiar with SFML, but here are my suggestions about improving the code: When you get familiar with C++, comments like these can be deleted: <...
L. F.'s user avatar
  • 9,560
5 votes
Accepted

Snake game in C++ with SFML

1) Remove unused headers You don't need stdlib.h and stdio.h. These are C headers, and you'll rarely use them in C++ (and if you ...
Rish's user avatar
  • 2,341
5 votes
Accepted

A Flappy bird Game

Prefer member variables to be private if possible There are a lot of member variables that are public that are not used outside ...
G. Sliepen's user avatar
5 votes
Accepted

game interface setup

Yes magic numbers are bad, as well as the data like "graphics/bee.png". The problem with that data in your code is that it is hidden, and dispersed across your source code files, and you ...
gotanod's user avatar
  • 199
4 votes

Cursor module for a text-editor

The names 'txtX' and 'txtY' don't say anything about the domain as 'line', or 'length' do. Someone would need to see how are you using that variable to figure out what it is. If you want to make the ...
Mauricio Rondon's user avatar
4 votes
Accepted

TicTacToe with MiniMax algorithm

Don't use raw pointers, make ownership semantics clear ...
πάντα ῥεῖ's user avatar
4 votes
Accepted

Drawing a circle segment

Overall, this is pretty good. It's straightforward and to the point. Here are some other thoughts. Don't Declare PI You don't need to declare π. It's already ...
user1118321's user avatar
  • 11.7k

Only top scored, non community-wiki answers of a minimum length are eligible