Have you ever been surprised by someone who bought you something completely unexpected? Something which they would not normally get for you as it's uncharacteristic of them?
Well during my recent birthday I got a note through the door whilst I was out from the Royal Mail saying that they had tried to deliver a package but of course no-one was home. So later that day I headed down to the delivery office and picked it up and one top of the items in the box was an Amazon note and a message from my Dad wishing me a happy birthday. Now in the box was one book which really took me by surprise, he'd gone and bought me "Beginning Game Development with Python and PyGame"! To say I was bowled over would be an understatement.
My dad was the person who initially got me into programming, he insisted when I got my first computer that I learn to use it properly and it not be used only for gaming. Whilst I'm sure he meant that I should learn how to write documents and edit graphics with it instead of hacking around with code he encouraged me to continue anyway, but never actually as far as buying me a programming book so this is a first. I know he bought it from my Amazon Wish List but there were other books on there along with music and DVD's so the fact he bought this one is incredible. I'm fairly sure he's not following this blog either as usually just turning a computer on is enough to get him fed up with using them so the idea he spends time browsing the web and reading a blog of mine dedicated to programming is slightly more than unlikely.
But anyway I thought I'd mention as the book is likely to drive some further posts to here and I'll write up a review on the book when I get somewhere useful with it.
Showing posts with label PyGame. Show all posts
Showing posts with label PyGame. Show all posts
Sunday, 1 February 2009
Sunday, 12 October 2008
Still ongoing...
Well having recently had a holiday and having made some time to do some odd jobs around the place my pace of development has dropped. I've had some time to look around at a few books for C++ and have downloaded a copy of "How to Think Like a Computer Scientist". I think for the time being I'll be looking through this until I can purchase a book of my choosing, for some reason I still like books in dead tree format although as soon as devices like the BeBook become more affordable I may consider getting one of them instead.
Currently I'm looking at getting a Sam's teach yourself in one hour a day book but I've never used one of their books before normally preferring instead to go for something from O'Reilly or Apress. It's quite amazing how we can grow accustomed to and even develop a preference for a particular publisher.
In the mean time I've just received my next copy of Linux Format and there is another PyGame tutorial in there so I'll probably dive into that at some point in the very near future.
Currently I'm looking at getting a Sam's teach yourself in one hour a day book but I've never used one of their books before normally preferring instead to go for something from O'Reilly or Apress. It's quite amazing how we can grow accustomed to and even develop a preference for a particular publisher.
In the mean time I've just received my next copy of Linux Format and there is another PyGame tutorial in there so I'll probably dive into that at some point in the very near future.
Sunday, 31 August 2008
Now with text
Okay so I've not had a lot of time to make much progress this week but I did manage to spend a few minutes on my space invaders game. Looking back through previous issues of Linux Format - as suggested by someone on their forums - I came across a flash card tutorial which used PyGame as well. The bulk of the game was text based so there was a bit which explained about rendering and displaying text on the game window, porting this into my game was quite trivial and so now I have a life and score counter.
The thing to learn from this though is that it is always worth hanging onto those back issues, even though some of the stuff is now out of date there is still a wealth of knowledge buried in those pages.
The thing to learn from this though is that it is always worth hanging onto those back issues, even though some of the stuff is now out of date there is still a wealth of knowledge buried in those pages.
Sunday, 24 August 2008
Game update
Been hacking around with the code from Linux Format and added in a few features. So we've now got a configurable alien setup where you can define the number of rows and the number of aliens in each row. I've set up a missile count so we start out at the number of rows plus 1, it also now removes a missile for each row you take out and checks to see if there are more missiles than aliens and removes them so there is always one less missile than there are aliens, until you get to one alien then obviously we keep that final missile in play.
The speeds and drops are now configurable and we've still got missile collision detection and a configurable number of lives. Still got a few more things I can do with it, and when I've done those I'll probably be able to think of a few more but this is a great project for cutting my teeth with Python.

The speeds and drops are now configurable and we've still got missile collision detection and a configurable number of lives. Still got a few more things I can do with it, and when I've done those I'll probably be able to think of a few more but this is a great project for cutting my teeth with Python.

Saturday, 23 August 2008
Sods Law
As is normally the case, I finally settle down into doing something and I end up getting ill! Fortunately though I was starting to feel a bit better this morning and was inspired by the latest copy of Linux Format which turned up through my letterbox earlier this week.
One of the things I tend to do is flip straight to the back to see what kind of tutorials they're running and found to my delight one on Python game programming using PyGame, so I set about following the tutorial to see what I could do.
I could have easily skipped half the work at the first stage as LXF very kindly included the art-work from the tutorial on the cover disk but I figured I wanted to create my own, firstly so that the game felt more personal but also because the aliens look like a cross-dressing pac-man throwing kitchen funnels at the poor hero (if you're reading this Mike, it's this charm which makes them scary). I'm sure mine aren't that much better but like I said it makes the game feel more personal.
The code for the game is quite straight forward for a few reasons, firstly there is only one row of aliens, secondly the only collision detection is between the missiles and the hero/enemy and finally there is no on-screen text. So if you get hit it's game over and when you've killed them all it's game over. The only snag I hit was in setting the transparency for the graphics, the ones provided by LXF were probably already in the correct format whereas mine are not. Fortunately the PyGame surface class has a function called convert which sorts this out, so changing the line of code from:
self.bitmap = image.load(filename)
self.bitmap.set_colorkey((0, 0, 0))
to
self.bitmap = image.load(filename).convert()
self.bitmap.set_colorkey((0, 0, 0))
I suddenly ended up with transparent graphics.

Since then I've gone on and added in missile collision detection so I can blast their missiles out of the sky and I've added sprite collision detection, so if the aliens get to the bottom of the screen and they hit me it's game over. I also added lives into the game so I get three chances to lose now.
I'm possibly going to stick with this game for a few days now and add things like information to the display, more aliens and I might try and see if I can get it to become progressively more difficult. This is why I like game tutorials, they really get the imagination going.
One of the things I tend to do is flip straight to the back to see what kind of tutorials they're running and found to my delight one on Python game programming using PyGame, so I set about following the tutorial to see what I could do.
I could have easily skipped half the work at the first stage as LXF very kindly included the art-work from the tutorial on the cover disk but I figured I wanted to create my own, firstly so that the game felt more personal but also because the aliens look like a cross-dressing pac-man throwing kitchen funnels at the poor hero (if you're reading this Mike, it's this charm which makes them scary). I'm sure mine aren't that much better but like I said it makes the game feel more personal.
The code for the game is quite straight forward for a few reasons, firstly there is only one row of aliens, secondly the only collision detection is between the missiles and the hero/enemy and finally there is no on-screen text. So if you get hit it's game over and when you've killed them all it's game over. The only snag I hit was in setting the transparency for the graphics, the ones provided by LXF were probably already in the correct format whereas mine are not. Fortunately the PyGame surface class has a function called convert which sorts this out, so changing the line of code from:
self.bitmap = image.load(filename)
self.bitmap.set_colorkey((0, 0, 0))
to
self.bitmap = image.load(filename).convert()
self.bitmap.set_colorkey((0, 0, 0))
I suddenly ended up with transparent graphics.

Since then I've gone on and added in missile collision detection so I can blast their missiles out of the sky and I've added sprite collision detection, so if the aliens get to the bottom of the screen and they hit me it's game over. I also added lives into the game so I get three chances to lose now.
I'm possibly going to stick with this game for a few days now and add things like information to the display, more aliens and I might try and see if I can get it to become progressively more difficult. This is why I like game tutorials, they really get the imagination going.
Subscribe to:
Posts (Atom)