/*
软件作者:https://xuhss.com/oxox/pro
*/
"ui";
ui.statusBarColor("#AA0000");
ui.layout(
<frame background="#AA0000">
<vertical align="top" margin="5">
<text id="text" bg="#ffffff" h="430" gravity="center" color="#111111" size="40"></text>
<linear>
<vertical w="170">
</vertical>
<vertical>
<linear>
<button margin="0 0 0 60" h="60" w="60" id="up" text="上"></button>
</linear>
<linear>
<button h="60" w="60" id="left" text="左"></button>
<button h="60" w="60" id="ok" text="ok"></button>
<button h="60" w="60" id="right" text="右"></button>
</linear>
<linear>
<button margin="0 0 0 60" h="60" w="60" id="down" text="下"></button>
</linear>
</vertical>
</linear>
</vertical>
</frame>
);
//console.show()
clear();
display()
function display() {
ui.text.text(toText(screen));
}
ui.up.click(() => {
});
ui.left.click(() => {
});
ui.down.click(() => {
down()
display()
});
ui.left.click(() => {
});
ui.ok.click(() => {
random()
//toast(String(screen))
display()
});
function down() {
for (y = 3; y > 0; y--) {
for (x = 0; x < 4; x++) {
if (screen[y][x] == 0) {
if(y != 0){
screen[y][x] = screen[y - 1][x]
screen[y - 1][x] = 0
}
else{
screen[0][x] = 0
}
}
if(screen[y][x]==[y-1][x]&&screen[y][x]!=0){
toast(x+","+y)
screen[y][x]*=2
screen[y-1][x]=0
}
}
}
}
function random() {
var blank = 0
for (y = 0; y < 4; y++) {
for (x = 0; x < 4; x++) {
if (screen[y][x] == 0) {
blank++
}
}
}
var random = Math.floor(Math.random() * blank)
toast(random)
blank = 0
lab:
for (y = 0; y < 4; y++) {
for (x = 0; x < 4; x++) {
if (screen[y][x] == 0) {
if (blank == random) {
screen[y][x] = 2
break lab;
}
blank++
}
}
}
}
function clear() {
screen = new Array();
width = 4;
height = 4;
for (y = 0; y <= height; y++) {
screen[y] = new Array();
for (x = 0; x <= width; x++) {
screen[y][x] = 0;
}
}
}
function set(x, y, str) {
if (str == null) {
str = 0
}
if (y <= height && x <= width && y > 0 && x > 0) {
screen[round(y)][round(x)] = str
}
return arr
}
function toText(arr) {
var text = new String();
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
text = text + arr[y][x] + " "
}
text = text + "\n"
}
return String(text)
}
没有合适的资源?快使用搜索试试~ 我知道了~
AutoJs源码-2048游戏机(3)
共1个文件
js:1个
需积分: 1 0 下载量 163 浏览量
2022-11-14
22:18:02
上传
评论
收藏 1KB 7Z 举报
温馨提示
AutoJs源码-2048游戏机(3)。本资源购买前提醒:本源码都是实际autojs项目模板,安装好autojs直接运行即可打开。1、支持低版本autojs。2、资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!。3、安装过程详见具体资源,不会使用autojs谨慎下载
资源推荐
资源详情
资源评论
收起资源包目录
AutoJs源码-2048游戏机(3).7z (1个子文件)
AutoJs源码-2048游戏机(3).js 3KB
共 1 条
- 1
资源评论
[虚幻私塾】
- 粉丝: 335
- 资源: 1559
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功