Simple Breakout! clone

Started by
3 comments, last by ??????????????? 12 years, 8 months ago
Hey guys, my first post here!

I'm not much for introductions, so let me just say that I'm new to programming (less than 2 months of experience) and just started learning PyGame a week ago, so be gentle.

I tried to get into programming around a year ago, but got sidetracked by life stuff and dropped it up till two weeks ago, approximately. Last year I started with C#, didn't really like it, moved on to Python, then found Ruby and fell in love with it. The most complicated program I had made before the one I'm going to show you is a failed attempt at a console Blackjack app, around 200 LOC in Ruby.

Now this time around I said to myself I'm going to be learning C++ (bad idea). I got right around Chapter 4 of "Accelerated C++ Practical Programming by Example" and decided it's waaaay to complicated for me atm. So I decided to take one more look at Python. And, of course, as things work out, I fell in love with yet another language :)

Things are just so damn easy. It took me exactly one day to translate my knowledge from Ruby to Python. On the next day I finished my Blackjack app and was thinking about more complicated projects. I did the necessary unbeatable Tic-Tac-Toe AI :P, and some other small projects. Then one day, bored out of my mind (no internet connection for 20 miles), I was browsing the Python folders, and found one called PyGame. "Hey, I've heard that", I thought, and quickly opened the examples folder. WOW! Graphics. Games! Holy shit!

I quickly found the manual and browsed the tutorials. I even typed the simple ball program from the first tutorial. And this is where things went stale. I couldn't do anything. I couldn't make the ball move, nothing. I just tried to do something I didn't understand way too fast. I left it for about a week and then got back to it, this time with more boredom to accompany me. I was determined to make that ball move by user input, and I finally did it, YAY! From then on, it was just a matter of thinking what I want to do, checking the manual, and actually doing it.

Soon after that I started working on a simple Breakout! clone. Things were going somewhat well, and now I've got a ready to play "game". It's still pretty rudimentary, but I'd really appreciate your input.

There is one major bug in the game, though. Collision detection, as I've implemented it, sucks. If the ball comes from the side of the blocks, it just plows through everything. It was worse in the beginning, but it's still bad now. Any ideas on how to fix that would be greatly appreciated.

I would also appreciate any comments on coding style and such. The program, at the moment, is a mess, with functional and OO programming mixed together and globals used left and right (I know, yuck!). I just didn't expect the program would become so big. Plus it's my first PyGame project.

Anyhow, here is the complete program:
http://www.2shared.com/file/A2thIBC4/breakout.html
Advertisement

Hey guys, my first post here!

I'm not much for introductions, so let me just say that I'm new to programming (less than 2 months of experience) and just started learning PyGame a week ago, so be gentle.

I tried to get into programming around a year ago, but got sidetracked by life stuff and dropped it up till two weeks ago, approximately. Last year I started with C#, didn't really like it, moved on to Python, then found Ruby and fell in love with it. The most complicated program I had made before the one I'm going to show you is a failed attempt at a console Blackjack app, around 200 LOC in Ruby.

Now this time around I said to myself I'm going to be learning C++ (bad idea). I got right around Chapter 4 of "Accelerated C++ Practical Programming by Example" and decided it's waaaay to complicated for me atm. So I decided to take one more look at Python. And, of course, as things work out, I fell in love with yet another language :)

Things are just so damn easy. It took me exactly one day to translate my knowledge from Ruby to Python. On the next day I finished my Blackjack app and was thinking about more complicated projects. I did the necessary unbeatable Tic-Tac-Toe AI :P, and some other small projects. Then one day, bored out of my mind (no internet connection for 20 miles), I was browsing the Python folders, and found one called PyGame. "Hey, I've heard that", I thought, and quickly opened the examples folder. WOW! Graphics. Games! Holy shit!

I quickly found the manual and browsed the tutorials. I even typed the simple ball program from the first tutorial. And this is where things went stale. I couldn't do anything. I couldn't make the ball move, nothing. I just tried to do something I didn't understand way too fast. I left it for about a week and then got back to it, this time with more boredom to accompany me. I was determined to make that ball move by user input, and I finally did it, YAY! From then on, it was just a matter of thinking what I want to do, checking the manual, and actually doing it.

Soon after that I started working on a simple Breakout! clone. Things were going somewhat well, and now I've got a ready to play "game". It's still pretty rudimentary, but I'd really appreciate your input.

There is one major bug in the game, though. Collision detection, as I've implemented it, sucks. If the ball comes from the side of the blocks, it just plows through everything. It was worse in the beginning, but it's still bad now. Any ideas on how to fix that would be greatly appreciated.

I would also appreciate any comments on coding style and such. The program, at the moment, is a mess, with functional and OO programming mixed together and globals used left and right (I know, yuck!). I just didn't expect the program would become so big. Plus it's my first PyGame project.

Anyhow, here is the complete program:
http://www.2shared.c...4/breakout.html


Welcome,

You can take a look at this thread to see my earlier attempt to explain how I implemented my breakout collisions.
Or you can take a look at the entire source at sourceforge.

Ohh, and grats with Python =)
That post looks really sweet and in depth. I will definitely be getting back to it when I learn more about the geometry used in it.

