-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code refactoring #7
Comments
In my version I changed the main collision/wall state section in index.js from a nested if/then/else statement to a switch statement. Its posted in my branch but I was trying to implement sonic 3 slope physics in a really messy way so I'm not sure how much help it will be. I didn't mess with goingleft in my version because it looked like it was being used for homing attack code in some way, ended up creating a separate redundant variable called "mirrored" so that sonic could face/run/slide backwards. `else if (!(keysDown[86] && devMode) && keysDown[leftKey] && (char.golock <= 0 || char.Gv < 0) && char.state != -1) { //normal state with left key down
|
What exactly are magic numbers? Ive never heard the term before but there are some mathematical equations in the code that I had to google to figure out. |
Magic numbers in coding refer to hardcoded numbers that should really be stored in well-named constants. So, for example, in the code you posted earlier, I'd consider 40 and 0.1 to be "magic numbers." They're called that because they are usually hard to understand in context, so they just seem like they "magically" do what you want. |
I probably should have asked earlier but would you rather replace magic numbers with variables or constants? Also, I think it might be helpful to replace certain complex math equations with functions, do you agree with this? edit: any ideas for cleaning up the code that checks for keyboard inputs? It's pretty messy hard to read without adding comments but Im not sure how else you could have done it got some stuff i want to fix/change myself but waiting for the comment branch to get merged first |
The codebase is currently very messy. Here are some examples of things to watch out for:
This is stuff that is likely to get fixed slowly over time, but if you find anything egregious, talk about it in this thread.
The text was updated successfully, but these errors were encountered: