aardio色块消除游戏源码
By
admin
at 2020-01-12 • 0人收藏 • 1970人看过
感谢 aardio培训群: 撒旦微笑 分享源码
以前玩的经典消除类游戏, 这个是aardio版本
import win.ui; /*DSG{{*/ var winform = win.form(text="翻牌游戏 —— 找出两两相同的色块消除";right=759;bottom=469;max=false) winform.add( ["1"]={cls="plus";left=228;top=54;right=288;bottom=114;dl=1;dt=1;forecolor=15780518;notify=1;z=1}; ["10"]={cls="plus";left=295;top=187;right=355;bottom=247;db=1;dl=1;dt=1;forecolor=15780518;notify=1;z=10}; ["11"]={cls="plus";left=362;top=187;right=422;bottom=247;db=1;dl=1;dr=1;dt=1;forecolor=15780518;notify=1;z=11}; ["12"]={cls="plus";left=429;top=187;right=489;bottom=247;db=1;dr=1;dt=1;forecolor=15780518;notify=1;z=12}; ["13"]={cls="plus";left=228;top=254;right=288;bottom=314;db=1;dl=1;forecolor=15780518;notify=1;z=13}; ["14"]={cls="plus";left=295;top=254;right=355;bottom=314;db=1;dl=1;forecolor=15780518;notify=1;z=14}; ["15"]={cls="plus";left=362;top=254;right=422;bottom=314;db=1;dl=1;dr=1;forecolor=15780518;notify=1;z=15}; ["16"]={cls="plus";left=429;top=254;right=489;bottom=314;db=1;dr=1;forecolor=15780518;notify=1;z=16}; ["2"]={cls="plus";left=295;top=54;right=355;bottom=114;dl=1;dt=1;forecolor=15780518;notify=1;z=2}; ["3"]={cls="plus";left=362;top=54;right=422;bottom=114;dl=1;dr=1;dt=1;forecolor=15780518;notify=1;z=3}; ["4"]={cls="plus";left=429;top=54;right=489;bottom=114;dr=1;dt=1;forecolor=15780518;notify=1;z=4}; ["5"]={cls="plus";left=228;top=120;right=288;bottom=180;dl=1;dt=1;forecolor=15780518;notify=1;z=5}; ["6"]={cls="plus";left=295;top=120;right=355;bottom=180;dl=1;dt=1;forecolor=15780518;notify=1;z=6}; ["7"]={cls="plus";left=362;top=120;right=422;bottom=180;dl=1;dr=1;dt=1;forecolor=15780518;notify=1;z=7}; ["8"]={cls="plus";left=429;top=120;right=489;bottom=180;dr=1;dt=1;forecolor=15780518;notify=1;z=8}; ["9"]={cls="plus";left=228;top=187;right=288;bottom=247;db=1;dl=1;dt=1;forecolor=15780518;notify=1;z=9}; plus={cls="plus";text="重新开始";left=228;top=369;right=489;bottom=425;color=16777215;db=1;dl=1;dr=1;forecolor=15780518;notify=1;z=17}; plus2={cls="plus";left=0;top=0;right=760;bottom=5;bgcolor=-7223;border={radius=1};color=16754775;dl=1;dr=1;dt=1;foreRight=5;forecolor=-22441;z=18} ) /*}}*/ winform.plus2.setProgressRange(1,600); winform.plus2.skin({ background={ default=0xFFC9E3FF }; foreground={ default=0xFF57A8FF } }) import math; var tab = { 1;1;2;2;3;3;4;4;5;5;6;6;7;7;8;8 }; //颜色数组,可以使用图片 var color = { 0xFFE53935; 0xFF8E24AA; 0xFF3949AB; 0xFF039BE5; 0xFF00ACC1; 0xFF4CAF50; 0xFFFFEB3B; 0xFFF4511E; }; var before,info,timer,t; var reset = function(){ before = { 0;0;0}; //控件id,颜色索引,消除数量 info = table.clone(tab); if(timer){ winform.clearInterval(timer) } winform.plus2.progressPos = 600; for(i=1;16;1){ winform[tostring(i)].text=" "; winform[tostring(i)].hide = false; winform[tostring(i)].foreground = 0xFFA6CAF0; winform[tostring(i)].info = table.remove(info,math.random(1,#info)) } }; var start = function(){ t = 0; before[3] = 1; timer = winform.setInterval( 100,function(){ if(t=600){ winform.msgbox("时间到,游戏结束",'结束') reset() return false; } winform.plus2.progressPos = 600-t; t+=1; } ); } var init = function(){ reset() /*绑定事件处理*/ for(i=1;16;1){ winform[tostring(i)].oncommand = function( id,event ){ if(before[3]==0){ start() } foreground = color[winform[tostring(i)].info]; for(j=1;16;1){ if(i!==j and foreground !==color[before[2]]){ winform[tostring(j)].foreground = 0xFFA6CAF0; } } winform[tostring(i)].foreground = foreground; if(foreground ==color[before[2]] and before[1]!==i){ sleep(200) winform[tostring(before[1])].hide = true; owner.hide = true; before[3]+=1; if(before[3]==8+1){ if(timer){ winform.clearInterval(timer) } winform.msgbox("游戏结束用时"++t/10++"秒","完成") } } before[1] = i; before[2] = owner.info; } } }; init() winform.plus.oncommand = function(id,event){ reset() } winform.show(); win.loopMessage();
1 个回复 | 最后更新于 2020-09-09
登录后方可回帖
感谢分享!