I actually wrote the code for this way back in 2008, it was my self assigned learning exercise to teach myself ActionScript 3. I hadn’t intended to create this effect but was intrigued on how transformation matrices works and my tests evolved into he beginnings of a game.
The way it works is pretty simple, each building consists of five sprites, the roof and the four sides. The sides all have a translation matrix enabled which affect the scale and skew based on the distance the building is from the centre of the screen. The roof position is just keeping aligned with top & left sides.
I did want to continue developing this as a game but enthusiasm fizzled out, hopefully soon I’ll be able to revive this work. From the video you’ll be able to see some enemies and the ability to shot a few different guns but it ends there, it really is just a proof of concept.
UPDATE: I’ve released the source for this HERE
I’ve recently developed a random city generator and thought my method might be helpful to someone else in the future.
The plan is to randomly create a portion of an unlimited sized city. This will work by having a set sized grid with multiple exit points and the buildings & road structure will be randomly generated. Each portion of the city will be created upon entry and the exit points should match up to appear that the player is moving seamlessly between sections of the city. We therefore need to seed the sections so if an area is revisited, it’s the same as before.
To start with, we’re going to create a multidimensional array of grid city segments to give a 2D map of the whole city. The whole map will be empty to start with but will end with each tile being assigned to a road or a building. We need to determine if there should be any existing exit points on each side of the section based on neighbouring sections. These exit points are essentially roads so the cells between each exit point is a building. The starting point buildings will have to be generated between the roads but they can be of any length. The exits should have the option to be predetermined to allow matching up with neighbouring blocks or if there are no predetermined neighbours the exits will be dynamically generated.
With all of the exits in position we can start filling in our buildings. The buildings are generated in a spiral manner, starting from the top and working clockwise inwards towards the centre. As an example, the first building starts at point 1,1. We start looking right until we find road and this gives us our width, we then look down in the same manner to get our height. We check each square during this process to make sure each square is empty, if it is, we can create a building here. I set a maximum length for the buildings so if we hit this limit without hitting a road, we can randomly pick a length to use.Spiralling clockwise toward the centre allows us to make sure that all of the area is covered and should reduce an exact grid type look.
Here’s what the final generator is currently producing. It’s not perfect but it makes a good starting point & will work for what I”ve got planned:
Randomly generated City example
So I’ve finally gone & done what I’ve been saying I’m going to do for the last two years, I’ve splashed out & bought myself a MacBook Air. For anyone who’s known me for a long time will probably remember me being very much anti Apple so I’m officially a turncoat.
Although I’m very happy with it, I’m going to skim over the details of the Air so not to bore you. In all honesty, I don’t want to preach the way of the Apple like so many enthusiasts do, you know the type, if they had their way they’d be committing technological genocide as we speak. I think it’s good to have a choice and you should go with what works for you.
As for me, I’m a keen Flash / AS3 enthusiast and the enthusiasm has been suppressed the last few years seeing that Apple’s choice to snub Flash support so I’ve waited to see what the future holds. At this point it’s good to see that you can submit Flash based mobile apps to the App Store and it’s this which has rekindled my yearning to create a game in Flash and now, hopefully, be able to get it onto mobile devices.
One of the biggest losses I feel moving from a Linux environment to the Mac is the loss of the repositories. If you’re after a specific type of app, you can search the repositories and there’d most likely be at least one app there that’ll do what you’re after, completely free. While the Mac does have the Mac store which does a similar task, you’ll be paying for the privilege. Don’t get me wrong, I’m more than happy to pay for apps if they do what they’re suppose to and they do it well, it’s just a case of being used to have a wealth of free and open source applications which are no longer a click away from being installed.
On the flip-side, this does make me ask the question “Can I recreate this app? Could I make it better?”. I know this at face value could look like reinventing the wheel to save a few quid (and I guess it partially is), it’s also a valuable learning experience. Besides, if you look close enough, you’ll see that everything’s a copy of a copy of a…….
I’ve also had a few ideas for games over the last few years but it’s only been recent that it’s become more focused on what I’d like to made. I’ve always fancied the idea of a zombie based RPG, it would be something that I’d enjoy playing but upon looking around, it’s slim pickings. Being that there’s not much existing for me to play, I’m going to give making my own a bash.