Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Simple Pong Game (for DBC learners)

Author
Message
AluminumPork
20
Years of Service
User Offline
Joined: 28th Oct 2003
Location: Duluth, MN, USA
Posted: 23rd Nov 2003 06:48 Edited at: 23rd Nov 2003 06:48
This is a quick example of a super simple multiplayer pong game. It is fully commented and would be great for anyone wanting to learn about simple sprite movement, arrays, for/next and other simple ideas. Just thought I'd put it out there!

MikeS
Retired Moderator
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 23rd Nov 2003 19:40 Edited at: 23rd Nov 2003 19:41
Nice code you have there alluminumPork.

Only one problem I had. Whenever a player scored, it would only flash their score, so you weren't able to see it.

Luckily, I've fixed it.

-added sync rate 60
-added 2 print commands to display player_score(1) and player_score(2)
-added a little bar at the top to(hopefully) make the interface look nicer.
-Changed
IF ball_y < 0 then bally_dir = 1
to
IF ball_y < 15 then bally_dir = 1
-Version edited by yellow on 7th line



Really did a nice job, and hopefully this will point new programmers in the right direction.

kudos.
8)

[edit] I ran this in DBP and it worked fine.

A book? I hate book. Book is stupid.
genius
20
Years of Service
User Offline
Joined: 16th Oct 2003
Location: Utah, USA
Posted: 24th Nov 2003 01:31 Edited at: 24th Nov 2003 01:33
Quote: "I ran this in DBP and it worked fine. "

Yah, same here

Be happy, tomorrow is another day
MikeS
Retired Moderator
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 7th Dec 2003 01:03
This is one of those posts that should be stickied here, or moved to the Newcomer's section and stickied there.

*bump*




A book? I hate book. Book is stupid.
comando 300
20
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 7th Dec 2003 01:30
I don't understand this part
Quote: "REM -=-=-=-Draw a box (paddle) to the screen

BOX 1,1,10,50

REM -=-=-=-Grab the box and place it into an image slot

GET image 1, 1,1,10,50
"
Great Knight
21
Years of Service
User Offline
Joined: 25th Feb 2003
Location:
Posted: 9th Dec 2003 02:56
Commando300:
It is creating a image right inside the program for the paddle, instead of importing a all ready drawn image.

AMD Atherlon 2400+ XP, 380 DDr memeory, ATI Radeon 9000 64 DDR, Windos XP home edition.
-----------------------And a Katana.
comando 300
20
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 9th Dec 2003 19:16
but he use the same box coordanates to put it in an image slot?
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Dec 2003 00:05
get image image_number, x1,y1,x2,y2

get image grabs an image from the screen within the coordinates specified. They have to match the BOX's coordinates if you want to capture it into an image.
ginuwine
20
Years of Service
User Offline
Joined: 22nd Nov 2003
Location:
Posted: 13th Dec 2003 12:34
How would u put a background in this code??

Whot piece of code wqould u need 2 adjust?

Any1 know?

Dude
ginuwine
20
Years of Service
User Offline
Joined: 22nd Nov 2003
Location:
Posted: 13th Dec 2003 12:34
Also havin difficulty changing the images that r used 2 hit the ball?

Dude
qwe
20
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 3rd Jan 2004 13:59
to put a backround on, you can load an image at the start of the code, and then paste it right before all teh drawing commands in the main do loop, very simple

"BOX 1,1,10,50

REM -=-=-=-Grab the box and place it into an image slot

GET image 1, 1,1,10,50"

that puts a box onto the screen, then grabs the image to an image slot. you can replace "box 1,1,10,50" with "paste image x,1,1" where image x is an image you made and loaded, that way you can make a paddle in paint

Dell Dimension 4550, Windows XP Home
2.52 ghz, 256 Mb RAM, Radeon 9500 Pro / 9700

Login to post a reply

Server time is: 2024-05-03 16:25:52
Your offset time is: 2024-05-03 16:25:52