Gun Bastard
Playing pool
I've noticed the frame rate on Gun Bastard has a tendency to plummet when things get a bit splodey, so I should probably start looking at optimising the code a little before I go any further.
Since the explosions are the most obvious source of slowdown, at least some of the problem is likely down to object creation overhead on the various particles I'm chucking about the screen.
In order to minimise the overhead, I thought I should investigate object pooling.
The bastards have landed
Spent a bit more time playing around with Gun Bastard this weekend, so here's a quick WIP build for you to play with.
Needs a lot of work on balancing and generally making things fun, but it's just about playable.
Reasons to love Python
It let's you do twisted things like this:
waves = [[Clown, Clown, Clown], [Clown, Tank, Bunny, Clown], [Clown, Tank, Tank, Clown], [Clown, Tank, Tank, Bunny], [Tank, Tank, Tank, Clown], ... ]
where Clown, Tank and Bunny are the Types of the various enemies
and later...
for enemy in waves[wave]: enemy(xpos, ypos, 0, 0, self.target)
and it just figures it out and calls the constructor for the relevant type.
The bastard in motion
I knocked up a quick gameplay video of Gun Bastard - it's not looking too shabby.
Back to the bastard
With Sheep Snaggers finally out the door, and after recovering from a nasty toothache that turned into a whacking great abscess - leaving me spending the week on the couch cold a feverish with foul tasting poison dripping into my mouth - I finally got back to work on GUN BASTARD today.
After a bit of a slow start where I fumbled around with a couple of things that weren't working right* I've managed to get a bit more done.
Oh behave!
I spent the last couple of days reading over the Owyl docs, and I've managed to implement some basic AI in Gun Bastard.
I've got two different follow behaviours for the bad guys, a "shoot object x if you can see it", and I've farmed the player controls out to joystick move and fire behaviours rather than them being in the game loop.
New game - GUN BASTARD
With Sheep Snaggers pretty much finished, I've been thinking about how I could have improved the structure of the code. As it stands, it's a pretty horrendous spaghetti mess - I hacked features on pretty much at random, and it shows.
I've come up with a much better design, where the main game loop nice and simple
while running: think() #handles control input and AI update() # move things around render() # draws the end result
and the different game modules each have their own versions of the 3 functions. When I switch game modes, I swap out the function pointers for the relevant module and everything stays inside the one loop, which makes handling game events much cleaner.
In Sheep Snaggers, the attract mode and high score entry each have their own seperate copy of the game loop, which then has to throw events back to the main loop - hideous I know, but that's what happens when you don't plan ahead...
Anyway, to test the new structure out, I needed a nice simple game concept.
Enter GUN BASTARD.