Click here to Skip to main content
16,005,069 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: MAC address for client M/c Pin
Dave Kreskowiak26-Aug-07 9:15
mveDave Kreskowiak26-Aug-07 9:15 
QuestionRegarding IL Pin
Ahamed Azeem26-Aug-07 1:36
Ahamed Azeem26-Aug-07 1:36 
AnswerRe: Regarding IL Pin
Christian Graus26-Aug-07 1:45
protectorChristian Graus26-Aug-07 1:45 
AnswerRe: Regarding IL Pin
Colin Angus Mackay26-Aug-07 2:00
Colin Angus Mackay26-Aug-07 2:00 
AnswerRe: Regarding IL Pin
Dave Kreskowiak26-Aug-07 4:35
mveDave Kreskowiak26-Aug-07 4:35 
GeneralRe: Regarding IL Pin
Ahamed Azeem26-Aug-07 21:04
Ahamed Azeem26-Aug-07 21:04 
AnswerRe: Regarding IL Pin
Paul Conrad26-Aug-07 8:06
professionalPaul Conrad26-Aug-07 8:06 
Questioncollision problem Pin
bapu288926-Aug-07 1:34
bapu288926-Aug-07 1:34 
hello every one

i am working on my assignment and i have done about 75% work but i am strugling to collid ball with padle i mean bat so can any one help me with this issue code is like this

some time it works but some time it's behaive very funny

Option Explicit On <br />
Option Strict On<br />
Public Class frmPong<br />
    Inherits System.Windows.Forms.Form<br />
<br />
#Region " Windows Form Designer generated code "<br />
<br />
    Public Sub New()<br />
        MyBase.New()<br />
<br />
        'This call is required by the Windows Form Designer.<br />
        InitializeComponent()<br />
<br />
        'Add any initialization after the InitializeComponent() call<br />
<br />
    End Sub<br />
<br />
    'Form overrides dispose to clean up the component list.<br />
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
        If disposing Then<br />
            If Not (components Is Nothing) Then<br />
                components.Dispose()<br />
            End If<br />
        End If<br />
        MyBase.Dispose(disposing)<br />
    End Sub<br />
<br />
    'Required by the Windows Form Designer<br />
    Private components As System.ComponentModel.IContainer<br />
<br />
    'NOTE: The following procedure is required by the Windows Form Designer<br />
    'It can be modified using the Windows Form Designer.  <br />
    'Do not modify it using the code editor.<br />
    Friend WithEvents timPong As System.Windows.Forms.Timer<br />
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br />
        Me.components = New System.ComponentModel.Container<br />
        Me.timPong = New System.Windows.Forms.Timer(Me.components)<br />
        '<br />
        'timPong<br />
        '<br />
        '<br />
        'frmPong<br />
        '<br />
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)<br />
        Me.BackColor = System.Drawing.Color.GreenYellow<br />
        Me.ClientSize = New System.Drawing.Size(728, 461)<br />
        Me.Name = "frmPong"<br />
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen<br />
        Me.Text = "PingPong"<br />
<br />
    End Sub<br />
<br />
#End Region<br />
    Const BALL_WID As Integer = 50<br />
    Const BALL_HGT As Integer = 50<br />
    Const MyBall As Integer = 1<br />
    Dim BallDirX(MyBall), BallXSpd(MyBall) As Integer<br />
    Dim BallDirY(MyBall), BallYSpd(MyBall) As Integer<br />
    Dim BallX(MyBall) As Integer<br />
    Dim BallY(MyBall) As Integer<br />
    Dim MyBrush As Drawing.Brush<br />
    Dim BallImage(MyBall) As Drawing.Image<br />
    Dim MyDrawing As Drawing.Graphics<br />
    Dim Colors(10) As Drawing.Brush<br />
    Dim MyBat1, MyBat2, BallRct(MyBall) As Drawing.Rectangle<br />
    Dim MyPen As Drawing.Pen<br />
    Dim L, T As Integer<br />
