我目前有一个轮盘赌游戏模式,主要用javascript编码,并在linux服务器(debian 7)上使用node.js来启动网站等。我正在尝试实现一个' set roll'我可以设置下一卷的编号的页面。数字顺序是; [1,14,2,13,3,12,4,0,11,5,10,6,9,7,8]。当轮盘滚动当前,它很快并且它落在一个随机数上,因为它还没有被操纵。我尝试将dist += 1050 * 5;
两个函数更改为dist == (I PUT NUMBER HERE);
,但是当轮盘滚动时,它只会滚动一点点并且不会落在我放置的数字上。有人有什么想法吗?
function snapRender(x, wobble) {
CASEW = $("#case").width();
if (isMoving) return;
else if (typeof x === 'undefined') view(snapX);
else {
var order = [1, 14, 2, 13, 3, 12, 4, 0, 11, 5, 10, 6, 9, 7, 8];
var index = 0;
for (var i = 0; i < order.length; i++) {
if (x == order[i]) {
index = i;
break
}
}
var max = 32;
var min = -32;
var w = Math.floor(wobble * (max - min + 1) + min);
var dist = index * 70 + 36 + w;
dist += 1050 * 5;
snapX = dist;
view(snapX)
}
}
function spin(m) {
var x = m.roll;
play_sound("roll");
var order = [1, 14, 2, 13, 3, 12, 4, 0, 11, 5, 10, 6, 9, 7, 8];
var index = 0;
for (var i = 0; i < order.length; i++) {
if (x == order[i]) {
index = i;
break
}
}
var max = 32;
var min = -32;
var w = Math.floor(m.wobble * (max - min + 1) + min);
var dist = index * 70 + 36 + w;
dist += 1050 * 5;
animStart = new Date().getTime();
vi = getVi(dist);
tf = getTf(vi);
isMoving = true;
setTimeout(function() {
finishRoll(m, tf)
}, tf);
render()
}