Page 424 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 424
}
$('#result').html(res);
}
//create slot objects
var a = new Slot('#slot1', 30, 1),
b = new Slot('#slot2', 45, 2),
c = new Slot('#slot3', 70, 3);
/**
* Slot machine controller
*/
$('#control').click(function() {
var x;
if(this.innerHTML == "Start") {
a.start();
b.start();
c.start();
this.innerHTML = "Stop";
disableControl(); //disable control until the slots reach max speed
//check every 100ms if slots have reached max speed
//if so, enable the control
x = window.setInterval(function() {
if(a.speed >= a.maxSpeed && b.speed >= b.maxSpeed && c.speed >=
c.maxSpeed) {
enableControl();
window.clearInterval(x);
}
}, 100);
Money -= 1000;
} else if(this.innerHTML == "Stop") {
a.stop();
b.stop();
c.stop();
this.innerHTML = "Reset";
disableControl(); //disable control until the slots stop
//check every 100ms if slots have stopped
//if so, enable the control
x = window.setInterval(function() {
if(a.speed === 0 && b.speed === 0 && c.speed === 0 && completed === 3) {
enableControl();
window.clearInterval(x);
- 417 -