|
var tbl; // stores a reference to the RaceTrack table
function setup(boolIgnoreQueryString)
{
// if boolIgnoreQueryString is true then make a blank racetrack from
// the size indicated in the two select elements on the web-page
// otherwise load racetrack in from querystring
tbl = document.createElement("RaceTrack");
var qs = new QuerystringParser();
var track = qs.getRaceTrack("NA");
var rowLength = qs.getRowLength("NA");
if(track=="NA" || rowLength=="NA" || boolIgnoreQueryString)
{
// get choice from drop down list
var rows = document.getElementById("rows").value;
var cols = document.getElementById("cols").value;
tbl.makeTrack(rows, cols, ENABLE_CELL_CLICK_HANDLER);
}
else {
tbl.load(track, rowLength, ENABLE_CELL_CLICK_HANDLER);
}
// add racetrack to webpage
var container = document.getElementById("RaceTrackContainer");
container.replaceChild(tbl, container.firstChild);
}
function startRace()
{
if(!tbl.hasStart() || !tbl.hasFinish())
{
alert("Your track does not have a start and a finish point!");
return;
}
// re-direct to racing page
window.location = "miniRacer.htm?track=" + tbl.serialise() + "&rowLength=" + tbl.getRowLength();
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Teacher: Maths and Computing, Secondary School.
First learnt to program in BASIC on an Amstrad CPC464 and then continued messing around with programs at university and ever since. Doesn't know a huge deal about any of it really but enjoys the challenge and is always keen to learn a new trick!