明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 991|回复: 1

求大神教育 修改。

[复制链接]
发表于 2013-5-7 15:17 | 显示全部楼层 |阅读模式
我在做一个消图游戏,然后下面就是代码。

规则就是相同的数字 或者是字母 ,用鼠标点到可以消去(消去:可以是删除,或者是图片覆盖)
消完则结束。

实在写不下去了,代码写到消去,不知道如何判断光标选取的方块(算了好几天了,实在无能了),还有判断消去的方法,也实在无能了。
 楼主| 发表于 2013-5-7 15:19 | 显示全部楼层
(defun a()
  (setvar "clayer" "0");设置图层为当前图层
  (command "color" "1" "");图层颜色为红色

  (command "rectang" "0,800" "800,0" "");0图层区域绘制矩形
  (command "line" "0,200" "800,200" "");绘制图格
  (command "line" "0,400" "800,400" "")
  (command "line" "0,600" "800,600" "")
  (command "line" "200,0" "200,800" "")
  (command "line" "400,0" "400,800" "")
  (command "line" "600,0" "600,800" "")
  
  (command "layer" "Lo" "0" "");锁定0图层

  (command "layer""make" "Game" "");创建游戏界面图层
  (command "color" 3);设置游戏界面图层为绿色

  (setq n (fix(rem (getvar "CPUTICKS") 6)));;产生一个0-5的随机数
  
  (setq a0 (list 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8))
  (setq a1 (list 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8))
  (setq a2 (list 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8))
  (setq a3 (list 1 3 2 4 6 7 5 4 3 4 5 6 1 2 8 7))
  (setq a4 (list 1 4 7 2 5 8 3 6 2 5 8 1 4 7 3 6))
  (setq a5 (list 3 5 7 1 6 4 2 8 1 5 4 7 3 6 2 8))
  (if (= n 0) (setq a a0))
  (if (= n 1) (setq a a1))
  (if (= n 2) (setq a a2))
  (if (= n 3) (setq a a3))
  (if (= n 4) (setq a a4))
  (if (= n 5) (setq a a5))
  
  (setq x (nth 0 a))
  (command "rectang" "0,800" "200,600" "")
  (command "text" "j" "mc" "100,700" "100" "0" x);一行一列
  
  (setq x (nth 1 a))
  (command "rectang" "200,800" "400,600" "")
  (command "text" "j" "mc" "300,700" "100" "0" x);一行二列
  
  (setq x (nth 2 a))
  (command "rectang" "400,800" "600,600" "")
  (command "text" "j" "mc" "500,700" "100" "0" x);一行三列
  
  (setq x (nth 3 a))
  (command "rectang" "600,800" "800,600" "")
  (command "text" "j" "mc" "700,700" "100" "0" x);一行四列

  (setq x (nth 4 a))
  (command "rectang" "0,600" "200,400" "")
  (command "text" "j" "mc" "100,500" "100" "0" x);二行一列
  
  (setq x (nth 5 a))
  (command "rectang" "200,600" "400,400" "")
  (command "text" "j" "mc" "300,500" "100" "0" x);二行二列

  (setq x (nth 6 a))
  (command "rectang" "400,600" "600,400" "")
  (command "text" "j" "mc" "500,500" "100" "0" x);二行三列

  (setq x (nth 7 a))
  (command "rectang" "600,600" "800,400" "")
  (command "text" "j" "mc" "700,500" "100" "0" x);二行四列

  (setq x (nth 8 a))
  (command "rectang" "0,400" "200,200" "")
  (command "text" "j" "mc" "100,300" "100" "0" x);三行一列
  

  (setq x (nth 9 a))
  (command "rectang" "200,400" "400,200" "")
  (command "text" "j" "mc" "300,300" "100" "0" x);三行二列
  

  (setq x (nth 10 a))
  (command "rectang" "400,400" "600,200" "")
  (command "text" "j" "mc" "500,300" "100" "0" x);三行三列
   
  (setq x (nth 11 a))
  (command "rectang" "600,400" "800,200" "")
  (command "text" "j" "mc" "700,300" "100" "0" x);三行四列
   
  (setq x (nth 12 a))
  (command "rectang" "0,200" "200,0" "")
  (command "text" "j" "mc" "100,100" "100" "0" x);四行一列
  

  (setq x (nth 13 a))
  (command "rectang" "200,200" "400,0" "")
  (command "text" "j" "mc" "300,100" "100" "0" x);四行二列
  

  (setq x (nth 14 a))
  (command "rectang" "400,200" "600,0" "")
  (command "text" "j" "mc" "500,100" "100" "0" x);四行三列


  (setq x (nth 15 a))
  (command "rectang" "600,200" "800,0" "")
  (command "text" "j" "mc" "700,100" "100" "0" x);四行四列


  (setq x 0)
  (setq y 0)

  (while(and(<= x 800)(<= y 800)(>= x 0)(>= y 0));选取游戏框图坐标点
  (setq x 0)
  (setq y 0)
  (setq p1 (getpoint"/n请选择"))
  (setq x (nth 0 p1))
  (setq y (nth 1 p1))
  (setq x (/ (+ x 50) 20))
  (setq y (/ (+ y 50) 20))
  (setq x1 (* 100 (fix x)))
  (setq y1 (* 100 (fix y)))
  (setq p1 (list x1 y1))

  (setq x2 x1)
  (setq y2 (+ 200 y1))
  (setq p2 (list x2 y2))

  (setq x3 (+ 200 x1))
  (setq y3 y1)
  (setq p3 (list x3 y3))

  (setq x4 (+ 200 x1))
  (setq y4 (+ 200 y1))
  (setq p4 (list x4 y4))
           
  (setq pt_list (list p2 p1 p3 p4))
  (setq ss1(ssget "wp" pt_list))
  (command "move" ss1 "1000,0" "2500,0" "")

)   
)
          
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-20 16:30 , Processed in 0.309443 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表