Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Direct X / Game Programming

Post new topic   Reply to topic
Help with my high school vb game
View previous topic :: View next topic  
Author Message
buckwheat_88
Newbie


Joined: 16 Mar 2006
Posts: 1

PostPosted: Mar 16th, 2006 12:33 PM    Post subject: Help with my high school vb game Reply with quote

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
Back to top
View user's profile Send private message Send e-mail AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Direct X / Game Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic