Click here to Skip to main content
Click here to Skip to main content

The Old Mighty Pong

By , 20 Aug 2007
 

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:

'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)

About the Author

Buffalloy
Bulgaria Bulgaria
Member
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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralZip File is Corruptmemberomnimicro7 Mar '08 - 8:40 
Zip File is Corrupt

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

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 21 Aug 2007
Article Copyright 2007 by Buffalloy
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid