During various events in Pixel Blacksmith, a sound effect needs to play. There is more than one possible sound effect per event, so one needs to be randomly picked each time. Continue reading “Android: Playing Random Sounds”
In Pixel Blacksmith, visitors arrive in the shop and have demands that need fulfilling. The visitors are mostly random, but each visitor is weighted to appear more or less frequently, to allow for rarer visitors. These weighted probabilities also need to be modifiable, to add seasonal visitors etc. Continue reading “Android: Selecting A Weighted Random Item From A List”
Occasionally whilst developing a UI in Android, padding will have to be set programmatically, this usually happens when padding varies according to the number of items on screen. These values must be set in pixels, but the size of a pixel will vary massively, according to the density of the screen (for example, 2 1920px by 1080px and 192px by 108px screens may be the same physical size, but the former will have 10 times more pixels in any given centimetre). As such, display pixels (essentially a unit that aims to avoid this issue) must be used, however these values need converting into real pixels. Continue reading “Android: Converting Display Pixels (dp) To Real Pixels”
Pixel Blacksmith is an Android game where players craft and sell items to visitors, in order to make a profit to buy upgrades / more resources. These items can be enchanted with gems, and the item’s image needs to be tinted the gem’s colour to reflect this.
Many apps need to ship with a local database, and many apps also use a ORM to handle their database actions (I personally use and recommend Sugar). Tying together these two approaches requires some sort of compromise, often manually copying a SQLite database around the device’s filesystem.
Instead for City Flow a different approach was decided: Installing the database on first run, providing progress updates to the user.
City Flow is an Android game where players must rotate puzzle tiles until all flows (rivers, paths, etc) match up. Players can play existing levels, or create their own in a level editor. They can zoom in, out, and pan, so as to navigate larger puzzles easily. Whilst playing a level players are on a time limit, so ensuring all of the puzzle is on screen to begin with is very important to ensure the player doesn’t become frustrated having to initially get the puzzle in a good position.
City Flow is an Android game that tasks players with solving puzzles by rotating tiles to make all “flows” match up with no loose ends. Each tile has a flow (e.g. road, path, grass, river) on each side, as well as a height (high, normal, low). There are a few hundred built-in levels, but players can also create, share, and import their own levels for extended playability.
The game features a level generator, where players can specify:
Since a puzzle can contain up to 225 tiles (15×15), each from a pool of 200+ different tile types, the amount of data to process can swiftly ramp up.
Additionally, since this process could take a long time, it must be performed off the main thread (asynchronously). The player also needs to be kept updated throughout the process with current progress, and have the ability to cancel midway through.