Wednesday, August 12, 2015

Abiathar Online - Tileset Rendering and Keyboard Shortcuts

The only "// TODO" comment I had after yesterday's development on Abiathar Online was in renderLevel, specifically in the branch that should display the tileset (tile palette). Rendering the tile palette requires knowing how many tiles there are, so I also added a little code to editorReady to figure out the number of tiles based on the tile sheet height and width (that is, which graphics program created it). I decided that 14 infoplane rows ought to be enough for anybody, and declared the number of infoplane icons to be constant: 252.

I then learned about DOM events to add a key-down handler. I basically copied Abiathar's plane state management key layout; 1-3 toggle editability, 4-6 toggle visibility, 7-9 show the tileset, and 1-3/4-6 show the tileset if a different tileset is already showing. PageUp and PageDown do exactly what they do in Abiathar (move between levels), as does Space (switch between last-seen level and last-seen tileset). The tilde shows the level list, but I don't know how I would make keyboard shortcuts for a variable number of levels, so the mouse still has to select which level to switch to.

I also noticed that Abiathar Online works very nicely as a full-screen web page. I'll try to make sure a good editing experience is always had in that mode.

No comments:

Post a Comment