Friday, June 02, 2006

Hyperplanes, Normals & Vectors

Lot's of work over this week including a major overhaul of the waypoints system which was far from ideal. Previously the vehicles aimed for specific points on the track, a distance check was then used to decide whether the car had reached the waypoint - this resulted in a circular detection area.

The major drawbacks of this approach are that if you drive off the track you can completly miss a waypoint without realising and the lap wont be counted, ai cars all aim for the same point which results in them driving in a line on the same route and the start finish line is actually a circle! The solution has been to replace points with lines, the ai can then pick different points on the line to aim for resulting in a more unpredictable race. It is also possible to find if a waypoint has been passed by calculating the normal of the line and projecting the distance from the car to the line onto that - if the number is below zero then the line has been passed. For this Metanet has been a great help as always! The other great thing about this method is that the line never has to be phyisically touched as it is calculated as if the line continutes into infinity in both directions...

I have also integrated waypoint editing / saving / loading into the track editor. The ends of lines can be dragged to move the waypoint and the red arrow signifies direction. (The track is displayed half size in the editor)

I think once the AI cars are more aware of the other vehicles around them this will provide a really good level of challange, at the moment they like to cross each others paths too often, which results in cars scraping along next to each other...

Friday, April 28, 2006


Hey all,

After two months with no update from me and Jon i thought it worth posting what has been going on. I would love to say that we've both been working on the game so hard there has simply been no time.. however, this is not the case!

We have both been busy with other commitments, at my end this has been coursework and exams which will be ongoing for a few more weeks yet. After that i start a new job, which for the project is actually a good thing as i will have time in the evenings to work on the game instead of coursework and revision.

Hopefully, the next post will be sooner rather than later!


Wednesday, February 22, 2006

Through the keyhole

What kind of person would code in a place like this? A little insight into our work holes, where we spend hours perfecting blog posts like this for you guys and then a couple of minutes on the game ;-)


Monday, February 06, 2006

Solid Geometry


Since the demo i have been working hard on ironing out the little issues we had left and adding some new 3D features into the engine.

I thought i would write my first indepth post on the technology behind the game, and explain how we are achieving 3d objects while maintaining (hopefully!) high frame rates. I am using a technique that was explained to me by kirill mourzenko several years ago, and i used a less advanced version in my earlier (unfinished) game Felony (on which Jon helped with the physics, and is actually how we hooked up for this game!)

Faking It

The 3d objects in Flash Racer are faked through a combination of clever scaling, animation and paralax scrolling. Firstly, for each object the distance is found between it and the center of the screen. For buildings, this distance is then used to offset the roof by an amount depending on the buildings height. So, as the building moves further from the center of the screen the roof becomes more offset, this creates the impression of perspective.

See how the building to the left appears to be leaning more? Of course for taller buildings this effect is even more dramatically increased. The roof of the building is also scaled up according to its height as objects closer to the camera should appear bigger!

The walls are wedge shaped images that are simply scaled to fit between the base of the building and the side of the roof, at the moment this calculation is performed every frame in the Camera Class, however this could be reduced for lower spec machines and i am looking into making this one of the many graphics options we are likly to include!

The final piece of the puzzle is to skew the wall image so that it fits when the roof is no longer above the building base. This is predone animation, with one keyframe for every single pixel of movement (81 keyframes in total), this is a very efficient way of achieveing the right look.

On a side note, i have noticed that you can now dynamically skew images in flash 8, this would have been ideal for this, however we are currently coding for flash player 6 in AS1 so it would be unreasonable to code only one feature in the brand new flash player! Maybe in a future version?

Pseudo Speed

These tall objects are great, because they add that extra level of depth to the game and just as importantly - because they are closer to the camera, they move faster and dramatically increase the feel of speed when racing! All we need now is a little blurring...

Any questions? Just leave a comment! Extra points if you can work out the cryptic title ;-)

Monday, January 23, 2006

Tech Demo Release! (Finally..)

At last, the first major milestone in this mammoth project has been reached, we've kept you hanging since well before Christmas for a working demo, but now is the time! Me and Jon have been laboring all weekend over the last of our goals for this tech demo in order to get it into the wild today...

Current Features
- Different surfaces affect handling
- All game data loaded from external XML files
- Accurate collision detection
- AI with up to 6 cars on track
- HUD including lap times / lap counter and race positions
- Dynamic camera, that can swap between racers

