17
votes
Can I lessen the use of boolean flag variables in this snippet?
Can I lessen the use of boolean flag variables in this snippet?
Consider 1st comparing.
...
11
votes
Simulation of hero vs monster
Reminds me of one of my first programs from a couple years ago. :)
Here is some basic, (hopefully) uncontroversial feedback.
Small bug: "while hero and monster > 0"
You are probably ...
10
votes
Accepted
Spin the wheel game
I think the biggest improvement that you can make is to use functions instead of putting all functionality in one big block of code. The main advantage of functions is that it will be easier to ...
10
votes
Tic-Tac-Toe game in C++
Avoid using namespace std;
If you are coding professionally you probably should get out of the habit of using the ...
10
votes
Can I lessen the use of boolean flag variables in this snippet?
I'm not familiar with unity so, I can't review your code from that perspective. But we can certainly make this code more concise. Let me show you how to get started with refactor this code.
1. Get rid ...
10
votes
Can I lessen the use of boolean flag variables in this snippet?
Each call to handleInputEvents() can set bShow to a new boolean value.
We could approach the display update task by making a
truth table.
...
9
votes
Rock, Paper, Scissors game with CPU
int games_number = 0, games_played = 0, user_wins = 0, computer_wins = 0, even_games = 0; //Counters
Wow, that's a lot of counters!
When choosing a data ...
8
votes
Accepted
"Rock Paper Scissors" game
Overview
I don't like how you are simply passing strings around for the values. Its simple but not very optimal. I would create some enum types to represent the different states (Win, Lose, Draw) and/...
7
votes
Spin the wheel game
Use while True instead of while flag:
An idiomatic and simpler way to loop until condition is changed, is using:
...
7
votes
Accepted
Tic-Tac-Toe game in C++
I think the only 'major' change I might make is to replace the switch..case with if...else to remove duplicate code and actually ...
7
votes
Crossword puzzle app
There's a lot of improvement in both style and structure. I will concentrate on style only.
Use variable names that represent the purpose of the value. For example ...
7
votes
Accepted
Event System using C++
Avoid macros
There are many issues with macros, the general advice is to avoid them where possible.
Let's look at EVENT_TYPE_FUNCTION(): it's there to add a few ...
7
votes
Can I lessen the use of boolean flag variables in this snippet?
Why don't you make button.show() simply do an early exit if the visibility state being passed in is already the same? I'm surprised it doesn't already work this ...
7
votes
"Rock Paper Scissors" game
Computing pcSelection can be factored out into a separate function.
If users enter an invalid choice, promptUserInput still ...
6
votes
Rock, Paper, Scissors game with CPU
Many points already covered.
Check input functions return values
...
6
votes
Accepted
Command-line Tower of Hanoi game
General Observations
Interesting! Decent job of coding. The partitioning of the code seems pretty good, but it can be improved.
In the display of towers, the towers should be numbered so that the user ...
6
votes
Event System using C++
General Observations
This code review request does not present any C++ source files (.cpp files). It appears that you are trying to write close code without the <...
6
votes
Here is a Tic Tac Toe game in Python using functions
I would say you did an excellent job overall! The only suggestions I would make are:
The User Is Capable of Entering Unexpected Input
You have:
...
6
votes
Can I lessen the use of boolean flag variables in this snippet?
Since this is tagged unity3d, rather than setting a flag somewhere else in the script, you can just do the following:
...
5
votes
Accepted
Slot Machine Project
Some of the initial comment lines
look like they should be a module """docstring""".
The os.system() call is expensive and non-portable.
You might assign ...
5
votes
Accepted
Intersecting rectangles on a torus
bool IntersectsOnTorus(int x1, int w1, int y1, int h1, int x2, int w2, int y2, int h2, int domain)
Choosing to phrase it as (x, w, y, h) instead of (x, y, w, h) ...
5
votes
Command-line Tower of Hanoi game
In addition to pacmaninbw's excellent answer, I'd like to add:
Avoid using system()
system() is very expensive: it has to fork ...
5
votes
Accepted
Little CLI game in C++ with random words
General Observations
An interesting new twist on an old game! Using Wikipedia as a source gives a lot of possible words.
There is a lot of good ideas here, but there can be some improvement. An ...
5
votes
Accepted
Recreated Snake in Rust
Clippy
One of the most important tools when writing good rust code is clippy. I recommend to configure your editor to run clippy on-the fly. It has very nice messages and includes an explanation for ...
4
votes
"Asteroids" style arcade game
Loop like a native
In modern C++, we have range-based for. We can replace
...
4
votes
Simple N Puzzle console game
I have a few scattered observations.
Your Tile.Value is a field rather than a property. If using a public access modifier, you ...
4
votes
Accepted
Rock, Paper, Scissors game with CPU
move the srand to the top, no reason to call it multiple times
Get rid of the goto and instead rely an outer ...
4
votes
Rock, Paper, Scissors game with CPU
When it comes to code structure, here are some tips that may be helpful:
Don't use gotos when you can achieve the same behaviour with ...
4
votes
Chess Game with GUI in C++ using SDL2
Since you're already on C++11, it shouldn't be too much effort to move to C++17 or 20, which you should pursue.
Since you have a project with multiple translation units (object files), strongly ...
4
votes
Chess Game with GUI in C++ using SDL2
Answers to your questions
Is my use of namespaces correct?
It's definitely better than not using namespaces. However, you can improve it:
Move more things into the namespaces. For example, why not ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
game × 1935python × 495
beginner × 419
java × 411
c++ × 301
javascript × 228
object-oriented × 206
c# × 195
python-3.x × 183
tic-tac-toe × 135
performance × 130
console × 99
playing-cards × 91
c × 71
rock-paper-scissors × 71
hangman × 64
random × 51
swing × 51
c++11 × 48
dice × 47
pygame × 46
snake-game × 46
algorithm × 44
objective-c × 44
community-challenge × 43