First iPhone App

I am learning iOS  development as a full time subject at school like I did electronics last year. Yep, I go to school and learn programming. Pretty f$#^@&g awesome. We’d been doing terminal apps to learn the basics of objective c when we had a one-day workshop from apple engineers. Real apple people. The people emerged from the shadows with a holy white glow. No, they were really nice down to earth people actually. After they showed us iBooks author in the morning (it has a VERY hard to solve bug –  changing the background colour of a page) they moved on to some more advanced stuff – iOS dev. I was expecting some big thing where you have to code all this stuff to get it to display a black screen. It had to be harder than little terminal apps right? He dragged and dropped a text field, linked it up, pressed run and there was a hello world! I was like REALLY? Is it really that EASY?

This was awesome. I’d never seen anything this easy. So I mucked around for the rest of the workshop making some little things with the button and text outlets. We did a map example which everyone thought had a critical bug. It turned out to be that the simulator was set to simulate every single apple store location. So it was flying around before the map image was loaded. Making it look like the animation feature was stuffed.

I got home from the workshop and I was like, make something, anything, now! There’s some kids on my bus who talk about Minecraft EVERY day. And a lot of kids in the junior school robotics class that I teach are crazy about the stuff. I decided to make something minecrafty for them. I settled on making a little app that allows people to view all the splash texts and see what their meanings are. If you don’t know what the splash texts are go here: http://www.minecraftwiki.net/wiki/Splash . They’re basically just references to popular culture, games and in jokes. There’s 304 of them and one is randomnly displayed each time you load the game in a bright yellow flashing font.

So I set about making a little browser for these. Luckily all the splash texts are stored in a text file called splashes.txt found in minecraft.jar. So all I had to do was get the text file out, write some code to convert it to an array and print out the result. I also added the ability to view what each text means on the wiki page, and the text number. It was made as a project to learn how to make, debug, refine, submit and manage an iPhone app so I know what I’m doing when I want to make something good. The app is rated 17+ because apple has a silly rule that anything that has web access is highly dangerous. I think because it’s 17+ it’s banned in Korea or something. It’s a free app available for download from the app store.

It should top 50 downloads by the end of today. I don’t understand who would download it. Honestly.

Get the app here: http://itunes.apple.com/us/app/mc-splashes/id514227231?ls=1&mt=8

Some of my favourite reactions:

“So, what does this actually do?” Nothing really.

“Are you serious?” Yep. Vaguely.

“You’re going to charge people money for this aren’t you? Yes?” Um, no.

“Can’t you just view the wiki page?” Well, yeah but it doesn’t display them in the font and colour.

 

Advertisements

An update on some stuff

Okay so I went away for the weekend for a cycling race and on the car drive out I mostly just messed around with my new macbook air (more on that later). On the way back when I was extremely tired (as one is after racing the national champion) I remembered that I’d promised to write up some better behaviour code for that little robot I built.

The end result of that lazy little 20 minutes of code writing is pretty simple. Basically the program picks whether the robot is going to be happy, sad or neutral when the door is opened. Once it has determined that it simply shakes it’s head, blinks it’s eyes or plays a tune based on how happy it is. There are varying levels of action for each part of the robot to correspond with how happy or sad it is. Anyway, here’s the code so you can get a feel for what it’s like:

//Servo robot behaviour program
//Created by Lochie Ferrier to control a small robot
//the servo control information
#include <Servo.h>
Servo head;
//the mood of the robot when the program runs for the first time
String mood=”happy”;
//initiate variables
int selector, speakerPin, lastReading, pos,range,ledPin,lastPitch,pitch,additive,timeAfterAction=60000;
void setup(){
head.attach(9);
Serial.begin(9600);
}
//HEAD FUNCTIONS
//function to shake the head slowly
void headShakeSlow(){
pos= random(0,180);
head.write(pos);
delay(3000);
head.write(0);
delay(3000);
}
//function to shake the head moderately
void headShakeMedium(){
pos= random(0,180);
head.write(pos);
delay(2000);
head.write(0);
delay(2000);
}
//function to shake the head fast
void headShakeFast(){
pos= random(0,180);
head.write(pos);
delay(1000);
head.write(0);
delay(1000);
}
//LIGHT FUNCTIONS
void eyeBlinkSlow(){
digitalWrite(ledPin,HIGH);
delay(1000);
digitalWrite(ledPin,LOW);
}
void eyeBlinkFast(){
digitalWrite(ledPin,HIGH);
delay(500);
digitalWrite(ledPin,LOW);
}
//SOUND FUNCTIONS
void melodyLow(){
pitch=200;
int count=0;
if(count<10){
range=50;
additive=random(-range,range);
pitch = pitch+additive;
tone(speakerPin, pitch);
pitch=lastPitch;
count++;
delay(500);
noTone(speakerPin);
}
}
void melodyHigh(){
pitch=400;
int count=0;
if(count<10){
range=50;
additive=random(-range,range);
pitch = pitch+additive;
tone(speakerPin, pitch);
pitch=lastPitch;
count++;
delay(500);
noTone(speakerPin);
}
}
void loop(){
if((lastReading+2)>analogRead(0)){
selector=random(0,2);
if(selector==0){
mood=”sad”;
//perform sad behaviour for the robot
Serial.write(“:(“);
eyeBlinkSlow();
headShakeSlow();
melodyLow();
//this function ensures the robot does not continue to bug me once it has finished
//it’s little hello
delay(timeAfterAction);
}
if(selector==1){
mood=”neutral”;
//perform neutral behaviour for the robot
Serial.write(“:|”);
eyeBlinkSlow();
headShakeMedium();
melodyLow();
//this function ensures the robot does not continue to bug me once it has finished
//it’s little hello
delay(timeAfterAction);
}
if(selector==2){
mood=”happy”;
//perform happy behaviour for the robot
Serial.write(“:)”);
eyeBlinkFast();
headShakeFast();
melodyLow();
//this function ensures the robot does not continue to bug me once it has finished
//it’s little hello
delay(timeAfterAction);
}
//end of robot action
}
}

The other cool thing that has happened recently is I have received on loan for a year a Macbook Air from my school for learning iOS development. Aside from all the pretty Mac graphics and hardware design I think one of the main cool things about this computer is it’s flash hard drive. This means it’s boots up REALLY fast making it a much more useful device than my slower booting (but to be fair, faster overall Dell). Also it’s weight and size is quite impressive. I’m going to be pretty tempted to buy it from the school at the end of the year.

I was also asked by my iOS dev teacher to share my thoughts on objective-c. Well seeing as I really haven’t done that much in it already I thought I’d just make a meme about it instead.