2048通关的程序员们,来试试脚本版的吧!!!

LanglyTiger 2014-04-28 02:24:02
加精
游戏2048最近在我的小圈子里挺热闹,前段时间回家班车上一个同车的机械工程师问做个这样的游戏要多少时间?我当时回答他的是2小时应该可以完成基本功能。

鬼使神差,我回家当晚就真的花了2个多小时写了个PC版的,自己前后手工通关了2048,4096,8192。后来慢慢完善,逐渐的想在里面加脚本功能,这就是大家即将看到的2048脚本版。

因为是用MFC来写的,所以放到了这个版块,其实脚本是lua的。

游戏做的很粗糙,大家都不要吐槽界面了,要是有美工高手愿意给套配色方案,不胜感激。如果有bug或者需要支持新的更方便的函数,readme里面有我的联系方式。

下载地址: http://pan.baidu.com/s/1hqkjlwg

-----------------------------------------脚本简介-----------------------------------------

-- write log to the list of host, maximum log length is 4095
-- log will be truncated after index 4095
logToHost("SCRIPT_START")

-- set the interval between two steps, between 50 and 3000(ms)
-- the host will sleep a period after each move, 500 is the
-- default value for human in host.
setStepInterval(500);

-- slide to left, right, up, down
-- possible returns: SUCCESS, KEY_IGNORED, GAME_ISOVER
moveLeft()
moveUp()
moveRight()
moveDown()

-- sleep some time, in milliseconds
sleep(1000)

-- test if able to slide to a direction
-- possible returns:
-- true - able to slide
-- false - not able to slide
testMoveLeft()
testMoveUp()
testMoveRight()
testMoveDown()

-- get the cell values from host, the table index is from 0
cellValues = getCellTable();
-- loop through all table values and write to log
for i=0, #cellValues do
logToHost( string.format("CELL_VALUES[%d] = %d", i, cellValues[i]) )
end

-- get single cell value by index
-- possible returns:
-- nil - index is out of range
valueAtIndexZero = getCellValue(0)

-- get rows, columns
rows = getRows()
columns = getColumns()

-- get empty cell count
emptyCellCount = getEmptyCellCount()

-- test if game is over
if ( not isGameOver() ) then
logToHost("Game is not over.")
end
...全文
6896 68 打赏 收藏 转发到动态 举报
写回复
用AI写文章
68 条回复
切换为时间正序
请发表友善的回复…
发表回复
aligebaba 2014-05-26
  • 打赏
  • 举报
回复
这游戏还挺好玩的
j805 2014-05-18
  • 打赏
  • 举报
回复
感谢楼主的代码!
不要做咸鱼 2014-05-08
  • 打赏
  • 举报
回复
引用 54 楼 LanglyTiger 的回复:
源码 https://bitbucket.org/shaolinfu/game2048pub
我去,屌丝xp2000竟然安装不了客户端下载不了啊,csdn传一个吧大哥
  • 打赏
  • 举报
回复
cp32212116 2014-05-07
  • 打赏
  • 举报
回复
楼主真是厉害
难题 2014-05-07
  • 打赏
  • 举报
回复
支持一下,等楼主发源码的时候来看
lhw7791086 2014-05-07
  • 打赏
  • 举报
回复
xiaoyue_748941 2014-05-06
  • 打赏
  • 举报
回复
感谢分享~~~
忘却空白 2014-05-06
  • 打赏
  • 举报
回复
gui41021 2014-05-06
  • 打赏
  • 举报
回复
error LNK1104: lua5.1.dll文件无法打开
LanglyTiger 2014-05-05
  • 打赏
  • 举报
回复
源码 https://bitbucket.org/shaolinfu/game2048pub
我是技术渣 2014-05-05
  • 打赏
  • 举报
回复
xiaoxinxin1128 2014-05-05
  • 打赏
  • 举报
回复
看看 学习而已
austin9972 2014-05-05
  • 打赏
  • 举报
回复
伊顺鸣 2014-05-05
  • 打赏
  • 举报
回复
来眼睛一下啊
云满笔记 2014-05-04
  • 打赏
  • 举报
回复
哈哈 这个一定要支持
iNsomnia__ 2014-05-04
  • 打赏
  • 举报
回复
佩服,我们还在一天天脑残的玩
chenxd008 2014-05-04
  • 打赏
  • 举报
回复
都是高手啊,
不要做咸鱼 2014-05-04
  • 打赏
  • 举报
回复
大哥你也该开源了吧,等的俺花都开啦
as190783852 2014-05-03
  • 打赏
  • 举报
回复
感谢你的推荐
加载更多回复(47)

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