Something went wrong. Try again later

Bio2hazard

This user has not updated recently.

152 0 14 8
Forum Posts Wiki Points Following Followers

I'm making a (mobile) game - Part 3!

Well, it's been a while since my last entry. Almost 2 weeks ( wow, time flies ).. but I've gotten a lot of work done!

Let's continue from the last post: After creating the rooms, I added in road creation. I ended up writing a algorithm that always seeks the center of a room. Additionally, every room except the first and the last try to connect twice. The result is a map that, in my opinion looks pretty good and still maintains that every room is accessible.

After that came the big - nay, the HUGE thing: Graphics. Now, it being a roguelike, it certainly doesn't require much graphical prowess, but still, I don't think a text-only roguelike would find much audience in a mobile store.

Now, implementing the graphics was rather challenging. For one, I'm not too experienced with Flex, for two, performance is a big concern: Displaying the whole map ( sized at 80 x 24 ) would mean that it needs to display a whole 1920 pictures at once. This shot the memory usage through the roof and simply was not feasible.

So - cropping it to the viewport was the next step. But there were problems with that as well: the images that get dynamically loaded in would flicker. Not a pretty sight.

I ended up doing several things:

1) I embedded all images into the SWF file, greatly reducing access time and memory usage when displaying the images

2) I am loading a few more cells than can be fit on the screen: 2 extra rows and 2 extra columns.

3) I am using a mask that hides the extra rows and columns.

What this means is that as the character moves, the preloaded row or column is pushed into view, and a new row / column is being loaded off-screen - while on the opposite site a column is discarded. This is essentially a buffer and makes it so that all loading simply happens out of the player's view.

The result is a nice and low memory usage, no flickering or hiccuping - I am quite pleased.

The tileset I am using for my game ( for now ) are from Danc's Miraculously Flexible Game Prototyping Tiles

Next I worked on a option screen, and permanently storing information. For this purpose I am using a SQLite wrapper. ( I can't help it! I love databases for storing and accessing data!! )

The process was fairly easy in general and the implementation is working like a charm. Currently, you can (independently) select animation speeds for map & unit movement, as well as whether you'd like to view the game in tile or in ascii view by default.

I've also made the active game data more persistent - you can open up the options screen mid-game without it loosing anything when going back to the game.

Then I worked on coming up with a way to dynamically load data. If you recall, one of the goals I set forth was "Load most game data via XML files, for easy editing & modding.", so that's exactly what I did.

It took me surprisingly long to come up with a smooth way of loading data via XML, but I managed to do it ( can't help it - I'm awesome )

I have preset models for each loader ( currently I have a terrain loader and a monster loader ), and am using the Parsley framework to create objects out of the XML files.

One thing I'm a bit "meh" about is that, for obvious reasons, it's impossible to dynamically embed images, so the images in use will always have to be hardcoded. But oh well, performance is important for mobile devices so that's the way it has to be.

Now.. today I've been working on adding monsters. Setting up the basic xml data loader was easy as I could largely copy & paste the terrain implementation, populating the map and displaying it in ASCII was also rather easy.. but displaying it on the tileset, now that was a challenge.

You see, I only have a single group for all images - background tiles, the hero's sprite and all monsters. Due to how often these images are used, I can't afford to add too much information to the custom image class I am using. In short: Dynamically loading monsters in and out as they come into the player's view was a challenge involving around 10 hours of non-stop coding, trial and error, and oh god so much debugging. But I finally got it to work ( I hope... :P but so far all tests succeeded ).

Obligatory screenshot ( this time, comparison! )

Same scene - once with the tiles, once in ASCII !

Starting to look like a game, eh ?

Goal for tomorrow is to get a basic combat engine going ( walking into enemy = attack it ), followed by getting a basic enemy AI going ( enemies walk when player moves ).

40 days left on my Flash Builder trial.

1 Comments

1 Comments

Avatar image for bio2hazard
Bio2hazard

152

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

Edited By Bio2hazard

Well, it's been a while since my last entry. Almost 2 weeks ( wow, time flies ).. but I've gotten a lot of work done!

Let's continue from the last post: After creating the rooms, I added in road creation. I ended up writing a algorithm that always seeks the center of a room. Additionally, every room except the first and the last try to connect twice. The result is a map that, in my opinion looks pretty good and still maintains that every room is accessible.

After that came the big - nay, the HUGE thing: Graphics. Now, it being a roguelike, it certainly doesn't require much graphical prowess, but still, I don't think a text-only roguelike would find much audience in a mobile store.

Now, implementing the graphics was rather challenging. For one, I'm not too experienced with Flex, for two, performance is a big concern: Displaying the whole map ( sized at 80 x 24 ) would mean that it needs to display a whole 1920 pictures at once. This shot the memory usage through the roof and simply was not feasible.

So - cropping it to the viewport was the next step. But there were problems with that as well: the images that get dynamically loaded in would flicker. Not a pretty sight.

I ended up doing several things:

1) I embedded all images into the SWF file, greatly reducing access time and memory usage when displaying the images

2) I am loading a few more cells than can be fit on the screen: 2 extra rows and 2 extra columns.

3) I am using a mask that hides the extra rows and columns.

What this means is that as the character moves, the preloaded row or column is pushed into view, and a new row / column is being loaded off-screen - while on the opposite site a column is discarded. This is essentially a buffer and makes it so that all loading simply happens out of the player's view.

The result is a nice and low memory usage, no flickering or hiccuping - I am quite pleased.

The tileset I am using for my game ( for now ) are from Danc's Miraculously Flexible Game Prototyping Tiles

Next I worked on a option screen, and permanently storing information. For this purpose I am using a SQLite wrapper. ( I can't help it! I love databases for storing and accessing data!! )

The process was fairly easy in general and the implementation is working like a charm. Currently, you can (independently) select animation speeds for map & unit movement, as well as whether you'd like to view the game in tile or in ascii view by default.

I've also made the active game data more persistent - you can open up the options screen mid-game without it loosing anything when going back to the game.

Then I worked on coming up with a way to dynamically load data. If you recall, one of the goals I set forth was "Load most game data via XML files, for easy editing & modding.", so that's exactly what I did.

It took me surprisingly long to come up with a smooth way of loading data via XML, but I managed to do it ( can't help it - I'm awesome )

I have preset models for each loader ( currently I have a terrain loader and a monster loader ), and am using the Parsley framework to create objects out of the XML files.

One thing I'm a bit "meh" about is that, for obvious reasons, it's impossible to dynamically embed images, so the images in use will always have to be hardcoded. But oh well, performance is important for mobile devices so that's the way it has to be.

Now.. today I've been working on adding monsters. Setting up the basic xml data loader was easy as I could largely copy & paste the terrain implementation, populating the map and displaying it in ASCII was also rather easy.. but displaying it on the tileset, now that was a challenge.

You see, I only have a single group for all images - background tiles, the hero's sprite and all monsters. Due to how often these images are used, I can't afford to add too much information to the custom image class I am using. In short: Dynamically loading monsters in and out as they come into the player's view was a challenge involving around 10 hours of non-stop coding, trial and error, and oh god so much debugging. But I finally got it to work ( I hope... :P but so far all tests succeeded ).

Obligatory screenshot ( this time, comparison! )

Same scene - once with the tiles, once in ASCII !

Starting to look like a game, eh ?

Goal for tomorrow is to get a basic combat engine going ( walking into enemy = attack it ), followed by getting a basic enemy AI going ( enemies walk when player moves ).

40 days left on my Flash Builder trial.