tiao.txt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. require "import"--我最初把这个发到robin那个代码手册上来了结果一个人给我搬运到这个论坛了
  2. import "android.app.*"
  3. import "android.os.*"
  4. import "android.widget.*"
  5. import "android.view.*"
  6. import "android.graphics.Path"
  7. import "android.graphics.Paint"
  8. import "android.graphics.Color"
  9. import "android.graphics.RectF"
  10. import "java.io.*"
  11. function 加载()
  12. function 提示(text)
  13. Toast.makeText(activity,text,Toast.LENGTH_SHORT).show()
  14. end
  15. function 随机数(min,max)
  16. return math.random(min,max)
  17. end
  18. function 获取屏幕宽()
  19. return activity.getWidth()
  20. end
  21. function 获取屏幕高()
  22. return activity.getHeight()
  23. end
  24. layout=
  25. {
  26. LinearLayout;
  27. layout_height="fill";
  28. orientation="horizontal";
  29. layout_width="fill";
  30. {
  31. RelativeLayout;
  32. layout_width="match_parent";
  33. layout_height="match_parent";
  34. {
  35. LinearLayout;
  36. layout_width="match_parent";
  37. id="背景布局";
  38. layout_height="match_parent";
  39. {
  40. LinearLayout;
  41. layout_height="match_parent";
  42. layout_gravity="center";
  43. id="绘制目标";
  44. layout_width="match_parent";
  45. };
  46. };
  47. {
  48. LinearLayout;
  49. layout_width="match_parent";
  50. layout_height="match_parent";
  51. {
  52. LinearLayout;
  53. layout_height="180dp";
  54. layout_gravity="bottom";
  55. layout_width="match_parent";
  56. orientation="vertical";
  57. backgroundColor="";
  58. {
  59. LinearLayout;
  60. gravity="center";
  61. layout_gravity="right";
  62. layout_width="180dp";
  63. layout_height="180dp";
  64. {
  65. Button;
  66. layout_height="70dp";
  67. text="跳";
  68. id="跳";
  69. layout_width="70dp";
  70. };
  71. };
  72. };
  73. };
  74. {
  75. TextView;
  76. hint="游戏数据";
  77. id="数据反馈";
  78. textColor="0xFFFF1B44";
  79. gravity="center";
  80. layout_width="match_parent";
  81. };
  82. };
  83. };
  84. activity.setContentView(loadlayout(layout))
  85. activity.setRequestedOrientation(0);
  86. 数值=获取屏幕宽()
  87. 数值二=获取屏幕高()
  88. 数据=数值/2
  89. 数据二=数值二/2
  90. 高度=100
  91. 刷新=Ticker()
  92. 刷新.Period=100
  93. 刷新.onTick=function()
  94. 绘制目标.setBackground(
  95. LuaDrawable(
  96. function(画布,画笔)
  97. 画笔.setColor(0xFF009FFF)
  98. 画布.drawCircle(获取屏幕高(),高度,50,画笔)
  99. end))
  100. end
  101. 间隔=10
  102. 加值=1
  103. 高度刷新=Ticker()
  104. 高度刷新.Period=间隔
  105. 高度刷新.onTick=function()
  106. 高度=高度+加值
  107. end
  108. 高度刷新.start()
  109. 刷新.start()
  110. 状态=Ticker()
  111. 状态.Period=100
  112. 状态.onTick=function()
  113. 判断上=数据-高度
  114. 判断下=高度
  115. if 判断上>=数据 or 判断下>=数值 then
  116. print("游戏结束")
  117. 跳.onClick=function()
  118. 分数=0
  119. 等级=1
  120. 间隔=10
  121. 加值=1
  122. 跳跃高度=120
  123. 加载()
  124. end
  125. 状态.stop()
  126. 高度刷新.stop()
  127. 刷新.stop()
  128. 反馈.stop()
  129. 刷新分数.stop()
  130. 等级刷新.stop()
  131. 地狱刷新.stop()
  132. else
  133. end
  134. end
  135. 分数=0
  136. 分数间隔=1000
  137. 刷新分数=Ticker()
  138. 刷新分数.Period=分数间隔
  139. 刷新分数.onTick=function()
  140. 分数=分数+1
  141. end
  142. 等级=1
  143. 等级刷新=Ticker()
  144. 等级刷新.Period=4000
  145. 等级刷新.onTick=function()
  146. if 间隔<=3 or 跳跃高度<= 100 then
  147. 等级="地狱"
  148. 等级刷新.stop()
  149. 跳跃高度=跳跃高度+20
  150. 分数间隔=25
  151. 地狱开始()
  152. 地狱刷新.start()
  153. else
  154. 等级=等级+1
  155. 间隔=间隔-1
  156. 加值=加值+1
  157. 跳跃高度=跳跃高度-2
  158. end
  159. end
  160. 反馈=Ticker()
  161. 反馈.Period=50
  162. 反馈.onTick=function()
  163. 数据反馈.setText("分数:"..分数.."\n高度:"..高度.."\n等级:"..等级.."\n屏幕宽:"..获取屏幕宽().."\n屏幕高:"..获取屏幕高().."")
  164. end
  165. 状态.start()
  166. 反馈.start()
  167. 刷新分数.start()
  168. 等级刷新.start()
  169. 跳跃高度=120
  170. 跳.onClick=function()
  171. 高度=高度-跳跃高度
  172. end
  173. function 地狱开始()
  174. 地狱刷新=Ticker()
  175. 地狱刷新.Period=500
  176. 地狱刷新.onTick=function()
  177. 数据二=随机数(0,""..获取屏幕高().."")
  178. end
  179. end
  180. 地狱开始()
  181. end
  182. 加载()