Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 149,954 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,331 people online right now. Registration is fast and FREE... Join Now!




Help making a pong game

 
Reply to this topicStart new topic

Help making a pong game, how many timers do i need to mkae it go diagnol and what are there cod

Learner15
16 Dec, 2007 - 11:35 AM
Post #1

New D.I.C Head
*

Joined: 15 Nov, 2007
Posts: 5


My Contributions
CODE
Public Class Form1
Const intformsize As Integer = 407
Const intxformsize As Integer = 333
Const intwidthPaddle As Integer = 20
Const intheightPaddle As Integer = 90
Const intwidthball As Integer = 15
Const intwidthPaddle2 As Integer = 20
Const intheightPaddle2 As Integer = 90
Const intheightball As Integer = 15
Dim intxBall As Integer
Dim intyBall As Integer
Dim intxPaddle As Integer = 367
Dim intyPaddle As Integer = 106
Dim intxPaddle2 As Integer = 12
Dim intyPaddle2 As Integer = 26

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Down Then
intyPaddle = intyPaddle - 10
End If
If e.KeyCode = Keys.Up Then
intyPaddle = intyPaddle + 10
End If
If e.KeyCode = Keys.A Then
intyPaddle2 = intyPaddle - 10
End If
If e.KeyCode = Keys.S Then
intyPaddle2 = intyPaddle2 + 10
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Randomize()
intxPaddle = picPaddle1.Width
intxBall = intxformsize - 200
intyball = Rnd() * intyformsize
tmrLeft.Start()
End Sub

Private Sub tmrRight_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrRight.Tick
intxBall = intxBall + 1
picBlueBall.Location = New System.Drawing.Point(intxBall, intyBall)
If intxBall > intxformsize Then
intxBall = 0
intyBall = Rnd() * (intyformsize - intheightball)
Else
If (intxBall >= intxPaddle2 - intwidthpaddle2) Then
If (intyBall + intwidthball > intyPaddle2) And (intyBall + intwidthball < intyPaddle2 + intheightPaddle2) Then
tmrRight.Stop()
tmrLeft.Start()
End If
End If
End If
End Sub

Private Sub tmrLeft_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrLeft.Tick
intxBall = intxBall - 1
picBlueBall.Location = New System.Drawing.Point(intxBall, intyBall)
If intxBall > intxformsize Then
intxBall = 0
intyBall = Rnd() * (intyformsize - intheightball)
Else
If (intxBall <= intxPaddle + intwidthPaddle) Then
If (intyBall + intwidthball > intyPaddle) And (intyBall + intwidthball < intyPaddle + intheightPaddle) Then
tmrLeft.Stop()
tmrRight.Start()
End If
End If
End If

End Sub

End Class

User is offlineProfile CardPM
+Quote Post

Jayman
RE: Help Making A Pong Game
16 Dec, 2007 - 12:10 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,317



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Moved to VB.NET
User is offlineProfile CardPM
+Quote Post

RodgerB
RE: Help Making A Pong Game
18 Dec, 2007 - 06:43 AM
Post #3

D.I.C Lover
Group Icon

Joined: 21 Sep, 2007
Posts: 2,166



Thanked: 17 times
Dream Kudos: 2200
Expert In: Dot Net Technologies

My Contributions
You might like to read my VB.NET Pong Tutorial.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 05:53PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month