Friday, March 23, 2007

Dribbling

Things have been going in a certain way that immediately brings such non-words as "poocrapular" to mind. The last three weeks have been focused on getting some people playing football, and this has revolved around several areas of frustration.

The first is the fact that I can't have little people playing football until I have little people. I'm not a terrible artist but nor am I particularly adept with the human form, so after much frustration I finally got this lot done.

As you can see, they aren't the best looking animation frames in the world. For a start, they're far too exaggerated so I've got some freakish loon waving his arms all over the place when he so much as attempts a light jog. And I'm pretty sure he'd actually break his legs if he ever tried to run with that. But still, they're functional so it gives me something half decent to work from.

Once I got the little chaps done, my next task was to get him running about. I've created a rather simplistic animation system, which I'll no doubt build upon as I go along (the same can also be said for the tilemap system, which will be updated with animation and transparency features as time goes on). I did a little bit of research and found that professional runners tend to run at about 180 steps per minute, essentially meaning three steps per second. So each frame lasts for a ninth of a second, and this was pretty easy to do. The game's physics engine (rudimentary though it may be) already had code to ensure it updates every 60th of a second, so the same code was used in the animation system to keep things ticking along.

A running man, and not an Austrian in sight. Now what he needs is a football, and the ability to run with it.

I've played a fair amount of football games in my time, and having recently upgraded my PSP to a PS1-emulation supporting firmware, I indulged in yet more online spending to grab myself another six. Across all the games, it seems that the representation of dribbling ability falls into one of four camps.

  1. The ball sticks to the player's feet. All the time. In other words, I can't actually see what the difference is between a good dribbler and a bad dribbler. Sample games: Actua Soccer, FIFA 98, Viva Football
  2. The ball sticks to the player's feet for a period of time. During this period the player has full control over movement, however when the time elapses he can no longer change the ball's direction. Thus, a better dribbler can keep control for longer. Sample game: Sensible World of Soccer
  3. The ball sticks to the player's feet, but he moves much slower than his normal running rate. The better his dribbling ability, the faster he can move whilst maintaining this level of control. Sample game: New Star Soccer 3
  4. The player nudges the ball along as he moves, just as you would in real life. The player can therefore only change direction when he's close enough to the ball to alter its direction accordingly. Better dribblers don't knock the ball as far as the poorer ones. Sample games: FIFA 07, Kick Off, Pro Evolution Soccer 6
I've never seen anything different. Seeing as this game is supposed put a lot of weight on the player's abilities, the first one can't be considered. A shame, as it's by far the easiest to actually do, but frankly I'm not sure I'd want a game where something as vital as a dribbling ability is entirely irrelevant. The second system, used by the official Best Football Game Of All Time as voted by me, just now, places a large importance on ability but at the expense of realism - I dunno about you, but when I run the length of a pitch I'm still able to change direction and take the ball with me.

The last two have their good and bad points, and it's hard to split them. It can be argued that they're both differing implementations of the same basic idea - where Pro Evolution Soccer's players knock the ball further so that they don't trip over their own feet, NSS3's little guys just take their time to achieve the same thing. Of course, if you delve deeper into Pro Evo's control system you'll find that you can slow yourself right down and maintain tighter control of the ball, while with NSS3 you can nudge the ball out from under your own feet to run at a quicker pace.

For now, I've gone with the fourth system. In addition to being a fairly fine representation of how dribbling is, it also plays a part in goalkeeping - my own position in the field. When an opponent is bearing down on your goal and you feel like rushing off your line to smother at his feet, you need to time your advance with his own dribbling. When he nudges the ball further still, you need to be quick off the blocks to close down the angle before he can do anything else. This also applies to defenders, who will be looking to nick the ball away from a player when it's vulnerable. When the ball is stuck to a dribbler's foot, you lose these facets of the game.

Whether or not this lasts depends on how it holds up in gameplay. There's no swanky 3D engine to get a closer look, and the players are sprite based which greatly limits the animations available. Yesterday I finally got a player to run with the ball in a manner that satisfies me, but until opposition stand in the way it'll be impossible to know for sure. One irksome problem is the game's perspective - when you're running towards the goal at the top of the screen, the ball is often obscured by your player. If you can't see the ball too well, how will it affect gameplay?

Friday, March 02, 2007

Deceptive

The central midfielder picks the ball up just inside his own half. He rolls a simple ball out to the wing where it's picked up and dribbled, unchallenged, towards the corner flag. Cutting onto his left foot, the winger lays the ball off to the unmarked and now arriving central midfielder who meets the ball beautifully and deftly slots it home through the obvious gap. All so simple.

It's not fucking simple! It's fucking terrifying! There's nothing fucking simple about getting any of that to work, not without tearing huge chunks of your own brain out and devouring them in the process in the hope that you might get taken away and never have to do any of this cunting shite ever again!

As you can tell, I'm not particularly happy at the moment. The little things that, when you're out on the pitch playing with even the more clueless folk out there, are so easy to do, become cunting tough whenever you actually need to put it into code. Let's take an example - there's a ball rolling in a direction, and you want it. So what do you do? You take note of where it's going and you get in the way of it. Easy.

I spent the best part of a week trying to come up with the quickest possible way of getting my tiny little blobs to do that. I have pages and pages of worthless trigonometry, now. Worthless because those theories never panned out. Maybe I never coded them correctly, maybe they were wrong in the first place, none of that matters because it's a heck of a lot of wasted time - in thirty minutes I coded in what was initially a temporary fix that actually does a better job than any of my mathematical tricknickery.

With that done, I turned my head to the rest of the physics. Balls should bounce off players, right? This would be easy if it wasn't for two things - first, I can't rely on the actual graphics engine for collision detection because I want the game to be able to process more than just the match you're viewing. The second irritance is that I never know what the hell a player is doing. Is he running? Where are his arms?

"Where are my arms" is a question I may well have found myself asking random people if this had frustrated me any more, as I can think of little more immediately satisfying than blowing away the object of your anger whilst cackling like a 1920's Chicago mob boss. I would even have bought a cigar for the occasion, it would be that important.

But it never came to that. I decided that as much fun as playing with little circles is, there's no real match for getting proper visual feedback. Instead of working with an abstract engine and Football Manager style blobs on a single-screen, overhead pitch before introducing the snazzier display, I've decided to go the other way. A pitch, a ball, a man (although I'm not fussy, so as long as it's bipedal I couldn't give a shit), and they'll fucking stay there until they've worked out how they're supposed to interact. Actually, I did get the ball interacting with the pitch correctly, but with an overhead view it's harder to see the bounce.

So, over the last two days I've created a basic tiling system for the game. Tiling, if you don't already know, is simply the way the background graphics of the game get built - the pitch consists of several tiles which are laid together, and that's about it. In order to do this I knocked together a half-decent TileMap editor, and I made sure the drawing code could cope with flipping the tiles on the horizontal and vertical axes, to save me having to have four versions of similar tiles. It all seems to be working well, and about a half hour ago I managed to have a scrolling football pitch. Couldn't even get jumpers for goalposts though, I'm very poor.

I've set myself a little personal goal for the end of March. If I can get something that resembles a playable football match done, I'm going to treat myself. As I have no money, it will have to be something small.

And with Sensible World of Soccer on the way for the Xbox 360, I think I also need to have a major goal for around June 2007, get that done, and treat myself to one of those.