<br />
    Private Sub frmPong_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
        'choose color<br />
        Colors(1) = Brushes.BlueViolet<br />
        Colors(2) = Brushes.Blue<br />
        Colors(3) = Brushes.Green<br />
        Colors(4) = Brushes.Red<br />
        Colors(5) = Brushes.Yellow<br />
        Colors(6) = Brushes.Aqua<br />
        Colors(7) = Brushes.Black<br />
        Colors(8) = Brushes.Brown<br />
        Colors(9) = Brushes.DarkOrange<br />
        Colors(10) = Brushes.Navy<br />
<br />
        'choose random color<br />
        MyBrush = Colors(CInt(Rnd() * 10 - 0.5 + 1))<br />
        Randomize()<br />
        'bat1 and bat2 dimention<br />
        L = 30 : T = 100<br />
        'draw bat1<br />
        MyBat1 = New Drawing.Rectangle(CInt(L / 2), CInt(Me.ClientRectangle.Height / 2) - CInt(T / 2), L, T)<br />
        'draw bat2<br />
        MyBat2 = New Drawing.Rectangle(Me.ClientRectangle.Width - L - CInt(L / 2), CInt(Me.ClientRectangle.Height / 2) _<br />
        - CInt(T / 2), L, T)<br />
        'randomize ball direction<br />
        For I As Integer = 1 To MyBall<br />
            BallDirX(I) = CInt(Rnd() * 3 - 0.5)<br />
            BallDirY(I) = CInt(Rnd() * 3 - 0.5)<br />
            BallX(I) = CInt(Rnd() * (Me.ClientSize.Width - BALL_WID))<br />
            BallY(I) = CInt(Rnd() * (Me.ClientSize.Height - BALL_HGT))<br />
            'randomize speed<br />
            BallXSpd(I) = 3 + CInt(Rnd() * 8 - 0.5)<br />
            BallYSpd(I) = 3 + CInt(Rnd() * 8 - 0.5)<br />
        Next I<br />
        Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _<br />
            ControlStyles.DoubleBuffer, True)<br />
        Me.UpdateStyles()<br />
        timPong.Enabled = True<br />
    End Sub<br />
<br />
    Private Sub timPong_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timPong.Tick<br />
<br />
        For I As Integer = 1 To MyBall<br />
            BallX(I) = BallX(I) + BallDirX(I) * BallXSpd(I)<br />
            BallY(I) = BallY(I) + BallDirY(I) * BallYSpd(I)<br />
            BallRct(I) = New Rectangle(BallX(I), BallY(I), BALL_WID, BALL_HGT)<br />
            If BallX(I) < 0 Then<br />
                BallDirX(I) = -BallDirX(I)<br />
                Beep()<br />
                'choose random color<br />
                MyBrush = Colors(CInt(Rnd() * 10 - 0.5 + 1))<br />
                CheckCollision()<br />
            ElseIf BallX(I) + BALL_WID > Me.ClientSize.Width Then<br />
                BallDirX(I) = -BallDirX(I)<br />
                Beep()<br />
                'choose random color<br />
                MyBrush = Colors(CInt(Rnd() * 10 - 0.5 + 1))<br />
                CheckCollision()<br />
            End If<br />
            If BallY(I) < 0 Then<br />
                BallDirY(I) = -BallDirY(I)<br />
                Beep()<br />
                'choose random color<br />
                MyBrush = Colors(CInt(Rnd() * 10 - 0.5 + 1))<br />
                CheckCollision()<br />
            ElseIf BallY(I) + BALL_HGT > Me.ClientSize.Height Then<br />
                BallDirY(I) = -BallDirY(I)<br />
                Beep()<br />
                'choose random color<br />
                MyBrush = Colors(CInt(Rnd() * 10 - 0.5 + 1))<br />
                CheckCollision()<br />
            End If<br />
            If BallX(I) < MyBat1.X Then<br />
                BallDirX(I) = -BallDirX(I)<br />
            End If<br />
        Next I<br />
        Me.Invalidate()<br />
<br />
    End Sub<br />
