1
0
Fork 0
Commit Graph

8 Commits (ee99ab6ba9dd9be4e87f40bad16bf476c858a747)

Author SHA1 Message Date
Mike Gerwitz 6654b19ecb Added ability to render other maps after having rendered another (demo file now allows for map selection by id) 2012-03-17 16:34:36 -04:00
Mike Gerwitz 0d82e84daf Added basic animation support to MapRender
This implementation is likely to change, but it does an excellent job bringing
the map to life. The only frustrating part is that the game looks playable,
but is not.
2012-03-16 21:36:57 -04:00
Mike Gerwitz 90b9208bca Refactored tunnel logic from MapRender into ClassicMap 2012-03-16 20:34:54 -04:00
Mike Gerwitz 6af5adddb8 Game object tile mappings and tunnel colors are now part of the ClassicMap 2012-03-16 20:04:52 -04:00
Mike Gerwitz 2a903f7b3d MapRender will now lock canvas from other MapRender instances 2012-03-16 19:42:59 -04:00
Mike Gerwitz 17d8dbe0fc Removed hard-coded width and height for tunnel color rects 2012-03-16 18:51:29 -04:00
Mike Gerwitz eb5fb38396 Added reference to first element in circular linked list for tile frames
This will both make it easy to reset an animation and help to display
the first tile (when animations are disabled or for display tiles for
the editor)
2012-03-16 00:32:13 -04:00
Mike Gerwitz af533652a6 Initial map rendering support
The next major step for the clone is the loading and parsing of LVL files
(maps). This is especially imporant for the purpose of ensuring that users can
continue to use the maps the know and love (and possibly created themselves),
rather than having to recreate them in the clone.

The maps are concatenated into a single fixed-width file and loaded (in the
original sources) into the TLEVEL struct (LTANK.H). The main thing to note about
this data is the manner in which the object data (the playfield) is stored. The
TPLAYFIELD type (defined as a 16x16 multidimensional signed char array) is
formatted as [x][y], meaning that it is an array of *columns*, not rows. While
at first confusing, this does not complicate matters any.

This commit adds initial rendering support for the playfield via MapRender and
is demonstrated in the same demo file as LtgLoader. After loading a tile set,
the user can load an LVL file. The rendering is done using two canvas elements,
the second of which is created by MapRender itself and overlayed atop of the
original canvas. Unmasked tiles are rendered to the bottom canvas and masked
tiles to the upper, allowing us to move game objects without having to redraw
underlying tiles. This is also necessary as the context putImageData() method
overwrites any existing data rather than leaving values corresponding to the
transparent pixels in tact.

This commit also added support for tunnel coloring - each set of tunnels has its
own distinct color. The color values were taken from ColorList in LTANK2.C in
the original sources rather than using CSS color names (e.g. 'red', 'blue',
'magenta') because different environments may assign slightly different colors
to those values (as an example, FireFox does not use #00FF00 for 'green').
Tunnels themselves are identified by a bitmask (0x40), so we can get the tunnel
id by XORing with that mask. The ids are incremented by two in the LVL data
(e.g. 0x40 for index 1, 0x42 for index 2), so we can then divide by two and take
that index in the color array. This color is used to fill the tile with a solid
color in the lower canvas. We can then paint the tile on the upper canvas, which
will allow the color of the lower canvas to peek through the transparent pixels.

Animation support has not yet been added (but animations are still visible in
the demo to the left of the map rendering). This is an exciting start, as we can
clearly see what the game will look like in the browser. This commit also does
not cover any additional level metadata (e.g. author, difficulty, hints); that
will be addressed in future commits and added to the demo.
2012-03-16 00:06:30 -04:00