Future Features
- More tracks
- Larger tracks
- Accurate collision response
- Solid & Tire Walls
- 3D Structures
- More advanced AI with more varied racing lines
- Career mode, saving of all race data / lap times etc
- Graphics options for slower computers
- Cheats
- Sound

Known Issues
- You can drive off the map
- Collision response not finished

We Need You

What we would love it some feedback on the engine so far, your opinions on every aspect of the game and how it can be improved in future revisions. Some information that would be nice when you comment:
  • CPU speed
  • Flash player version
  • frames per second ( top-right corner ) - min/max/average would be great!

Enough Babble, I Want To Play!

You can play the flashracer tech demo using the following controls...

UP arrow - Accelerate
DOWN arrow - Brake
LEFT and RIGHT arrows - Steering
SPACE bar - Handbrake
1 - 4 numbers - Change camera view to other cars

The Sexy Temporary Graphics

(Jon getting beats by the computer)


Enjoy the demo, let us know what you think in the comments for this post or on the flashkit thread which can be found here. Don't forget, this is just a tech demo, showing the engine we have achieved so far - there is much more to add and many more updates left to come so stay tuned!

Monday, November 28, 2005

XML Fun!


Its been a while! What have i been upto you may ask, well apart from shifting my life around the country i have been wrapping up our lovely engine into a more presentable game.

As with most of the information in the game we have decided to keep all the menu info in an external XML file, this allows for ease of editing, flexibility and hopefully reusability in any future projects we undertake. An example of the menu XML for the tech demo:

<text>Start Beta</text>

This is parsed and converted to an object structure as the game is displaying the loading screen. The menus are then created on the fly in the right positions and orientations, displaying the right text! When a button is pressed it then calls the appropriate function within the MenuManager Class and passes the appropriate parameters. I have also been working on a new class called HUDManager, this retrieves all the current information about the race (for example, lap times, positions etc) and displays it on the screen... At the moment this is all done in text format but that will be replaced with some flashy graphics in a later release..

In other news we have been largly bug fixing since the last post, Jon is still working on the broken collision response while i have been tidying up code all over the game in order to get it ready to show you all! Thanks for the support - keep checking back (or subscribe to our Atom feed!) - were getting closer!

Tuesday, August 30, 2005

All That Jazz

The project has been moving forward quickly since we started working using the SVN system, having a central store of the games code that both of us can work from has been invaluable.

Since the last update I have been working on the file manager almost exclusively. Early on we decided that most of the games resources should be kept in external files for easy editing and loaded into the game engine on runtime. This includes things like; race, track and car data aswell as all the in game graphics (which are stored in external SWFs)... All of these files need to be loaded and parsed correctly so that the data is accessible within the game. This is now almost entirely finished.

I have also done a large clear up aswell as adding some small features like 'pause' and a countdown on the grid at the beginning of a race.

We are hoping to post a 'tech demo' of the game on here fairly soon, which is guaranteed to impress, so keep checking back!

Friday, August 12, 2005

Back of the Class

It seems like a long time since i last updated here... i have spent a lot of time on the engine today, mainly organising code and class structure after a lengthy discussion with Jon last night. We have decided on a system of 'Manager' classes to keep the code in order, the main one's being:


keeps track of players career status and track records


holds information only for the current race and functions for starting / stopping / pausing


loading, starting, stopping and deletion of all the sounds within the game


loading and saving of track, player and tileset data

Im hoping to post more technical details here over the coming weeks, aswell as hopefully some interesting code and in depth theory!

Wednesday, July 27, 2005

Artificial Intelligence Update

I've been hard at work on this the past few days. As my part of the engine now stands the AI car races around the track with ease, braking at the appropriate places - it also has the ability to recover after an accident.

Elsewhere, i have corrected a few bugs that were causing problems on certain shapes of corner and in the process simplified some of the calculations. I have also added a handbrake to the physics model, allowing you to perform handbrake turns!

I will try and post a demo (recorded or realtime) here in the next week.

Saturday, July 23, 2005

Artificial Intelligence

Over the past couple of nights i have been working on a basic AI, the aim for this is simply to get the car to drive around the track, when this is complete it will be advanced with braking etc. I also hope to add the ability to avoid other vehicles and recover from any accidents...

This screen shows the current engine with debugging lines displayed, the car works out the trajectory to the next 'waypoint' (which are poistioned at critical points around the track) and adjusts its steering accordingly.