HNHacker News
TopNewBestAskShowJobs

davidim

50 karma · joined December 30, 2018

High-school student interested in computer science and neuroscience.

dmaydan2@gmail.com

submissionscomments
davidim··on Show HN: Solve and generate mazes with JavaScript on HTML Canvas
What sort of drawing are you thinking? Dragging the mouse around on the screen or navigating with the arrows?
davidim··on Show HN: Solve and generate mazes with JavaScript on HTML Canvas
Thanks a lot for the bug report! You're right - I was forgetting to clear the canvas on render. So I added ctx.clearRect(0, 0, WIDTH, HEIGHT); to the start of the render method.
davidim··on Show HN: Solve and generate mazes with JavaScript on HTML Canvas
Recursive division may be elegant, but it seems that may also have its disadvantages.
davidim··on Show HN: Solve and generate mazes with JavaScript on HTML Canvas
Thanks so much for the compliment. This is probably a bi-product of the maze generation algorithm I used. Essentially, at every step, the algorithm bisects the maze horizontally or vertically - then, it chooses a random cell along this bisection to leave open (that way the 2 resulting regions are still connected). Then, the same algorithm is performed on the 2 new regions. Recursion continues until it no longer makes sense to continue bisecting.

Wikipedia has an article on maze generation that explains the algorithm - https://en.m.wikipedia.org/wiki/Maze_generation_algorithm

davidim··on Show HN: Solve and generate mazes with JavaScript on HTML Canvas
Thanks for checking it out! I am wondering how big is the number you are putting in? If the number is really high, it's probably causing a stack overflow. I would limit the size, but each browser has its own recursion limits so that would be quite a pain. In retrospect, I probably should not have used a recursive algorithm for this task :).
davidim··on Show HN: An analog clock on html canvas
Thanks for checking it out. I like the idea of making the hand move between seconds - I was actually thinking about doing something like that when originally making the clock - then I got too lazy and told myself that real clocks don’t do that so I don’t have to worry about implementing it :). Now it’s too late! I haven’t looked at the code for 2 days, and there are no comments! :)

I’m not sure what you mean with that last suggestion - I’m pretty sure you’re joking, but I still have no idea what you’re talking about.