buckwheat_88 Newbie
Joined: 16 Mar 2006 Posts: 1
|
Posted: Mar 16th, 2006 12:33 PM Post subject: Help with my high school vb game |
|
|
Hi,
I am working on a high school physics AP project and its programming a vb game. I have no coding experience and right now the only code I have is from a vb game programming book. Any help would be very appreciated. It is supposed to be similar to slime volleyball on addictinggames.com. I am putting the code here, but you can also e-mail me directly at buckwheat_88@pacbell.net for a .zip version.
| Code: |
Option Explicit
'Ball Information---------------------------------
Dim bmpBall As Double
'Ball Speed-----------------------
Dim vx As Integer
Dim vy As Integer
'Ball Starting Position----------
Dim XStart As Integer
Dim YStart As Integer
'Direction of Ball----------
Dim Xdir As Integer
Dim Ydir As Integer
'Change of Ball Speed-------
Dim UnitSp As Integer
'Slowest Ball Speed---------
Dim MinXSp As Integer
Dim MinYSp As Integer
'Ball Position
Dim X As Integer
Dim Y As Integer
'BuddyLeft Information-----------------------------
Dim bmpBuddyLeft As Double
'Start Position----------------
Dim XLStart As Integer
Dim YLStart As Integer
'BuddyLeft Speed--------
Dim BLeftIncrement As Double
'BuddyRight Information-----------------------------
Dim bmpBuddyRight As Double
'Start Position----------------
Dim XRStart As Integer
Dim YRStart As Integer
'BuddyLeft Speed--------
Dim BRightIncrement As Double
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
End Sub
Private Sub BS3_MouseMove(BUTTON As Integer, Shift As Integer, X As Single, Y As Single)
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft
BLeftIncrement = Abs(BLeftIncrement)
Case vbKeyRight
BLeftIncrement = -Abs(BLeftIncrement)
Case vbKeyA
BRightIncrement = Abs(BRightIncrement)
Case vbKeyD
BRightIncrement = -Abs(BRightIncrement)
Case Else
End Select
End Sub
Private Sub Form_Load()
XStart = (Picture1.ScaleWidth / 4)
YStart = (Picture1.ScaleHeight / 4)
XLStart = (Picture1.ScaleWidth / 4) - (BuddyLeft.Width / 2)
YLStart = (Picture1.ScaleHeight - BuddyLeft.Height)
XRStart = 3 * (Picture1.ScaleWidth / 4)
YRStart = (Picture1.ScaleHeight - BuddyRight.Height)
Ball.Left = XStart
Ball.Top = YStart
Ball.Width = Ball.Width
Ball.Height = Ball.Height
BuddyLeft.Left = XLStart
BuddyLeft.Top = YLStart
BuddyLeft.Width = BuddyLeft.Width
BuddyLeft.Height = BuddyLeft.Height
BuddyRight.Left = XRStart
BuddyRight.Top = YRStart
BuddyRight.Width = BuddyRight.Width
BuddyRight.Height = BuddyRight.Height
BLeftIncrement = 0
BRightIncrement = 0
End Sub
Private Sub start_Click()
Timer1.Enabled = True
End Sub
Private Sub stop_Click()
Timer1.Enabled = False
XStart = (Picture1.Width / 4) + (BuddyLeft.Width / 2)
YStart = (Picture1.Height / 4)
XLStart = (Picture1.Width / 4)
YLStart = (Picture1.Height - BuddyLeft.Height)
XRStart = 3 * (Picture1.Width / 4)
YRStart = (Picture1.Height - BuddyRight.Height)
End Sub
Private Sub Timer1_Timer()
Dim Xincr As Integer
Dim Yincr As Integer
Dim i As Integer
Dim SlimeCollision As Integer
Xincr = Xdir * vx
Yincr = Ydir * vy
If (bmpBall.Left + bmpBall.Width + Xincr) > picField.ScaleWidth Then
Xdir = -Xdir
Xincr = Xdir * vx
End If
If (bmpBall.Left + Xincr) < 0 Then
Xdir = -Xdir
Xincr = Xdir * vx
End If
If (bmpBall.Top + Yincr) < 0 Then
Ydir = -Ydir
Yincr = Ydir * vy
End If
If bmpBuddyLeft.Left <= 0 Then
bmpBuddyLeft.Left = 0
End If
If bmpBuddyRight.Left >= (picField.ScaleWidth - bmpBuddyRight.ScaleWidth) Then
bmpBuddyRight.Left = (picField.ScaleWidth - bmpBuddyRight.ScaleWidth)
End If
If bmpBall.Top <= (0) Then
Y = -Abs(Y)
End If
If bmpBall.Left <= 0 Then
X = Abs(X)
End If
If bmpBall.Left >= (picField.ScaleWidth - bmpBall.ScaleWidth) Then
X = -Abs(X)
End If
bmpBuddyLeft.Left = XLStart + BLeftIncrement
bmpBuddyRight.Left = XRStart + BRightIncrement
BRightIncrement = -200
BLeftIncrement = 200
End Sub
|
|
|