PDA

View Full Version : سوال: برنامه نویسی گیم پد



alicam
شنبه 30 آذر 1387, 01:37 صبح
سلام
دوستان من میخوام که برنامه ای بنویسم که در اون از گیم پد استفاده کنم. اما نمیدونم که چه جوری باید به گیم پد دسترسی پیدا کنم. من فکر میکنم که باید راه حلی مثل key down داشته باشه. اگه ممکنه یک نفر کمک بکنه
مرسی

neda.neda12
جمعه 18 اردیبهشت 1388, 16:37 عصر
سلام به همه عزیزان من یه برنامه گیم نوشتم اما ارور میده اگه کمکم کنید مشکلشو رفع کنم ممنون میشم
Dim x1, y1
Dim Score As Double
Dim BallNum As Byte
Const PadlTop = 500
Dim HM As Integer
Dim VM As Integer
Private Sub Form_Activate()
Padle.Top = Me.Height - PadlTop
x1 = 1
y1 = 1
HM = 30 * Rnd + 20
VM = 80 * Rnd + 20
BallNum = 30
lblBalls.Caption = BallNum & " Balls left"
Bar.Width = Me.Width - Bar.Left
lblExit.Left = Me.Width - lblExit.Width - 200
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then
End
End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If lblNew.ForeColor = vbRed Then lblNew.ForeColor = vbYellow
If lblExit.ForeColor = vbRed Then lblExit.ForeColor = vbYellow
If X > Me.Width - Padle.Width Then X = Me.Width - Padle.Width
Padle.Left = X
End Sub
Private Sub lblExit_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
lblExit.ForeColor = vbBlue
End Sub
Private Sub lblExit_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lblExit.ForeColor = vbRed
End Sub
Private Sub lblExit_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
End
End Sub
Private Sub lblNew_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
lblNew.ForeColor = vbBlue
End Sub
Private Sub lblNew_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lblNew.ForeColor = vbRed
End Sub
Private Sub lblNew_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim t
x1 = 1
y1 = 1
BallNum = 3
lblGameOver.Visible = False
lblBalls.Caption = BallNum & " Balls left."
Ball.Left = Me.Width / 2
Ball.Top = 500
Score = 0
lblScore.Caption = "0"
Timer1.Interval = 0
Ball.Visible = False
t = Timer
Do
DoEvents
Loop While Timer < t + 1
Ball.Visible = True
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
Ball.Left = Ball.Left + HM * x1
If Ball.Left + Ball.Width > Me.Width Or Ball.Left < 0 Then
x1 = x1 * -1
Beep
Score = Score + 150
lblScore.Caption = Score
End If
Ball.Top = Ball.Top + VM * y1
If Ball.Top > (Me.Height - PadlTop - Padle.Height) Then
If Ball.Left + Ball.Width > Padle.Left And Ball.Left < (Padle.Left + Padle.Width) Then
If Ball.Left + Ball.Width / 2 < Padle.Left + (Padle.Width / 2) Then
'HM = HM + 20
x1 = -1
End If
If Ball.Left + Ball.Width / 2 > Padle.Left + (Padle.Width / 2) Then
'HM = HM + 20
x1 = 1
End If
If Ball.Left + Ball.Width / 2 > Padle.Left + (Padle.Width / 2) - 45 And _
Ball.Left + Ball.Width / 2 < Padle.Left + (Padle.Width / 2) + 40 _
Then
'HM = HM + 20
x1 = 0
End If
y1 = y1 * -1
Beep
Score = Score + 500
lblScore.Caption = Score
Else
Timer1.Interval = 0
Ball.Visible = False
BallNum = BallNum - 1
lblBalls.Caption = BallNum & " Balls left."
If BallNum = 0 Then
lblGameOver.Visible = True
Timer1.Interval = 0
Exit Sub
End If
Dim t
t = Timer
Do
DoEvents
Loop While Timer < t + 1
Ball.Left = Me.Width / 2
Ball.Top = 500
Ball.Visible = True
Timer1.Interval = 1
Exit Sub
End If
End If

If Ball.Top < (Bar.Top + Bar.Height) Then
y1 = y1 * -1
Beep
Score = Score + 150
lblScore.Caption = Score
End If
End Sub

شماره ارور 424

kablayi
شنبه 19 اردیبهشت 1388, 02:42 صبح
دوست عزیز به جای این همه کد که معلوم نیست چی هست!!! خود برنامه رو آپلود میکردید...