Android: Importing Levels From QR Codes (Camera / File)

The Problem

In a previous post, it was discussed how to export levels from an Android game (in this case Connect Quest) so that other players could play them. Now that they’re exported, we need to be able to import them again! This post will explain how to import QR codes either directly from the camera, or embedded within an image on the file system.

Continue reading “Android: Importing Levels From QR Codes (Camera / File)”

Calculating Weapon Damage Using Ideal Ranges

The Problem

Whilst building a turn based strategy shooter, weapons needed to have “ideal ranges”. For example, a melee weapon should only work from 1 tile away, a shotgun should prefer short ranges, a sniper rifle should prefer long ranges, etc. The non-melee weapons should still work outside of their ideal range, but with reduced damage.  Continue reading “Calculating Weapon Damage Using Ideal Ranges”

Android: Selecting A Weighted Random Item From A List

The Problem

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”

Android: Converting Display Pixels (dp) To Real Pixels

The Problem

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”