Archive

Archive for the ‘Development’ Category

Zen Garden Sudoku for the iPhone

November 24th, 2008

To learn Objective-C and the iPhone API I decided to write a Sudoku game for the iPhone. It was so fun to play that I decided to release it to the general public. With the help of a friend who is very talented in the art of graphic design we came up with a Zen garden theme and thus called it Zen Garden Sudoku. It is now available on the iTunes AppStore for your iPhone or iPod Touch. Enjoy!

troy Development , ,

What I’ve been Doing

August 1st, 2008
Comments Off

A few people have asked recently what I’m up to so I figured I should at least blog about it.  For the past 2 months I’ve immersed myself in the iPhone SDK in an attempt to become both a fluent iPhone developer as well as an OS X developer.  To reach my goal of fluency I decided I should build an iPhone application that I’d want to use on a daily basis and something I might sell in the iTunes AppStore.  That application is Sudoku.  Why?  First, because I love playing Sudoku.  Second, because it’s a fairly graspable application for my first iPhone attempt.  Third, because there’s a good chance of people buying it from the store.  Not that I’m not looking for this to be the killer iPhone application nor a huge money maker.  It’s just my first or hopefully many applications I’ll develop for the platform.  My task list is telling me that I’ll be code complete by August 15th.  If all things go well I’ll publish a week or so after I return from Burning Man.  I’ve registered a new domain that I’ll be using for self publishing.  I’ll announce it when it is up and running.

Otherwise I’m still enjoying San Francisco this summer.  The weather has been accomodating for development but I’m looking forward to fall where it should heat up.  Wow, did I just say that?

troy Development ,

Thanks Bill

June 27th, 2008
Comments Off

Today Bill Gates steps down from his role at Microsoft and I believe I owe him a huge thanks for all he’s done – for the software industry, for his community and now what’s he’s doing for the world at large.  I grew up not far from Microsoft and remember when its offices were next to the BurgerMaster.  In High School I dreamed of working there but after college I wound up at a small startup called Visio instead.  Visio rode the coat tails of Microsoft’s revolution as they pushed for a PC in every home and on every desk.  We had incredible success due in part to both our product and team but also to the massive growth that Microsoft was causing in the industry.  I remember sitting around with other devs around 1995, we were talking about how important Microsoft was to the current industry expansion and about the role Gates/Microsoft played in it.  Someone speculated that Microsoft, so dependent upon Gates, would crumble if he ever left.  We all agreed until someone, Mike Frederick methinks, reminded us that all things do come to an end and that, though we couldn’t see that far in the future, he would one day step down. 13 years later and that day is here.  The industry looks completely different now but hearing about his departure is making me wax nostalgic about where we came from.  I’m proud to have been part of that history and thank Bill for helping make it happen.  Love him or hate him, you have to admit that Microsoft helped fuel the revolution that keeps on moving.  I hope that he has even more success in his philanthropic pursuits.

Thanks Bill.

troy Development ,

Asteroids in Processing

May 5th, 2008

Last February I decided to write a game. Around that same time I was also introduced to Processing. To great things that work great together. If you are a software developer and are not familiar with Processing then I think you should be. It’s a wonderful Java based environment in which you can sketch out graphical ideas very quickly. It lets you worry less about how well structured your code is and instead you quickly formulate your ideas and see them on screen. The number of interesting Processing applications is growing daily and some are very impressive.  It was the perfect platform for my game. Well I should be honest – it’s not “my game” it’s a knock off of one by Atari. You see I haven’t written a video game since high school so I wanted to start with something easy and familiar, hence I chose Asteroids.

It only took me about 24 hours of work to get a good version of the game running. It took an extra 15 hours to try and polish out the rough edges. Honestly I could probably use another 24 hours to polish but at this point I feel happy with the game and feel like releasing it and moving on to my next game. Supposedly there is a bug that causes the ship to lock up though I have not experienced it. If you do please let me know and try in detail what was happening at the time of the lockup. Or download the source and fix it yourself.  Enjoy!

Controls:

Space – Fire
Left – Rotate Left
Right – Rotate Right
Up – Forward Thrust
Ctrl – Hyperspace

troy Development, games , ,

First Attempt at Debugging iPhone Web App

August 15th, 2007
Comments Off

I’ve started debugging an application for the iPhone and thought it decent to post my first thoughts and discoveries. Apologies for the bad code formatting, I’ve never posted code to my blog before and WordPress really gave me a bad time. I’ll figure this out.
Logging via console.log

First off was console output. The simple console.log() method supported by Safari and FireBug is what I use in much of my code. Though supported on the iPhone one cannot view the console at the same time. Instead of falling back to alert() I instead redirect the console output to the server. John Hewitt built a solution similar to mine which is to have your web server accept log messages. Since I’m working on a Java web server I wrote a Servlet that accepts a URL of the form

http://localhost/app/logger.js?msg=Hello%20World

and logs the output to a local file, in my case /tmp/logger.log. Here’s the Servlet code.

public class LoggerServlet extends HttpServlet {
@Override
protected void doGet(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {

   response.addHeader("Cache-Control", "no-cache");
   response.addHeader("pragma", "no-cache");
   response.addHeader("Expires", "-1");
   response.setContentType("text/javascript");
   response.getWriter().write("//Done");
   response.setContentLength(6);

   String message = request.getParameter("msg");
   message = message.replaceAll("rn", "n").replaceAll("r", "n");

  try {
    File x = new File("/tmp/logger.log");
    FileOutputStream fos = new FileOutputStream(x, true);
    PrintWriter pw = new PrintWriter(fos);
    pw.println(message);
    pw.close();
  } catch (java.io.FileNotFoundException fnfe) {
}
} }

On the client I detect if I’m using an iPhone and redirect console.log() to GET this URL instead using a SCRIPT GET. Perhaps using the Image object is better as it doesn’t clutter the DOM. That’s an optimization. Here’s the code.

// This causes browsers without a console or the iPhone to log on the server.
if (typeof console == "undefined" || /iPhone/.test(navigator.platform)) {
var oldConsole = window['console'];
if (typeof console == "undefined")
window.console = { };

console.log = function(msg) {
// Might be too early to do this - can we add directly to the body?
if (typeof document.body == "undefined") {
if (oldConsole) oldConsole.log(msg);
return;
}
var script = document.createElement("script");
script.type = 'text/javascript';
script.src = './logger.js?msg=' + encodeURIComponent(msg);
document.body.appendChild(script);
}
}

It’s simple and works well for my scenarios. To see the log output I just open a Terminal window and run ‘tail -f -n 50 /tmp/logger.log’ which continuously displays new log output.

Trapping Enter Key

I’ve got lots of key handlers that check for the enter key by looking for (event.charCode || event.keyCode) == 13. Sadly this fails on the iPhone as it returns 10 (line-feed) instead of 13 (carriage return). I find it odd that Safari returns 13 like IE and FireFox but the iPhone is different.  If you are handling the enter key then you must check for 10 on the iPhone and 13 on other browsers, or check for both which seems safe.
No Scroll bars with CSS Overflow

The next thing I’ve found but have no fix for is displaying scroll bars on block elements with overflowing content. I use this as do many sites and it’s really too bad the iPhone won’t display a scroll bar. Below is an example that, when viewed on the iPhone, shows no scroll bars but does in all other browsers.

asdf
asdf
asdf
asdf
asdf
asdf

troy Development