A simple ball game

Hey guys!

I recently came back to Codea when I noticed it was released for iPhone. To get back into it I made a simple ball game. Most of the time I spent making classes (Buttons, Highscore, Prompt) that are reusable for other projects. I made those halfway through the project and didn’t brother to change the code once I had access to my new Button class, so the code is messier than it should be.

The game is designed for iPhone, but should work on iPad as well. It should be played in portrait mode.

Every time I start a new project I think “This time I’ll get into the habit of commenting my code”, but sadly I never do!

The code is too long for a post, and I got an eror message trying to export it as a zip file (I’ll report that bug later), so I copied the code into a txt file. Hope that’s ok!

@Bastis Nice game. I didn’t get to play it very long, but it look interesting. I’ll play it more later. The txt file worked just fine. It ran OK on my ipad.

@Bastis I managed to get a score of 24. The ball and paddle were just a little bigger than dots. It’s a very interesting and challenging game. One thing I had to modify was the paddle movement. It wasn’t moving in sync with my finger. Depending on the value, it either moved faster or slower than my finger. Once I had the correct value, it was a little easier to play.

Glad you liked it @dave1707 !
Once I’ve managed to get 27, otherwise 24 has been my best as well.

I’m thinking about letting the paddle get higher and higher up for each hit after the ball is small enough, but for now I’ve never managed to get enough bounces for the ball to get to minimal size. Might make the minimal ball and paddle size bigger so it’s possible to get far enough to raise the paddle.

@Bastis - neat game, a complete package. You’ll probably start tickling bits and pieces to smooth out the rough edges. I added a background to the game. Don’t drop into the bad habit of not commenting, as a lazy programmer myself, I am constantly re-inventing my old code as I didn’t comment it when I wrote it.

Ideas- objects to deflect the ball on the game screen, sprite for the name entry in high score table. Bigger (thicker) bat - easier to see.

@Bastis One other thing, can you describe the steps you took to create the txt file here just in case others might want to do it.

@Bri_G Thanks! I might add a background and increase the bat height. I will probably move on to something else though, since I do this to improve my programming skills. Easier to try to keep the code nice and clean and commented when starting fresh.

@dave1707 To create the txt file I used the app GoodReader. Just copied the code via the export function in Codea and created a new txt file in GoodReader, then exporten it to iCloud so I could upload it here. I’m sure there are alot of other apps and websites that let’s you create a txt file.

@Bastis that’s a really polished game, you even did all the bits most people usually skip like menus and high scores!

@Simeon Thank you! I feel that using menus makes the approach to writing the game part a bit different and teaches me more about how it is to make a “real” game.