Saturday, August 24, 2013

Game Syncing and Thermometers

I've been working with the Google Play Game Services some more trying to get a player's unlocked levels to sync for accounts across different devices in the scrolling shooter. The Game Services have some cloud saving abilities, but after spending a lot of time trying (and failing) to get it working, I decided to go a different route. Google's documentation of the cloud saving services leaves a lot to be desired, and I found their one example of how to implement it to be a bit of a complicated mess. For my solution, I tried something else, and it is not what Google would ever intend for someone to do and it probably isn't very good practice, but it's working well for me. What I'm doing is when the player starts up a game, I use the Game Services API to get a buffer filled with all the available achievements for the account. Then I step through the buffer and record how many of the achievements are unlocked. Since in the scrolling shooter game, the only achievements will be for completing a level, the number of achievements that are unlocked for the account is the same number of levels completed. Obviously this method wouldn't work if I had achievements for other things like reaching a certain score or beating a level in a certain time, but I have no intention of adding any such achievements so this works out pretty well. The game has a saved preference of how many levels are unlocked, so after I get how many achievements the player has, I compare that to the saved value of unlocked levels. If the number of unlocked levels is less than the number of achievements, I update the unlocked levels to be correct for the account. If the max number of unlocked levels is already saved in the preferences then I don't have to check for this level syncing in the first place and I just avoid any unnecessary calls to the Game Services. It's not how Google intends for people to do things and it's a bit of a hack job, but it's also pretty solid and it seems to be working well, so I'm going to stick with it on this particular app.

In addition to working on the Game Services for my scrolling shooter, I've been adding a bit to my platformer as well. Just recently I added my "danger meter" to the HUD. Its a thermometer and it shows how close the lava wave chasing the player is. As the lava wave gets closer, the level of the thermometer rises, filling the gauge when the lava actually reaches the player. It's really nice because you now have a way of telling when the lava is getting close before it actually appears on the screen. For the most part, its easy to keep the lava far enough away that the thermometer is empty, but since the lava speed ramps up over time, it will eventually catch up and the level of the meter rising lets you know its coming.

Here are a couple screenshots of the thermometer in action:


No comments:

Post a Comment