My Experience with Penguin Technology

I got introduced to a new Technology called “Penguin”, as a part of our course, Interactive Multimedia. This is a very interesting piece of code created by Prof. Dan Zen, with which we can develop “Mobile Tilt Games or Applications” in flash.

Few Words about Penguin Technology:        

Penguin Technology allows us to emulate mobile device rotation and translation in Flash so that we can develop Mobile Tilt Games or Application.  

Penguin Technology comes with a Penguin Tilt Emulator. This creates tilt data and stores it as an XML file on your machine. Penguin is a simple class that retrieves XML which provides tilt and translation of the device.  An event is triggered when any of the properties (roll, pitch, yaw, forward, right or down) is changed.

 

For more details about Penguin Technology, samples, code and video, go to http://penguinsflash.wordpress.com 

Penguin Technology and Accelerometer Class:

Flash 10.1 introduced a new user interface feature called Accelerometer which also supports tilt. The Accelerometer Class is currently only available for AIR 2, Flash Player 10.1, Flash Lite 4, and iPhone Flash apps. On Android phones you will only be using this feature if the phone runs Flash Player 10.1.

  Penguin Technology Accelerometer
Class Custom made class by Inventor Professor Dan Zen com.danzen.interfaces.penguin.Penguin Introduced in Flash 10.1. flash.sensors.Accelerometer
Test Emulator Penguin Tilt Emulator Flash Emulator in Device Central
Events Event.CHANGE AccelerometerEvent.UPDATE
Properties roll, pitch, yaw, forward, down, right accelerationX, accelerationY, accelerationZ

My experiments:

I created a small tilt game using Accelerometer class. I tried making a simple version of the old Pacman Game(credited to Namco Ltd.), where all motions of Pacman is controlled by tilting the device.

In order to check whether the device has accelerometer capabilities, you need to retrieve the  “.isSupported property” of the Accelerometer class. The value of this property is true if it is supported, and false if it is not supported. In order to see or test the game on the emulator, go through Control ->Test Movie and make sure that in Device Central is checked.

 Two classes we need to import into the project to use Accelerometer are:

import flash.sensors.Accelerometer;
import flash.events.AccelerometerEvent;

In the AccelerometerEvent.UPDATE method, the Accelerometer sensor properties, accelerationX and accelerationY  are stored in two variables.

moveX = -e.accelerationX;
moveY = e.accelerationY;

In the ENTER_FRAME event method, x and y properties of Pacman is constantly updated to the value retrieving from Accelerometer sensor. Thus x and y properties of the Pacman is controlled by tilt motion.

pacman.x += moveX * speed;
pacman.y += moveY * speed;
if (moveX<0) {pacman.scaleX = -1;}     //to flip Pacman
if (moveX>0) {pacman.scaleX = 1;}

I randomly placed some popcorn on the stage. When Pacman hits each of the popcorns, the popcorn disappears and the score increment by 10.

for (var i:uint=0;i<candyNum;i++){
            if (pacman.hit.hitTestObject(candyArray[i].hitBox)){
                        if(this.contains(candyArray[i])){
                                    this.removeChild(candyArray[i]);
                                    scoreUpdate();
                        }
            }
}

There is a countdown timer and the game will be over when time is over or Pacman finish all popcorns.

This entry was posted in Technology. Bookmark the permalink.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s