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 13
小游戏,目前能看到的就是:B自己动,P可以用鼠标移动,同时分数显示出来。
2014年12月03日 15点12分
7
这些我都明白…就是想知道代码的意思
2014年12月04日 15点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 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 :
![[笑眼]](/static/emoticons/u7b11u773c.png)
再次感谢~
2014年12月05日 12点12分