108
votes
Accepted
How clean is my snow?
Let's look at the code.
from random import randrange
import time
Your imports are very minimal! Good.
...
61
votes
How clean is my snow?
Cool animation!
Let's get some linting out of the way. As per PEP 8, you should use 4 spaces of indentation consistently, and function names should be snake_case.
...
37
votes
33
votes
Accepted
Loading... animating dots in C
Too frenetic
I ran your program but it was very frenetic. It was constantly clearing the "Loading" prompt and reprinting it which resulted in a flickering effect. In addition, the cursor also moved ...
30
votes
How clean is my snow?
I'm surprised no one has talked about your character choice! Why are their a bunch of hashtags falling? Nah, I kid, it was an ok choice of character, but we can do better! What about changing the <...
21
votes
How clean is my snow?
def createRandomDrops():
dropCount = 4
for i in range(dropCount):
Magic number 4 in middle of the code
...
14
votes
Maze generator & animator in Python
This is a tip I make a lot, but if you have a collection that's simply tracking "membership", and you don't care about order, you should consider using a Set over a List.
I think this is the case for ...
12
votes
Loading... animating dots in C
You can get rid of that flickering green box by disabling the cursor.
fputs("\e[?25l", stdout); /* hide the cursor */
If you want it back, you can re-enable it.
...
12
votes
Accepted
Counting people inside the house game
You're right - there is a lot of duplication. Also, some organization is needed.
Organize!
Before you do anything else, get everything into a function of some kind. All those statements at module ...
11
votes
"Star Catcher" game
Your code is good, but you have one massive oversight:
It's hackable.
Your code shouldn't be accessable from the Console. I would recommend using getters and setters to limit incorrect addition:
<...
10
votes
How clean is my snow?
from random import randrange
I would suggest using
import random
Then in your code use ...
10
votes
Accepted
Human-like mouse movement
You can get much cleaner code and more readable code if you do 3 things:
Use OOP and custom types to better encapsulate values
Use more descriptive names
Write more helper methods that encapsulate ...
10
votes
Countdown control with arc animation
There are a couple of things which could be more consistent.
...
8
votes
Accepted
A "C" shape of 7 boxes that turn green on click
This has "interview question" all over it :D Anyways.
First, I'd avoid inline styles. The most common issue with inline styles is that they are hard to override. Only ...
8
votes
Loading... animating dots in C
I would probably tie this into whatever code is actually loading something, and print a new dot (or use a /-\| spinner) every 100 kb or whatever number makes, ...
7
votes
A "C" shape of 7 boxes that turn green on click
Throwing in the green flag
if (box.style.backgroundColor !== 'green') {
This string comparison isn't very efficient. By the looks of it, you are trying to use ...
7
votes
Loading... animating dots in C
Instead of the double for loop: one for dots and one for spaces, you could write combined one:
...
7
votes
Countdown control with arc animation
1) DispatcherTimer is good for periodic UI updates, but it should not be used to measure time, because it is just not accurate enough. For precise time measurement ...
6
votes
Parallax animation, running well on Chrome but slow on Safari
The major issue that I see in your code is that you keep requestAnimationFrame no matter what. This obviously causes the browser to update the css of the element at ...
6
votes
UIButton subclass with animated 'shimmer' effect
Okay, so sometimes posting a question is the best way to figure out an answer yourself 🙃.
I was looking for an alternative to having the gradient colors evenly spaced (my hack was to repeat the ...
6
votes
Interactive small town
JavaScript
The loop that generates people - an expensive bridge to cross
”...DOM access is actually pretty costly - I think of it like if I have a bridge - like two pieces of land with a toll bridge, ...
6
votes
Accepted
D3js: transition from stacked bar chart to bar chart with different datasets
Before dealing with the "enter", "update" and "exit" pattern, which is specific to D3, I'd like to address some general issues first.
Do not mix jQuery and D3: this mix is normally unnecessary. Not ...
6
votes
Counting people inside the house game
I noticed that you are repeating some of the code under animate_person_going_inside
and `animate_person_going_outside functions. Also when rendering the text, some ...
6
votes
Accepted
Ring Timer Animation with Chasing Tail using CoreAnimation
There is one problem with your approach: Additional sublayers are added
in draw() and in animateTimerReset() and never removed. ...
6
votes
Accepted
Time delay indication bar for a text game
You can use bar.count rather than your sum
You can use ' ' * n, rather than your for loop.
...
6
votes
Basic orbiting planets in P5.js
Use of p5.js and JavaScript
Math is part of the standard JavaScript library. You shouldn't pollute its namespace with your own code, because it could interfere ...
6
votes
Accepted
Sierpiński's carpet fractal animation for teaching Python 3
Algorithm
You can simplify the code and make it run faster if you construct the next-level carpet by continuing to work on the previous image (punching more holes in it), rather than starting with a ...
6
votes
Maze generator in Python- Gif animator-Custom colors/sizes
Type hints
row_index, column_index, rows, columns
I can guess that these are all int based on the docs. But adding ...
6
votes
Bash script simple countdown timer with dotted output
Validate inputs
The script quietly ignores invalid inputs.
It would be good to add some validation logic and fail when used incorrectly.
Since the counter* ...
5
votes
Accepted
Front End Web exercise, no HTML
There isn't much (that I see) to say about this code; it is mostly straightforward and easy to understand. Therefore, my review will be fairly short.
Refactoring
Take a look at your ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
animation × 384javascript × 214
jquery × 94
performance × 83
css × 64
html × 44
java × 42
python × 41
beginner × 33
canvas × 29
game × 23
image × 17
dom × 17
c# × 16
android × 16
python-3.x × 13
console × 13
ios × 12
physics × 12
ecmascript-6 × 11
timer × 11
event-handling × 10
c++ × 9
swift × 9
object-oriented × 8