Log In  

Just wanted to share my %95 complete Pong game in order to get some feedback. The main thing I'd like to change is make the ball run faster after every hit, and add some rudimentary AI for a single player mode.

P#77346 2020-05-29 01:49

It looks and plays like how I imagine Pong to look and play. So, for first bit of feedback: it's good. :)

But I've never played any official Pong game. :/


Beyond that, I'm a little unsure what feedback you're looking for. As you haven't specified, I'll cover a few things briefly.

I'm presuming when you write "The main thing I'd like to change is make the ball run faster after every hit, and add some rudimentary AI for a single player mode." that these are your intentions and not something you need help with - your code works well enough that I think you can implement both of these without any advice/feedback on them. (The simplest AI in Pong is probably to check whether the ball has a greater y variable than the paddle, then move the paddle accordingly.)

It uses vectors to move the ball which is fine for Pong - certainly Pong-like games on which I have played do the same. Another alternative is to use an angle and a speed and some trigonometry (for games, you only need to know just enough as formulas to get by) something like: ball.x+=cos(ball.angle)*ball.speed ball.y+=sin(ball.angle)*ball.speed

Your code works, which is good. It's very different from how I would have coded it; there are, however, different code styles - I have three similar Pico-8 games all coded in very different styles.

Here are a few of the things (mostly small) I would have coded differently:

if flr(rnd(2)) == 1

could also be: if rnd()<0.5 then

xdir = xdir - (xdir * 2) -- return the ball

could also be: xdir*=-1

flr(rnd(3)) - 1

could also be: rnd({-1,0,1})

or: rnd(3)\1-1

And I suspect the code of the functions of the two paddles has enough shared that they could have both redirected to an update function and a draw function outside of the objects themselves.

Stylistic differences - you code your way, I code mine.

Note: the code I've written in this post has not been run. I get it right (eventually ;p) when I type it in pico-8, but it may have mistakes when I type it on the bbs.

I hope some of this is along the lines of the desired feedback. :)


By the way, it's possible to upload a cartridge to the bulletin board system in a way that makes it playable, rather than just an image. The option should be there to upload it as a cartridge while you're editing/writing your post.

P#77433 2020-05-30 17:42 ( Edited 2020-05-30 21:30)
1

For further feedback, here is a Pong paddle program outline demonstrating objects and inheritance in Pico-8/Lua; I've kept many aspects close to your original code. Click on code under the cartridge to see the code and comments.

Cart #remcode_oo_pong_outline-0 | 2020-06-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

For any relatively new programmers:

What I've programmed shows a little more code reuse through shared functions, either as part of objects further up the object hierarchy (example: the draw function of object), or just through a function call (example: the function setplayerpaddle). This should not be seen as a definitive model - some of it (for example: protopaddle) is probably my own preference, and other ways exist to get to the end result.

See also: https://www.lua.org/pil/16.2.html

P#77478 2020-06-01 07:46 ( Edited 2020-06-01 11:25)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 13:01:33 | 0.009s | Q:14