Earlier quoted context omitted.
Really well done and I like the brevity. Here are some ideas for revising the code: 1. There are two functions called "distance" and they're identical. Only the outermost appears to be needed. 2. As written, the game places variable and function names into the global scope. It doesn't matter for this game, but will be a problem for larger games. One idea would be to use the Immediately Invoked Function Expression (II…
Also never use Math.pow for squaring numbers (used in the distance function) because it is significantly slower as it is designed for abitrary real exponents, not just integer ones. Cannot be learned soon enough IMO :) Still a very good job for just a week of coding though.
Show HN: I taught my little brother JS, and he made this videogame in a week
261–270 of 285 posts
Re: Show HN: I taught my little brother JS, and he made this videogame in a week
#262Re: Show HN: I taught my little brother JS, and he made this videogame in a week
#263how little is little? why didnt he post it here himself? feels a little suspect.
Maybe because he is not on hackernews? I told him I did this post, and he reads your comments, though. He is 15. I should have written younger brother and not little brother; english is not my native language.
Re: Show HN: I taught my little brother JS, and he made this videogame in a week
#264Earlier quoted context omitted.
Also never use Math.pow for squaring numbers (used in the distance function) because it is significantly slower as it is designed for abitrary real exponents, not just integer ones. Cannot be learned soon enough IMO :) Still a very good job for just a week of coding though.
This advice is incorrect. Experimenting in the console in both Firefox and Chrome shows that there's not a significant speed difference between the two, even if you make sure you only call a given function with integers <10000.
Re: Show HN: I taught my little brother JS, and he made this videogame in a week
#265I love that the red block doesn't understand the concept of wrapping. It reminds me of playing with my dog.
I was actually going to ask what the rationale behind this was. I found that because of this, the best strategy was usually to wrap around to distract the block. I personally felt like the game would have worked better without that, although hard to know without trying it.
Re: Show HN: I taught my little brother JS, and he made this videogame in a week
#266Re: Show HN: I taught my little brother JS, and he made this videogame in a week
#267Earlier quoted context omitted.
Or your Macbook Pro if it originally came with an HDD. Apparently the device orientation API can utilize the triaxial accelerometer that Apple used for drop detection. Really neat experience tilting my laptop around like a mad man.
Can confirm that HP Probooks had the same accelerometer in 2011-2014. Win8 used it for screen orientation OOTB.
Re: Show HN: I taught my little brother JS, and he made this videogame in a week
#268Earlier quoted context omitted.
I do agree it’s a complaint about the language. However, I think it does ultimately fall on the developer to know how to work with the language including the bad/ugly/awful parts. I also think not polluting the global scope is a pretty foundational thing to know or be aware of. It’s really easy to shoot yourself in the foot or have naming collisions/overwrites happen if you aren’t careful. Another example would be me…
> However, I think it does ultimately fall on the developer to know... This person has been programming for a week. I think we can let this slide
Re: Show HN: I taught my little brother JS, and he made this videogame in a week
#269Earlier quoted context omitted.
But what if he wanted to turn it into a AAA FPS game with RTS elements in a persistent online world that supports millions of simultaneous users?
If you're not joking and actually making that statement seriously you need to close your computer and go take a few hour walk.
Re: Show HN: I taught my little brother JS, and he made this videogame in a week
#270when I was 11 an online friend showed me a "game" he was working on using VB6. There was a little star you moved across the screen by clicking buttons for u/d/l/r. His end goal was a top-down RPG.
Seeing projects like this always hold a special place in my heart. Best of luck to your brother. I hope his passion grows and he does amazing things