OOP Pong

BlitzMax Forums/BlitzMax Beginners Area/OOP Pong

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi.
1) The easiest thing is to give the paddle type an "up_key" and a "down_key" field, to initialise these values when you create the type and then use them within your drawing-method:
... = paddle.Create(790,265,4,False,KEY_UP,KEY_DOWN)

...
If cpu Then
    If KeyDown(up_key) then y=y-4
    If KeyDown(down_key) Then y=y+4
End If
...

2) I'd probably use a Function that does all the drawing (background, menu-entries, cursor, ...) manages the cursor control ("If KeyDown(KEY_UP) Then cursor=cursor-1") and returns an int when the user selects an entry (1=single player, 2=multiplayer, 3=highscores, ...).

3) You could either let the paddles draw the scores or give the background type a reference to the two paddle types.

4) It's personal preference and doesn't change how your prog works.

--Byteemoz