F-Zero-Clone
F-Zero-Clone copied to clipboard
Map Loader
@matthewcollier I've got an animation loop going for the game. Its rendering 3D now. However, I'd like to get a loader for the map going. This means we need to decide on the format for storing a map (tile array, whatever). Once we have a format, I can hand off some things to @april-lundy to start building images (via google searches, or her own artistry). What is your opinion on storing the map?
I think setting up some form of tile engine is going to be the most appropriate solution. Each track could consist of an array of tiles, a 2D array indexing those tiles for the layout of track, and any additional information we need, such as the starting points for the players, initial camera location/orientation, waypoints to describe how to navigate the track, etc. Each tile would contain the data we need for running the game logic (whether the tile can be driven on, acceleration/deceleration values, etc.) as well as rendering (texture coordinates for normal and collision states). Depending on exactly how we store the data, we'll eventually need an editor to ease creation of tracks.
@matthewcollier So I guess the next step is to decide on a format, build the data structure in JS, then create a single instance (maybe an extremely simple track. @april-lundy will need to round up some images for that, once she knows the data structure). I like the idea of the track being stored as JSON, since it parses so easily:
{
"name": "Mute City",
"sky-box-image": "cityscape.jpg",
"road-background": "city-background.jpg",
"tiles": [
[1,2,4],
[3,3,3],
[1,3,4],
],
"start-tile": [2,0],
"start-orientation": "N",
}
and so on... The tiles entry could simply index 'tile' images, via either a sprite map (track-tiles.jpg
)or whatever.
I think this will make the loader easier, using some sort of
TrackFactory.factory('http://fzero.com/mute-city.json')
call that returns a Track
object, or whatever inner class (Renderable
, TrackDrawer
, etc.) we want.