我想寫像貪食蛇的動態線
就是當它轉彎時
要讓後面的線段沿新的方向前進阿
急件! 請大家幫幫忙
2006-04-11 19:20:58 · 1 個解答 · 發問者 宣緯 1 in 電腦與網際網路 ➔ 程式設計
請問大大
這個 W = Me.TextWidth("*")
是做啥用的ㄚ ???
2006-04-12 16:22:35 · update #1
'表單置一個TimerPrivate Type Point X As Long Y As LongEnd TypeDim A(19) As Point, W&, F%Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)Select Case KeyCode Case 39: If F <> 1 Then F = 0 Case 37: If F > 0 Then F = 1 Case 38: If F < 3 Then F = 2 Case 40: If F <> 2 Then F = 3End SelectEnd SubPrivate Sub Form_Load()ScaleMode = 3KeyPreview = TrueW = Me.TextWidth("*")Timer1.Interval = 50Timer1.Enabled = TrueEnd SubPrivate Sub Timer1_Timer()Dim I&, B As Boolean, T As PointT = A(19)Select Case F Case 0 T.X = T.X + W Case 1 T.X = T.X - W Case 2 T.Y = T.Y - W Case 3 T.Y = T.Y + WEnd SelectIf T.X < 0 Then T.X = ScaleWidth - WIf T.X > ScaleWidth Then T.X = 0If T.Y < 0 Then T.Y = ScaleHeight - WIf T.Y > ScaleHeight Then T.Y = 0ForeColor = vbBlackCurrentX = T.XCurrentY = T.YPrint "*"ForeColor = Me.BackColorCurrentX = A(0).XCurrentY = A(0).YPrint "*"For I = 0 To 18 A(I) = A(I + 1)NextA(19) = TEnd Sub
2006-04-13 16:04:35 補充:
W= * 這個字的寬度
2006-04-12 12:28:21 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