Unfortunately, as often happens with beginners, I've found yet a new technology that has captivated my imagination, called Unity. It looks really sweet and I've seen some pretty nice games made with it (I was looking mostly at the 2D titles, 3D is out of my reach as a single developer I think).

I would like your opinion on that, guys. Do you think Unity is good for a beginner programmer / game developer like me? I really like it because it supports scripting languages like JS and Boo (python dialect with ruby mixed in where applicable, really sweet). It does take a lot of the hard but tedious stuff out of your way and lets you prototype a game relatively fast.

I don't plan on ever working for some big game studio, so I might not even need to learn C++ for a long time, if I can get away with it with Unity. My idea is to make a nice 2D game which doesn't really require any fast computation and so on, and UnityScripts are compiled either way, so it's not like it will be the slowest thing in the world.

Cheers!

That post looks really sweet and in depth. I will definitely be getting back to it when I learn more about the geometry used in it.

Unfortunately, as often happens with beginners, I've found yet a new technology that has captivated my imagination, called Unity. It looks really sweet and I've seen some pretty nice games made with it (I was looking mostly at the 2D titles, 3D is out of my reach as a single developer I think).

I would like your opinion on that, guys. Do you think Unity is good for a beginner programmer / game developer like me? I really like it because it supports scripting languages like JS and Boo (python dialect with ruby mixed in where applicable, really sweet). It does take a lot of the hard but tedious stuff out of your way and lets you prototype a game relatively fast.

I don't plan on ever working for some big game studio, so I might not even need to learn C++ for a long time, if I can get away with it with Unity. My idea is to make a nice 2D game which doesn't really require any fast computation and so on, and UnityScripts are compiled either way, so it's not like it will be the slowest thing in the world.

Cheers!


Unity is fine for beginners. What's far more important is that you slow down and fully explore some of these technologies. It's not enough to look at the top layer of a language/engine and then move on to the next greatest thing if you never actually learn anything about any of them. You're fully avoiding doing any of the hard stuff; learning more than just syntax.

It doesn't matter what language you use, what matters is finishing projects.

[quote name='_dogmeat' timestamp='1314267390' post='4853580']
That post looks really sweet and in depth. I will definitely be getting back to it when I learn more about the geometry used in it.

Unfortunately, as often happens with beginners, I've found yet a new technology that has captivated my imagination, called Unity. It looks really sweet and I've seen some pretty nice games made with it (I was looking mostly at the 2D titles, 3D is out of my reach as a single developer I think).

I would like your opinion on that, guys. Do you think Unity is good for a beginner programmer / game developer like me? I really like it because it supports scripting languages like JS and Boo (python dialect with ruby mixed in where applicable, really sweet). It does take a lot of the hard but tedious stuff out of your way and lets you prototype a game relatively fast.

I don't plan on ever working for some big game studio, so I might not even need to learn C++ for a long time, if I can get away with it with Unity. My idea is to make a nice 2D game which doesn't really require any fast computation and so on, and UnityScripts are compiled either way, so it's not like it will be the slowest thing in the world.

Cheers!


Unity is fine for beginners. What's far more important is that you slow down and fully explore some of these technologies. It's not enough to look at the top layer of a language/engine and then move on to the next greatest thing if you never actually learn anything about any of them. You're fully avoiding doing any of the hard stuff; learning more than just syntax.

It doesn't matter what language you use, what matters is finishing projects.
[/quote]

Yeah you're totally right about that! I just feel that learning PyGame when there are things like Unity would be a waste of time. Okay, maybe not a waste of time, but I'd be better off learning to develop games with Unity, IMO.

I still have this feeling that it's not really going to make me a decent programmer or something like that. I feel like it's abstracting away a lot of the hard stuff that needs to be done (which is good, usually) repeatedly. I mean, everyone can mock up a simple web page in DreamWeaver, but not everyone can tell you why each element is there and what exactly it's doing. Now, in web "programming", that might not be the case, since HTML is a markup language and it's hard to fuck up things bad. But not so much when we talk about games. There are a lot of stuff that can go wrong, and with just a knowledge for the tool and not the technology, people using something like Unity might be left stranded when something more complex happens.

Hope that is not the case though.

Also, I feel I've learned like 80% of what there is to learn about PyGame, and could implement almost anything, given enough time and interest. I've done the hardest parts of almost all of the classical arcade games, and most of the projects just need some cosmetic fixes and minor bug fixes.

I haven't gotten around to implementing full fledged physics yet, though. But I think that's too advanced for a beginner like me anyways.

But, I mean, there are commercial games made entirely in Unity, right. And it's not that hard to learn to use it to make something cool. In comparison, even the simplest things in PyGame were a lot of work (which, when I look at it in retrospect, I love, since it taught me so many things), which would be just wasted time when developing a game. It's cool to learn something in depth the first time you encounter it, but that doesn't mean I need to re-implement a circular motion device with a center axis just to use a simple wheel in my game.

That said, I will definitely try and stick with Unity for at least a couple of months (hopefully much more). That way, I can get to the meatier problems and not just double in the beginner sections.

Cheers!

This topic is closed to new replies.

Advertisement