const realtrue = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","0"];
var nowtrue = realtrue;
nowtrue.sort(function(){
return (0.5-Math.random())
});
//左按钮
function leftButtonClick(lbutton){
nowtrue.forEach(function(point,turn){
if(point == "0"){
var zeropoint = turn;
zeropoint = Number(zeropoint);
}
});
if(turn != 3 && turn != 7 && turn != 11 && turn != 15){
var leftpoint = zeropoint + 1;
nowtrue.splice(zeropoint - 1,1, ...nowtrue.splice(leftpoint - 1,1, nowtrue[zeropoint - 1]))
showme()
}else{
var leftpoint = undefined;
}
}
const lbutton = hmUI.createWidget(hmUI.widget.BUTTON,{
x: 32,
y: 217,
normal_color: 0xef5350,
text: 'button',
press_src: "himg/8.png",
normal_src: "himg/8.png",
w: -1,
h: -1,
click_func: leftButtonClick
})
function rightButtonClick(rbutton){
nowtrue.forEach(function(point2,turn2){
if(point2 == "0"){
var zeropoint2 = turn2;
zeropoint2 = Number(zeropoint2);
}
});
if(turn % 4 != 0 ){
var rightpoint = zeropoint2 - 1;
nowtrue.splice(rightpoint - 1,1, ...nowtrue.splice(zeropoint2 - 1,1, nowtrue[rightpoint - 1]))
showme()
}else{
var rightpoint = undefined;
}
}
//右按钮
const rbutton = hmUI.createWidget(hmUI.widget.BUTTON,{
x: 122,
y: 217,
press_src: "himg/1.png",
normal_src: "himg/1.png",
w: -1,
h: -1,
click_func: rightButtonClick
})