previous

page 11

next
implementing "run"

We're going to need a global to control the game.

var g_running=false;

The stop function will simply be:

function stop() {
g_running=false;
}

The run function is not quite as simple:

function run() {
g_running=true;
cont();
}
function cont() {
if (g_running) {
one_step();
setTimeout(cont,150);
}
}
Improving the layout
#game {
margin-top:3vmin;
justify-content: center;
}
#pane1 {
margin:1vmin;
padding:.5vmin;
border:3px solid brown;
}
previous
next