<br />
    Private Sub frmPong_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint<br />
        e.Graphics.Clear(Me.BackColor)<br />
<br />
        e.Graphics.FillEllipse(MyBrush, BallX(MyBall), BallY(MyBall), BALL_WID, BALL_HGT)<br />
<br />
        e.Graphics.FillRectangle(MyBrush, MyBat1)<br />
        e.Graphics.FillRectangle(MyBrush, MyBat2)<br />
    End Sub<br />
    Public Sub CheckCollision()<br />
        Dim Collid As Rectangle, Collided As Boolean<br />
        Collid = Collid.Intersect(BallRct(MyBall), MyBat1)<br />
        If Not (Collid.IsEmpty) Then<br />
            BallX(MyBall) = 1<br />
<br />
        End If<br />
<br />
    End Sub<br />
<br />
    Private Sub frmPong_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown<br />
        CheckCollision()<br />
        Select Case e.KeyCode<br />
            Case Keys.Up<br />
                MyBat1.Y -= 10<br />
            Case Keys.Down<br />
                MyBat1.Y += 10<br />
            Case Keys.Right<br />
                MyBat1.X += 10<br />
            Case Keys.Left<br />
                MyBat1.X -= 10<br />
<br />
        End Select<br />
    End Sub<br />
End Class


you can just copy and past this code and please have look

i have tried lot but i dont know how to deal with this problem
so please please please help me with this
thanks in advance

waiting for your kind rep.Confused | :confused:
AnswerRe: collision problem Pin
Dave Kreskowiak26-Aug-07 4:34
mveDave Kreskowiak26-Aug-07 4:34 
GeneralRe: collision problem Pin
bapu288926-Aug-07 4:49
bapu288926-Aug-07 4:49 
GeneralRe: collision problem Pin
Dave Kreskowiak26-Aug-07 5:05
mveDave Kreskowiak26-Aug-07 5:05 
GeneralRe: collision problem [modified] Pin
bapu288926-Aug-07 5:13
bapu288926-Aug-07 5:13 
QuestionDouble Click on Combo Box Pin
Widgets25-Aug-07 23:48
Widgets25-Aug-07 23:48 
AnswerRe: Double Click on Combo Box Pin
Dave Kreskowiak26-Aug-07 4:24
mveDave Kreskowiak26-Aug-07 4:24 
GeneralRe: Double Click on Combo Box Pin
Widgets26-Aug-07 14:48
Widgets26-Aug-07 14:48 
GeneralRe: Double Click on Combo Box Pin
Vaibhav Sharma26-Aug-07 15:45
Vaibhav Sharma26-Aug-07 15:45 
GeneralRe: Double Click on Combo Box Pin
Widgets26-Aug-07 16:45
Widgets26-Aug-07 16:45 
GeneralRe: Double Click on Combo Box Pin
Dave Kreskowiak26-Aug-07 15:48
mveDave Kreskowiak26-Aug-07 15:48 
GeneralRe: Double Click on Combo Box Pin
Widgets26-Aug-07 20:10
Widgets26-Aug-07 20:10 
QuestionMatchWithList in Combo Box? Pin
Widgets25-Aug-07 23:47
Widgets25-Aug-07 23:47 
AnswerRe: MatchWithList in Combo Box? Pin
Dave Kreskowiak26-Aug-07 4:25
mveDave Kreskowiak26-Aug-07 4:25 
GeneralRe: MatchWithList in Combo Box? Pin
Widgets26-Aug-07 15:29
Widgets26-Aug-07 15:29 
GeneralRe: MatchWithList in Combo Box? Pin
Dave Kreskowiak26-Aug-07 15:43
mveDave Kreskowiak26-Aug-07 15:43 
GeneralRe: MatchWithList in Combo Box? Pin
Suraj Babu19-Aug-11 0:10
Suraj Babu19-Aug-11 0:10 
GeneralRe: MatchWithList in Combo Box? Pin
Dave Kreskowiak19-Aug-11 1:57
mveDave Kreskowiak19-Aug-11 1:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.