【愿得一大神】求大神给我解释一段代码
vb.net吧
全部回复
仅看楼主
level 4
毕竟我会打滚 还会暖床[乖]
2014年12月03日 11点12分 1
level 4
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
B.Left += Vx
B.Top += Vy
If B.Left < 0 Then
Vx = Math.Abs(Vx)
End If
If B.Right > Me.ClientSize.Width Then
Vx = -Math.Abs(Vx)
End If
If B.Top < 0 Then
Vy = Math.Abs(Vy)
End If
If B.Bottom > P.Top Then
Dim C As Integer = (B.Left + B.Right) / 2
If C >= P.Left AndAlso C <= P.Right Then
Dim F As Double = (CDbl(C) - CDbl(P.Left)) / CDbl(P.Width)
If Vx < 0 Then
F = (1.0 - F)
End If
F = F + 0.5
Vx = CInt(Math.Round(Vx * F))
Vy = -Math.Abs(Vy)
Score = Score + 10
Me.Text = "分数:" & Score.ToString()
Else
If B.Bottom > Me.ClientSize.Height Then
Timer1.Stop()
MsgBox("Game Over!", , "提示")
B.Left = 220
B.Top = 200
Score = 0
Vx = 5
Vy = 5
Me.Text = "分数:" & Score.ToString()
End If
End If
End If
End Sub
2014年12月03日 12点12分 2
还能暖床不[阴险]
2018年07月07日 09点07分
level 4
Private Sub P_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles P.MouseDown
Timer1.Start()
Cursor.Current = Cursors.Hand
MDx = e.X
End Sub
2014年12月03日 12点12分 3
level 4
Private Sub P_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles P.MouseMove
If e.Button = MouseButtons.Left Then
Dim x As Integer = P.Left + (e.X - MDx)
If x < 0 Then
x = 0
End If
If x > Me.ClientSize.Width - P.Width Then
x = Me.ClientSize.Width - P.Width
End If
P.Left = x
End If
End Sub
2014年12月03日 12点12分 4
level 4
[泪] 你们在哪里~
2014年12月03日 12点12分 5
level 1
过来给我暖床呗[酷]
2014年12月03日 15点12分 6
给我翻译代码就暖[酷]
2014年12月03日 15点12分
回复 睡意朦胧的思念 :我不会,呢你就不给我暖床了啊[泪]
2014年12月03日 15点12分
回复 Theprofessor2 :[泪][泪][泪]
2014年12月04日 15点12分
level 13
小游戏,目前能看到的就是:B自己动,P可以用鼠标移动,同时分数显示出来。
2014年12月03日 15点12分 7
这些我都明白…就是想知道代码的意思[太开心]
2014年12月04日 15点12分
level 13
B碰到底线就game over了
2014年12月03日 16点12分 8
level 13
有点像以前玩过的小蜜蜂和打飞机
2014年12月03日 16点12分 9
就是那个板块接球的[乖]
2014年12月04日 15点12分
level 1
请叫我大神[滑稽][滑稽][滑稽]
2014年12月03日 23点12分 10
边去[喷]
2014年12月04日 15点12分
回复 睡意朦胧的思念 :[黑线][黑线]
2014年12月04日 23点12分
回复 qq378416954qd :你做完了?
2014年12月05日 01点12分
level 1
[滑稽]请叫我神大
2014年12月04日 08点12分 11
[滑稽]
2014年12月04日 15点12分
神大快来给我翻译下[泪]
2014年12月05日 01点12分
回复 睡意朦胧的思念 :[滑稽]我是VB彩笔
2014年12月05日 01点12分
回复 碎夢爺 :自己翻译的实在是心塞[吐]
2014年12月05日 03点12分
level 13
前面两句是球的坐标增加vx,vy,代表球在移动。接下几句就是球碰到4个边的时候坐标怎样变。
2014年12月04日 15点12分 12
level 4
If B.Bottom > P.Top Then
Dim C As Integer = (B.Left + B.Right) / 2
If C >= P.Left AndAlso C <= P.Right Then
Dim F As Double = (CDbl(C) - CDbl(P.Left)) / CDbl(P.Width)
If Vx < 0 Then
F = (1.0 - F)
End If
F = F + 0.5
Vx = CInt(Math.Round(Vx * F))
Vy = -Math.Abs(Vy)
Score = Score + 10
Me.Text = "分数:" & Score.ToString()
Else
If B.Bottom > Me.ClientSize.Height Then
Timer1.Stop()
MsgBox("Game Over!", , "提示")
B.Left = 220
B.Top = 200
Score = 0
Vx = 5
Vy = 5
Me.Text = "分数:" & Score.ToString()
End If
End If
End If
2014年12月05日 03点12分 13
level 4
求这段的注释[泪]
2014年12月05日 03点12分 14
level 13
If B.Bottom > P.Top Then : // 垂直方向 :B 的底 低于 P的顶
If C >= P.Left AndAlso C <= P.Right //水平方向 : B的中心在P的范围内,就是说接住球了。加10分在form标题那里显示出来。
If B.Bottom > Me.ClientSize.Height Then // B到底线了,GAMEOVER。
2014年12月05日 06点12分 15
嗯嗯嗯嗯 大神 真是太感谢你了[乖]
2014年12月05日 06点12分
Dim F As Double = (CDbl(C) - CDbl(P.Left)) / CDbl(P.Width) 那这一句呢
2014年12月05日 07点12分
(f=球接触拍子的位置,最左边0,中间0.5 ,最右边1 )不同,反弹力度就不同,F决定了球下次移动时水平方向的速度。
2014年12月05日 09点12分
回复 zhengtiger2003 :[笑眼]再次感谢~
2014年12月05日 12点12分
level 1
还有注释吗
2018年07月05日 09点07分 16
level 1
2楼的解释
2018年07月07日 09点07分 17
1