Click here to Skip to main content
15,894,090 members
Articles / Programming Languages / Visual Basic

The Old Mighty Pong

Rate me:
Please Sign up or sign in to vote.
3.33/5 (3 votes)
20 Aug 2007CPOL1 min read 27.7K   387   13   1
A classic in game history.

Introduction

I was staring in shock at some VB6 tutorials on how to make Pong. There were shown some awful functions, libraries, and things I couldn't understand. So I thought I could simplify the code to a level which a programmer with my experience would understand. I began to code from scratch, and in a few days, I managed to accomplish the task...

Background

Well, I suppose that many of you have played Pong... it's just a classic. But in my solution, there are some tricky parts, like the controls - they are buttons which have captions with "&" in front. And when set the controls section, you will probably notice that if you delete the char "&" before the actual control, it wouldn't work...

Using the Code

The code is nothing serious as I mentioned earlier. I have replaced the currenX position with the "Left" property and currentY with "Top".

Here is a piece of the code:

VB
'timer sub 
If Ball.Top = 0 Then optDown.Checked = True
If Ball.Top = 264 Then optUp.Checked = True
If optUp.Checked = True Then Ball.Top = Ball.Top - 1
If optDown.Checked = True Then Ball.Top = Ball.Top + 1
If optLeft.Checked = True Then Ball.Left = Ball.Left - 1
If optRight.Checked = True Then Ball.Left = Ball.Left + 1
If Ball.Left < -20 Then lblP2Score.Text = lblP2Score.Text + 1
If Ball.Left > 408 Then lblP1Score.Text = lblP1Score.Text + 1

Points of Interest

I was very exited when I did it, because I got to know a new way of making objects move. And I finally made an app from which I earned :D

History

I will keep an eye on your requests for improvement. If you'd like to contact me - my e-mail is buffallo@abv.bg.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Bulgaria Bulgaria
I was born in Plovdiv, Bulgaria in1991.

I began programming two years ago, and the firs language I encountered was Pascal. I got to know it very well, but five or six months ago I took up Visual Basic. I still study it, and as far as I can see I have a lot to do, befor I can develop serious apps and games.It's hard to study programming when you are in highschool... Pitty...
Dimitar Todorov, BG.

Comments and Discussions

 
GeneralZip File is Corrupt Pin
omnimicro7-Mar-08 8:40
omnimicro7-Mar-08 8:40 

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.