I'm currently in the process of building both the client and server side of an HTML5, canvas, and WebSocket game.
This is what I have thus far for the client: http://jsfiddle.net/dDmTf/20/
Current obstacles
The hover effect has no idea what to put back after the mouse leaves. Currently it's just drawing a "void" tile, but I can't figure out how to redraw a single tile without redrawing the whole map.How would I go about storing multiple layers within themap
variable? I was considering just using a multi-dimensional array for each layer (similar to what you see as the current array), and just iterating through it, but is that really an efficient way of doing it?Currently the "borders" encroach on one another. I'm not sure what I'm doing wrong? If you hover over and off of the bordering "tree" tiles, you'll notice how it removes part of the neighboring tiles border. This shouldn't need to happen.- Outside of the map, what would be an elegant way of adding Players to the render scene? I've seen a few places that recommend you use multiple canvas's, would you recommend that since they'll probably be moving much more? In addition to that, how can I confine player movement to the grid, similar to how in the pokemon gameboy games, when you tap the left arrow, you always move one "space" that direction. It's not a halfway type deal.
- Camera. What would be a good way about adding a "camera" to the equation, so the viewport can pan around a larger map area?
- Obstacles. In the newer version of the map, you'll notice an empty obstacles array. Assuming players get added well, what do you think would be good for adding movement obstacles?
Side note
The tile sheet being used for the jsfiddle display is only for development. I'll be replacing it as things progress in the engine.
If you guys have any pointers for my JavaScript, feel free. As I'm more or less learning advanced usage as I go, I'm sure I'm doing plenty of things wrong.
Note: I will continue to update this post as the engine improves, but updating the jsfiddle link and updating the obstacles list by striking things that have been solved, or adding additions.
Edit
Updated link from http://jsfiddle.net/dDmTf/7/ to http://jsfiddle.net/dDmTf/17/ - this handles the "hover" problem, and it's been striked out.
Edit
Updated link from http://jsfiddle.net/dDmTf/17/ to http://jsfiddle.net/dDmTf/19/ - fixes the out of bounds issue with the tiles
Edit
Updated link from http://jsfiddle.net/dDmTf/19/ to http://jsfiddle.net/dDmTf/20/ - adds multiple layers to the equation