Saturday, 6 February 2010

Using Mobile Processing (Part 1)



My recent experiments have been trying to utilise the Mobile Processing language to create applets for mobile phones. Having used Processing before quite extensively these experiments were concerning how easy it was to write applications for mobile phones, in particular my own, the LG KP500.

The majority of my work was creating an environment to write these applets, which involved downloading mobile processing from http://mobile.processing.org/ and also a wireless toolkit for testing and running prototypes of my code before uploading them to my mobile phone, which for the mac, mpower player (http://mpowerplayer.com/sdk) is the only option.

Once these are set up it was simply a matter of writing the code and exporting it as a midlet for my mobile phone to run.

My first experiment features no interaction, it is instead a simple animation of a house with snow falling, this allowed me to experiment with movement, arrays, colours and shape primitives.

My results were successful on this first experiment with mobile prcoessing, allowing me to play the rather simple animation, as can be seen in the following photo, however the real test will be to explore the power of mobile processing for allowing interaction to take place, using touch screens and buttons which will be my next experiment.



Here is the complete code-

int snow[][] = new int[100][2];
int x = height;
int y = width;

void setup()
{
for(int i = 0; i < 100; i++)
{
snow[i][0] = random(0, height);
snow[i][1] = random(0, width);
}
background(0);
rectMode(CORNER);
}

void draw()
{

fill(245);
ellipse(20, 20, 30, 30);
fill(100);
rect(80, 20, 70, height - 20);
fill(140);
rect(60, 60, 50, height - 60);
fill(144, 31, 46);
rect(40, height - 40, 75, 40);
fill(200);
triangle(40, height - 40, 115, height - 40, 77, height - 65);
fill(0, 2, 40);
rect(60, height - 15, 15, 15);
fill(255, 243, 0);
rect(90, height - 35, 15, 15);
fill(255);
for(int i = 0; i < 100; i++)
{
int total = snow[i][0];
snow[i][0] = total + 1;
if(snow[i][0] > height){
snow[i][0] = 0;
}
ellipse(snow[i][1], snow[i][0], 5, 5);
}
}

No comments:

Post a Comment