Tuesday 26 November 2013

Birds fly home to spawn

Just a small update here (Version 1.8, available by clicking the Source Files link top right).
I wanted the birds to spawn properly in their correct places, so I added a little routine for this. The birds Update method is getting a little messy. It might be time to start breaking it into smaller subroutines.

I also wanted to see what happens if you get loads of enemies, so I added a spawner routine which creates birds every few seconds. My old laptop can handle lots of birds, it seems.

Also, it turns out I'm quite pleased with the current flight pattern of the enemies. They seem to spread themselves around the screen quite nicely, so I'm not going to bother with the different flight algorithm for now.

Friday 22 November 2013

Joust: Improved platforms, our first enemy

It has been a busy month at work. Lots of evening working and stressful times. However, there's always time for tinkering, and I have turned my attention to the enemies in Joust.

I started by just cloning the player character class. It takes care of itself pretty well, bouncing off walls, automatically walking etc. The enemies need to do pretty much the same stuff. The only difference is that they need to control themselves. This boils down to deciding when to flap their wings, and when to accelerate.

The initial birds in Joust seem to be pretty dumb. They just fly in one direction, right-to-left or left-to-right , occasionally bouncing off things. I started doing this by simply adding a random chance to their flap. Each cycle of the game it would roll a dice and see if the bird flapped. A bit of trial and error gave a value of about 20% chance of flapping. This sort of random flapping is what you see in the video below.



This actually tended to make them fly upwards so that they clustered at the top of the screen, so I tweaked it lower. Ideally, some of the enemies would fly along the top of the screen, and some would choose the lower tier of the screen. There should be a random element to it, but they should have a "target altitude". The further below the target altitude they are, the more likely it should be that they flap. Sometimes they will drop a fair way below. Sometimes they will go above their target, but they will work it out in the end.

Later enemies are smarter, and have a strategy for killing the player. They will suddenly fly upwards as they approach you. That will be fun. For now I have to make this guy follow the rules, then get some sort of "spawning" animation going.

Incidentally, I'm enjoying using Wingware IDE as an alternative programming environment from Python IDLE. If you're taking Computing at WGHS or QEGS, I can give you a free pro licence. Drop me an email.


Monday 4 November 2013

Joust continued: Platforms

The source files folder now contains version 1.3 of the Joust game.

I made a few changes to the eel of the flying motion. Previously, the character would slow down when you let go of the control stick. it would do this on the ground and also in the air. More playing of the original version made me realise that the character doesn't slow down when you let go. Momentum carries it onwards, which makes it a bit easier to program. (Before, I had different "friction" settings for the flying and walking movements)

The new version has all the platforms of the original, in roughly the same positions. It also has sounds (you will need to download all the wav files from the folder for this to work)

I had to hard-code some special bits to handle the occasions where the player is walking on the platforms which span the edges of the screen. They're supposed to be the same platform, but I have them stored as two separate halves. The player character was falling down between the two platforms, so I added some lines to check the player's x and y coordinates to see if it's crossing a platform and act accordingly.

The player can still fly vertically up through a platform. That's next. Then we need enemies.