I've been following your tutorials and using your javascript library p5js.
Using the knowledge I could find I began making a clone of a puzzle game called BaBa is you for educational purposes.
I feel like theres too many if statements and for loops.
I was wondering if there were any tips you could give me to improve its efficiency / declutter it.
And maybe in the process find something to help others and do a video on.
On another note I also think doing a coding challenge on this game would be interesting as its similar to other coding challenges you've done in the past with a bit of a twist.
you should definitely get a code formatter - its not very easy to read code if the brackets are all over the place.
if you want to have your code reviewed its not helping to have random unused methods in there (mousePressed)
for making your if more uncluttered :
try thinking about the ifs in terms of dependencencies
for example : does the player==true check depend on the key ? no so move it above the keychecks
on top of that its usually more practical to turn directions into vectors that way you can just add them to the player position to achieve most goals
another piece of advice that makes your code prettier and easier to understand is : you dont need an else clause if your if clause has a return at the end
Hey The Coding Train,
I've been following your tutorials and using your javascript library p5js.
Using the knowledge I could find I began making a clone of a puzzle game called BaBa is you for educational purposes.
I feel like theres too many if statements and for loops.
I was wondering if there were any tips you could give me to improve its efficiency / declutter it. And maybe in the process find something to help others and do a video on.
On another note I also think doing a coding challenge on this game would be interesting as its similar to other coding challenges you've done in the past with a bit of a twist.
heres a link to my code https://github.com/MegaminxCode/BaBaisYouClone
here is a link to the steam page of the game https://store.steampowered.com/app/736260/Baba_Is_You/