orufet 07-26-2001, 03:14 PM A simple Pong game for you guys to have a look at. I started writing this before I knew about Global variables, so I used an invisible text box to pass the variables from one sub to another. Yeah, I know, not the best, but I'm too lazy to fix it up. By the way, the AI paddle is impossible to beat! images/icons/wink.gif
If anyone wants to take this and improve on it, please do. Feel free to steal the code, do whatever.
http://www.sheehy.ca/pong.zip
Jacob Sheehy
http://www.sheehy.ca
Multitasking - screwing up several things at once <P ID="edit"><FONT class="small"><EM>Edited by orufet on 07/27/01 01:56 PM.</EM></FONT></P>
Teric 07-27-2001, 12:18 PM Broken link--I tried to get to the .zip file, and it appears to be a bad URL.
orufet 07-27-2001, 12:56 PM Try it now, it should work, sorry about that
Jacob Sheehy
http://www.sheehy.ca
The more I C, the less I see.
BillSoo 07-27-2001, 12:59 PM Not for me it doesn't....
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
Teric 07-27-2001, 01:04 PM Nope, still doesn't work.
orufet 07-27-2001, 01:16 PM Open a new browser and type http://www.sheehy.ca/Pong.zip and it should work, it works for me....
Jacob Sheehy
http://www.sheehy.ca
The more I C, the less I see.
Teric 07-27-2001, 01:37 PM Got it, thanks.
Teric 07-27-2001, 01:43 PM I ran it, and I have a few comments.
-It runs pretty well, but there is still a bit of flicker as the ball moves around.
-It looks like you built it on a high-resolution screen. My screen is set to 1024x768, and the form was still bigger than my screen (i.e. the paddle and ball often went off-screen.)
-I assume that the arrow keys control the paddle on the right. However, I cannot see it, because it's off screen.
-Nice fast action and movement.
orufet 07-27-2001, 01:49 PM Thank you, I will try to fix that.....I completely forgot that screen resolution would be a problem.....Thank you for letting me know about that!
The ball does not flicker for me......
Edit: I just uploaded a new version, let me know if it's any better
Jacob Sheehy
http://www.sheehy.ca
The more I C, the less I see.<P ID="edit"><FONT class="small"><EM>Edited by orufet on 07/27/01 02:56 PM.</EM></FONT></P>
BillSoo 07-27-2001, 02:21 PM Here is a <a href="http://www.visualbasicforum.com/bbs/showflat.php?Cat=&Board=gp&Number=9668&page=1&view=collapsed&sb=6&o=all&part="> link </a> to a post I made almost a year ago. It includes a breakout style game. It may give you some ideas....it has some flicker problems as well, but they are not as bad.
To totally eliminate flicker, you need to have no objects other than the picturebox. Then just draw all your objects to the screen with AutoRedraw set to true...
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
Teric 07-27-2001, 02:51 PM Another way to eliminate flicker is to use double-buffering.
What is double-buffering? Well, it entails having two drawing surfaces and only displaying one at a time. The one that is displayed contains what the user sees, and the other, non-displayed surface is where you do your drawing.
Because the actual drawing is being done in the background and not on a visible form, it goes faster. Once you're done drawing on the background surface, switch the two surfaces. Make your visible surface invisible, and your background surface visible (in essence, flip the surfaces). Now, clear the form that you just made invisible and draw your next frame on it while the frame you just finished drawing is displayed to the user.
No flicker!
I'll try to attach an example. I am working on a crude Real-Time Strategy game that is still in the VERY early stages. However, it gives an example of this double-buffering concept. I use two picture boxes as my drawing surfaces, and to 'flip'them, I simply make one visible and the other invisible.
Download the attachment to see my game as it stands. When you run it, you will see 4 soldiers on the screen, 2 blue, 2 red. To move them, left click on one and then right-click on a destination. You will see a framerate on the upper-left portion of the screen.
I have even implemented some crude collision-detection in this one--if friendly soldiers collide, they go around each other. If enemy soldiers collide, they 'attack' each other.
Press ESC to break out of the game.
I hope this helps...
Teric 07-27-2001, 03:01 PM I just re-downloaded your pong program. Same problems--can't see my own paddle.
BillSoo 07-27-2001, 03:02 PM ...pretty nice....
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
Teric 07-27-2001, 03:04 PM *blush*
Thanks.
orufet 07-27-2001, 06:34 PM Teric: Could you maybe try to find out why it's not working? I thought the code I added would make it work.....The paddle is positioned by using.....
Paddle.Left = Screen.Width - 100
or something like that....
Jacob Sheehy
http://www.sheehy.ca
The more I C, the less I see.
BillSoo 07-27-2001, 06:38 PM I use 1024x768 as well but I can see my paddle.
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
orufet 07-27-2001, 06:41 PM I just changed my resultion to 1024 x 768, and it worked fine. Wonder what's causing this?
Jacob Sheehy
http://www.sheehy.ca
The more I C, the less I see.
dcl3500 07-27-2001, 07:58 PM Pretty neat. 2 things to say:
1. I'm envious. I wish I could bend my mind to games, but there is just some kind of mental block there.
2. It's really scary because I had one of those old Pong consoles when I was a kid. Brand new one year for Christmas. Man that was a long time ago. images/icons/smile.gif
Don
Time is the best teacher; unfortunately it kills all its students.
orufet 07-28-2001, 12:48 PM As you know, this is the simplest of games, and I'm struggling with anything more than this....images/icons/wink.gif. Thanks, though
Jacob Sheehy
http://www.sheehy.ca
The more I C, the less I see.
Teric 07-28-2001, 07:37 PM I downloaded it at home, with a 1024x768 resolution, and it worked fine. :-) Nice work.
dcl3500 07-28-2001, 07:43 PM Hey I just ran it at 800x600 and I beat it, well actually the ball got stuck behind the AI's paddle, so I really didn't beat it images/icons/smile.gif. Anyways, I could see both paddles.
Don
Time is the best teacher; unfortunately it kills all its students.
orufet 07-28-2001, 08:32 PM Thanks, I'm glad it's decent! I'll have to fix that error where the ball gets stuck.....oh well
Jacob Sheehy
http://www.sheehy.ca
The more I C, the less I see.
|