Visual_Basic 板


LINE

因为课业上的需求,所以做了一个走迷宫的小游戏, 基本上的执行都没问题,可是唯一的问题就出在: 我每走一步(每按一次移动键)迷宫地图就会闪烁一次。 因为我对VB的了解和使用还不是很熟悉,不知道要怎麽排解这个问题, 所以想请板上的高手们帮忙,可以教我或提示我应该怎麽修改吗? 程式码有点长,不过都在画迷宫,所以节录部分贴~ Dim Maze(40, 40) As Integer Dim ax, ay As Integer Dim bx, by As Integer Dim cx, cy As Integer ------------------------------------------------- Private Sub Command1_Click() Dim i As Integer, j As Integer Cls For y = 0 To ay Maze(0, y) = "1" Maze(ax, y) = "1" Next y For x = 0 To ax Maze(x, 0) = "1" Maze(x, ay) = "1" Next x For x = 1 To ax - 1 For y = 1 To ay - 1 Maze(x, y) = 1 For j = 4 To 7 Maze(2, j) = 0 Next For j = 7 To 10 Maze(3, j) = 0 Next (省略画迷宫~) Next y Next x Label1.Caption = "0" Maze(20, 20) = 2 '起点 bx = 20 by = 20 Maze(37, 37) = 3 '终点 show_maze End Sub --------------------------------------------------------- Sub show_maze() Cls For y = 0 To ay For x = 0 To ax If Maze(x, y) = 1 Then Print "■"; '地图呈现的图样 ElseIf Maze(x, y) = 2 Then Print "♂"; '起点 ElseIf Maze(x, y) = 3 Then Print "㊣"; '终点 Else Print " "; End If Next x Print Next y 'Label1.Caption = Label1.Caption & bx & "," & by End Sub ----------------------------------------------------- Private Sub Command1_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case 52 '4 Label1.Caption = Label1.Caption + 1 cx = -1 cy = 0 check_moving Case 56 '8 Label1.Caption = Label1.Caption + 1 cx = 0 cy = -1 check_moving Case 54 '6 Label1.Caption = Label1.Caption + 1 cx = 1 cy = 0 check_moving Case 50 '2 Label1.Caption = Label1.Caption + 1 cx = 0 cy = 1 check_moving End Select End Sub -------------------------------------------------- Private Sub Form_Load() ax = 39 ay = 39 End Sub -------------------------------------------------- Sub check_moving() Dim T As Integer T = Label1.Caption nx = bx + cx ny = by + cy If nx < 0 Or nx > ax Then Exit Sub If ny < 0 Or ny > ay Then Exit Sub If Maze(nx, ny) = 0 Or Maze(nx, ny) = 3 Or Maze(nx, ny) = 4 Then '允许移动 Maze(nx, ny) = 2 Maze(bx, by) = 0 bx = nx by = ny Else '会撞墙,不移动 End If show_maze End If End Sub -------------------------------------------------- 以上。 对不起贴上来的程式码很多, 希望有人可以帮我解决这个问题~ 非常感谢:) --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.211.28.23
1F:→ MOONRAKER:每次都cls当然会一直闪了 04/12 02:00
2F:→ MOONRAKER:现在还有这种DOS幽灵如影随形的程式,也不简单 04/12 02:01
3F:→ globav:甚麽是幽灵程式XDD 把show_maze的cls删掉之後, 04/12 13:02
4F:→ globav:每移动一次,它又重复print一个迷宫出来耶~ 04/12 13:03
5F:→ globav:删commond的cls好像没甚麽差别说.. 04/12 13:04
6F:→ MOONRAKER:因为你都用文字模式在印迷宫,自然需要cls 04/12 17:35
7F:→ MOONRAKER:也一定会有闪动问题,免不了的。(你认命吧。) 04/12 17:35
8F:→ MOONRAKER:正确的方法是把他重写成图形式的,每次只重划必要部份 04/12 17:36
9F:→ globav:图形式..有查到可以读取txt档内1和0产生迷宫..是指那个吗? 04/12 18:10
10F:→ MOONRAKER:把迷宫存到txt只是前端 後端怎麽画出来跟存不存txt无关 04/12 22:29
11F:→ MOONRAKER:要改成用画的 你需要知道shape的用法 (VB6 way) 04/12 22:36
12F:→ globav:谢谢MOONRAKER~ 我已经解决这个问题了~!!:) 04/14 22:33
13F:→ likemeizu999:刚刚还想贴上程式码玩走迷宫XD 04/15 12:17
14F:→ globav:楼上~画迷宫那段程式码超长XD.书面最後总共有70页说XDD 04/15 18:09
15F:→ globav:後来是把Form属性栏的AutoReDrew改True就不会闪烁了~ 04/15 18:10







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Gossiping站内搜寻

TOP