Adventures in Swift: Playing with CMMotionManager and gravity

I recently added an iOS game embryo to GitHub: https://github.com/LarsBergqvist/GravityBall

It’s a SpriteKit-based game in Swift 2.0 where you tilt the device to roll a spike ball around with the aim of smashing an infinite number of balloons.

Yes, it’s an endless game with no more purpose than destroying balloons for pure pleasure. But the major stakeholder for this piece of code likes to play it (my 4-year old son that currently has an obsession with physical balloon annihilation – with an app there’s much less to tidy up afterwards).

The code illustrates usage of accelerator data and multiple gravity fields. The physic’s world has a normal vertical gravity field, but there is also a SpringField in the middle of the scene that interacts with the balloons so reaching the balloons gets a bit harder.

I will use this game template for a complete maze ball game in the near future (do you remember those wooden games from BRIO in a not so distant past when there were no computer games around?) – perhaps with some Pac-Man ghost as enemies in the labyrinth.

Game on!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: