Jump to content
IGNORED

Pong


Galaxian

Recommended Posts

Hello, I'm designing a joystick pong game and, I don't know whether it's due to my age (12) or just lack of experience but I'm having trouble. It would be much appreciated if someone could send me some source code (I understand that might be difficult). I will use it a reference only, I will NOT directly copy the whole thing. I already have started on it and it's not bad I just need to know how to make it bounce when it hits the wall of paddle.

 

 

Sincerely,

Galaxian

Link to comment
Share on other sites

Didn't find any Pong examples but if you check out these:

http://www.atariage.com/forums/topic/109288-code-snippets-samples-for-bb-beginners/

 

I'm sure if you read through, compile and play with the examples above you'd be more than half-way to pong land :)

THANK YOU! It really is appreciated, however, I have already read through it and I've taken what I have from it.

 

On an unrelated note, I have encountered another problem. The playfield and objects haven't shown up.

I'm sure there will be a VERY simple answer and I'm SO sorry if I waste you time but, here is the source code:

 

COLUPF = 14

player0x = 30 : player0y = 44:player1x = 130 : player1y = 44

missile0height = 0

missile0x = 80

missile0y = 44

player0:

%00000000

%00011000

%00011000

%00011000

%00011000

%00011000

%00000000

end

player1:

%00000000

%00011000

%00011000

%00011000

%00011000

%00011000

%00000000

end

playfield:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

................................

................................

................................

................................

................................

................................

................................

................................

................................

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

end

 

mainloop

 

colup0 = 14

colup1 = 14

drawscreen

if joy0up then player0y=player0y+2

if joy0down then player0y=player0y-2

if joy1up then player1y=player1y+2

if joy1down then player1y=player1y-2

 

 

 

if collision (missile0,player0) then

AUDV0=15

AUDC0=4

AUDF0=13

musictimer=30

 

 

 

if collision (missile0,player1) then

AUDV0=15

AUDC0=4

AUDF0=13

musictimer=30

Edited by Galaxian
Link to comment
Share on other sites

A few things I see at first glance...

  • colup0 and colup1 should be COLUP0 and COLUP1
  • you were missing a "goto mainloop" at the end
  • if statements don't work over multiple lines in bB

COLUPF = 14
player0x = 30 : player0y = 44:player1x = 130 : player1y = 44
missile0height = 0
missile0x = 80
missile0y = 44
player0:
%00000000
%00011000
%00011000
%00011000
%00011000
%00011000
%00000000
end
player1:
%00000000
%00011000
%00011000
%00011000
%00011000
%00011000
%00000000
end
playfield:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
................................
................................
................................
................................
................................
................................
................................
................................
................................
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end

mainloop

COLUP0 = 14
COLUP1 = 14
drawscreen
if joy0up then player0y=player0y+2
if joy0down then player0y=player0y-2
if joy1up then player1y=player1y+2
if joy1down then player1y=player1y-2

if collision (missile0,player0) then AUDV0=15:AUDC0=4:AUDF0=13:musictimer=30
if collision (missile0,player1) then AUDV0=15:AUDC0=4:AUDF0=13:musictimer=30

goto mainloop

 

I don't have the opportunity to try it out, but I think that should work.

Edited by RevEng
Link to comment
Share on other sites

That's REALLY, REALLY good of you guys, but this game is my first one, so I have NO idea what half of those commands mean. Also, I have encountered yet another problem, when I go to compile the game, it comes up with the following error message: (52): Error: Unknown keyword: player0

 

Here is the source (yet again):

 

COLUPF = 14

player0x = 30 : player0y = 44:player1x = 130 : player1y = 44

missile0height = 0

missile0x = 80

missile0y = 44

 

player0:

%00000000

%00011000

%00011000

%00011000

%00011000

%00011000

%00000000

end

 

player1:

%00000000

%00011000

%00011000

%00011000

%00011000

%00011000

%00000000

end

playfield:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

................................

................................

................................

................................

................................

................................

................................

................................

................................

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

end

 

mainloop

 

AUDV0 = 15

COLUP0 = 14

COLUP1 = 14

drawscreen

if joy0up then player0y=player0y+2

if joy0down then player0y=player0y-2

if joy1up then player1y=player1y+2

if joy1down then player1y=player1y-2

 

 

if collision (missile0,player0) then AUDC0=4:AUDF0=13:musictimer=30

 

 

if collision (missile0,player1) then AUDC0=4:AUDF0=13:musictimer=30

goto mainloop

 

Thank you SOOO much for all your effort!

(Don't worry, the "end" and "mainloop" aren't spaced)

Edited by Galaxian
Link to comment
Share on other sites

The error that comes up is due to a lack of spaces before certain lines. If you're using visualbB, you could keep things simple by going through and clicking on the end of each line, pressing enter, then hitting delete.

 

When you type a line of code in VbB, make sure you press enter after it, then delete the tab down if needed.

Link to comment
Share on other sites

The error that comes up is due to a lack of spaces before certain lines. If you're using visualbB, you could keep things simple by going through and clicking on the end of each line, pressing enter, then hitting delete.

 

When you type a line of code in VbB, make sure you press enter after it, then delete the tab down if needed.

Thank you, do you know which lines?

Link to comment
Share on other sites

There might be some problems with indentation. Especially check out how yer sprites and playfields indentation differs from the examples.

 

Also, remember your

 

set romsize

 

and

 

set kernel_options

 

lines at the very beginning.

Okay, I've done that. However, something is wrong with my set romsize 4k syntax.

default.bas

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...