Dynamic Roads & Picking

It’s been a slow couple of weeks on the game development front which has mainly been down to trying to get ‘picking’ to work. I was thinking about the game play style and think that I’d prefer it to be more strategic than action and decided to change it to a point & click style game. This would also be a better choice as its mainly been aimed for mobile devices.

The main issue with this decision is that because I’m using a 3D environment now, I need to use a process called picking. Picking is the process when you click on a position of the screen and it calculates which object in the 3D environment has been clicked. This is all new to me and left me feeling quite out of my depth. I did manage to find an example of picking but it didn’t play nicely with my current workings when trying to add the methods to my code. After a full week of free time hours try to getting this working, I admitted defeat which doesn’t happen too often. The decision was made to take a look into a premade 3D engine so I started looking at Away3D.

Away3D

Looking at the examples on the Away3D shows that picking is alive & kicking and having a quick go at creating a testbed seems like a quick & easy solution to creating a 3D environment. My first issue was that there’s not really a great number of tutorials and the genreal help seems to be lacking, that is unless you want to pay for their support or purchase a book. At this revelation, the tenacious side of me kicked in again and I’ve decided to take another look at getting my own version working but in the mean time, take a break & make progress in other areas.

Dynamic Roads

While looking into the picking, I came to the realisation that the different sections of roads being used could be generated from just one tile. Being that the 3D models use triangulation, I could create a tile which would contain two different elements which could be manipulated to the correct road layout.

road

When applying the texture to the mesh, I have control over which part of the texture gets applied to which corner of the triangle. Therefore, with the image above I can create a straight section of road with the left triangle of the image twice or a crossroad using the right triangle in the same method. This in theory means that less textures are required and should help improve performance. The short video below shows this method in action.

It’s not the greatest looking piece of work but it’s functional and can be updated later on.

What’s Next?

There are a few pieces which are next on the list, I still need to get the picking working but I’ve pushed this to the back-burner for now so I can make some progress on other sections.

I really need to optimise the transition from one city area to another, currently there’s a lag when creating the new area which I really want to reduce or remove.

The other two sections are the pieces I really want to get my teeth into, that’s the enemies with basic reactions. The other is to make each city block more unique, I want there to be different building types and searchable items (crashed cars, bodies, containers, etc)

Seamless city generation progress

I’ve made the decision to change the loading of levels in the game. Originally the plan was to load each piece of the city at a time when you exited and entered a new area. In more recent games, gamers are more accustom for levels loading in the background making it a seamless experience, therefore, this is what I’ve attempted to go for.

To show how I’ve implemented this, I’ve zoomed right out to give  you an idea of the process being performed.

As you can see there’s still a little left to do, the buildings at the edge of each section is still full length which will lead to long buildings so I just need to half the width of these. There’s also a slight lag while each block is being generated. All in all, it’s not too far off what I was hoping to achieve, just needs a few tweaks.

Game Development (April 2013)

Once again, it’s been a while since I’ve posted anything but enthusiasm dwindled a bit a few months ago. A few changes have been made since the last update but nothing substantial. They pretty much cover what I was wanting to get done in the next stint but it hasn’t progressed much further than that. The main reason of the lack of progress is that I tried running the game on an Android Nexus and by the version of AIR available doesn’t support the 3D stage which is a bit of a major blow for trying to create a 3D game for AIR to be used on Android devices =P

Zombies!

I’ve added in basic randomised zombie sprites which are currently spawning on each road tile. At this point in time, it was mainly to get a sprite on stage with a randomly picked texture. They’re also shootable but hit-testing is a little hit & miss and needs tweaking. The next step for them is to be randomly spawning based on the player’s location and being destroyed once too far from the player. They also need to move (as zombies do), randomly at first but react to the player by noise and viewing angle.

Besides the zombies, I’ve also added in a slight camera chase so the camera movement is a little more fluid. I’ve tried to capture this in the video by starting & stopping but this may just end up being annoying. I’ve also added in a slight improvement on how the roads are being drawn on stage, now I’ve just got to replicate this on all the other models.

I’ve been trying again to get the 3D stage working on the Android but there’s been a security update which is causing problems so I can’t currently export onto the device. Hopefully I’ll crack it soon.

Update (2 minutes later)

Welllllll……. although I spent a couple of hours the other day fighting with AIR and Android and gave up in a sulk, I’ve just tried it again and it worked straight off the bat. Seriously, no changes to any configuration, literally plugged in the device & clicked debug.

Now this is working, I’m feeling a second wind coming on.

Game Development Update

Updates

It’s been a little while since my last update on the game dev process. I hadn’t really worked on it much over the last few months but had an inspirational burst over the last few days. I had hit a block with the 3D translations where models weren’t moving properly and it seemed to be moving some vertices in one direction while move the rest in another. This wasn’t ideal and it looked a bit like there was a rip in the fabric of the game’s universe.

After spending many hours trying to fix, I decided to cut the dead weight and completely rewrite how the 3D worked. There are still a few niggles which are annoying me but they’re purely with how the code’s currently working, they shouldn’t affect the final output so I’ve pushed them a bit lower down the priority list.

Now although the underlying code is all sparkly new, the output looks pretty much the same as the last video so I’m afraid there’s nothing new to actually see in this video. Hopefully I’ll have something more exciting in the next update.

What’s next

There are still a few pieces to be done on the 3D side of things, cleaning up & optimising but with the rewrite out of the way it lets me start coding some game functionality.

