mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-05-28 23:41:31 +00:00
now displaying names of available robots for user, on startup (changes to js and html)
This commit is contained in:
parent
4fe79afffd
commit
6845fa51d8
|
@ -15,6 +15,7 @@
|
|||
<p>Type the names of up to five programs to load into the battle robots.</p>
|
||||
<p>You may choose more than one of each.</p>
|
||||
<p>Then press return.</p>
|
||||
<p>(available robots: <span id="programNames"></span>)</p>
|
||||
<input id="programsInput" type="text" autofocus></input>
|
||||
<canvas id="canvas" width="600" height="600"></canvas>
|
||||
</div>
|
||||
|
|
|
@ -255,19 +255,31 @@
|
|||
});
|
||||
}
|
||||
|
||||
// Text and keyboard event listeners for sending program names to
|
||||
// server
|
||||
function init() {
|
||||
// Text and keyboard event listeners for sending program names to
|
||||
// server
|
||||
|
||||
$('#programsInput').bind('keydown', function(event) {
|
||||
if (event.which === 13) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if (worlds) {
|
||||
worlds.finish();
|
||||
$('#programsInput').bind('keydown', function(event) {
|
||||
if (event.which === 13) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if (worlds) {
|
||||
worlds.finish();
|
||||
}
|
||||
var programs = this.value;
|
||||
worlds = new Worlds(programs, BUFFER_LENGTH, startGame);
|
||||
$(this).blur();
|
||||
}
|
||||
var programs = this.value;
|
||||
worlds = new Worlds(programs, BUFFER_LENGTH, startGame);
|
||||
$(this).blur();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Fetch list of robots for user
|
||||
$.getJSON('program-names', function(data) {
|
||||
$('#programNames').text(data.names.join(", "));
|
||||
$('body').css({display: 'block'});
|
||||
});
|
||||
}
|
||||
|
||||
// Fire it up.
|
||||
$(init);
|
||||
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue
Block a user