As you can see from the video I’ve already started by adding in a placeholder sprite for the main player. Next I need to add in some basic enemies, bullets and hit testing on everything. Another important addition is to add in touch interface controls. I had wanted to make this more like a classic point click style RPG but there doesn’t seem to be an easy method of capturing touch events on the 3D stage. I’m therefore changing it to be more of an action RPG style.

Mobile projects

It’s been a little while since I’ve written anything about development and that’s down to yet another project. I seem to have quite a short attention span when it comes to my own projects so I seem to bounce between old & new things I’m working on.

One thing I’ve been wanting to do for a little while is take a look into mobile app development. I was on the verge of venturing out to teach myself iOS & android development until I learnt that Flash Builder can now export to both platforms. This means that I get to be somewhat lazy, I only have to build one application to work on multiple devices and I get to use ActionScript 3 which I’m already proficient in. There were plans for this before but I the last I heard Apple had pretty much put a stop to it. Luckily now they seem to have made a U- turn.

I’ve been looking through the available components and although some key pieces are there, that’s about it…. it feels very barebones. I guess this does allow you to be more creative in having to build the components you need but that’s half the fun (from a programmers point of view at least). Hopefully once I’ve gotten something worth publishing on the matter I can divulge further.

Textured 3D

Just an update of progress, I’ve been elbow deep in vectors and texturing trying to redo the 3D buildings shown in the previous progress post. The reason I redid things was because the texturing doesn’t allow repeats so to avoid having to create many textures for the different building sizes, I’ve written it so the 3D models are dynamically created.

Explain yourself!

Basically, in the old version the buildings all consisted for twelve triangles, two for each side and were given a scale to resize according to the city plan. Unfortunately to use textures correctly I’d have to break the models up into multiple squares per side. For example, a five by four sized building will be five by four to a scale of one, previously it was a one by one sized building scaled by five on the x axis and four on the y.

Okay, admittedly that explanation was pretty damn poor, I’ll write up something covering the ins & outs of 3D in Actionscript 3 when I find the time & enthusiasm.

More exciting than squares
While looking into the hows of 3D models in AS3, I found a script for Blender to export models to vector coordinates unleashing the possibility of creating some complex models. The script can be found here

Burgled & data safety

I was out of town last week for a few days where I received a phonecall no one wants,  the key-phrase being “you’ve had a little bit of a break in”. They had a good rummage through everything and managed to get away with a relatively good swag including two iPads, an old PS3 and about thirty games. The PS3 didn’t even have a hard-drive in which is a minor win (yay?). The week before we had purchased a new PS3 for a newer slim model which is much more energy efficient and we had taken that with us as we had some recorded TV programmes.

They obviously weren’t too tech savvy as they left the Drobo and fortunately I had the Macbook with me. This did get me thinking about offsite backups and the safety of my files. I’ve got Time Machine setup on my laptop which is saving to two locations, there’s a Micro SD card plugged in most of the time and the Drobo’s Time Machine share. This works fine as if my laptop is stolen while I’m out, I know that there’s a backup waiting for me at home, but what if someone brakes in & steals both the laptop AND the Drobo backup? For the web work I do, the majority is in subversion but all the other work files are just kept locally. The current main issue with subversion is that it doesn’t have my latest changes. Sometime I could work on something for a couple of months before committing my changes and that would be lost if the worst were to occur.

I’ve also started using Google Drive to keep everything synced online. There are plenty of alternatives but I purely went with Google as it’s half the price of Dropbox. I’m quite aware that Dropbox have a lot more features and is more widely supported but I can always change later if I need to. Anyhow, all this means is that if the worst was to happen (again), I could just link back up to Google Drive and download the latest copied of my files.

Moving to true 3D

The more I worked with the pseudo 3D I created, the more imperfections started to grate on me. The glaring one being that the wall perspective just wouldn’t work as I wanted with different sized buildings. I had started working on texturing the walls as shown in the following video but the last ten or so seconds of the video you’ll be able to see the gaping imperfection I speak of.

Not being happy with this, I’ve started looking into a true 3D setup. I’ve started playing around with a few basics and have integrated the random city generator into it. So far I’ve got a load of 3D boxes which will be the buildings and the gaps between will be the roads.  You’ll have to excuse the texture, it was a quick example. =)

Like I said, a very basic example but once I’ve fixed the textures, added a simple player sprite and added in some hit-testing it’ll be about the same stage as the pseudo version, give or take a few tweaks.

Admittedly it’s looking very much old GTA stylee which is the visual effect I was going for, but the gameplay in mind will be completely different. I’ll divulge more information of that in the future.

Random city generator with pseudo 3D

If you’ve read the previous posts you probably saw this one coming from a mile away. I’ve combined the random city generator with the pseudo 3D buildings to give a classic GTA style.

I’ve made a few tweaks to how the building perspective works and it looks much nicer than it did but it’s still not perfect. The scale of the walls is still generated by the dimensions of the building, for this to work correctly it should really be based by the building position from the player. This will probably be tackled another day as this makes a good starting point.

What next?
Now where do we go from here? Well the last piece of the level generation puzzle is to make the random level generation seeded. This is essential for the player to be able to revisit previous sections of the city and for the structure to remain intact.

Once the seeding is in place, we can move onto the graphics and some actual gameplay elements.

Pseudo 3D

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.