Whirly, PHP, Netbeans, CodeIgniter and Lidgren Gen 3
Whirlygig WP7
This week Vic Chelaru (the guy that built FlatRedBall) and a friend of mine named Joel solved the tombstoning problems that both Whirlygig and Udder Chaos, a game Vic just released on WP7 (try it now!) were having. With that solved, the only thing I have left to do is get the options screen working and resubmit it. Here’s the mockup of the options menu (some work left to do):
PHP and CodeIgniter
PHP was my first-ish programming language (I actually toyed with programming in BASIC as a youngster, then learned a little javascript and eventually ActionScript 1). I wrote PHP for years in the only way that I really knew from following tutorials online: procedural code with HTML mixed right in the middle of the PHP. When I first started, Object Oriented PHP was a bit of a joke. and most of the projects I worked on were too small to require a large, fancy framework. I wrote fast, vanilla PHP that worked just fine. I also wrote the majority of my PHP in a simple text editor with highlighting.
Once I moved into learning OOP languages like Java and C# the mashup of procedural PHP and HTML that I’d been writing looked like messy spaghetti. And after getting used to Visual Studio, going back to a humble text editor was downright painful. I began to think of PHP as a toy language…something serious programmers didn’t write because I’d only seen amateur code. But I never abandoned PHP because it was so darn useful. I had built a simple but fast and stable CMS that I used to build cheap sites for small businesses. I tried WordPress, Drupal, Joomla and others at various points but they were too large, a poor fit for the client’s custom needs or needed updating too frequently for a local business that needed a 10 page site that they could edit themselves.
So, I had a conundrum: .NET is a powerful language with a really, really good toolkit (VSE). But, .NET servers are more expensive and, I’ll be honest, I hate IIS. Additionally, many of my clients had some level of existing technology that they needed to be compatible or they had already purchased LAMP hosting (good for them). So, I started exploring PHP frameworks, new IDEs and spending a lot of time reading other people’s code. I learned a lot.
I’ve discovered that PHP is a lot like Javascript. Millions of people write it but only a handful write it well. And when it’s well-written it’s beautiful.
After spending some time with Cake, Symfony and CodeIgniter I decided that CodeIgniter fits me the best: it’s lightweight, really fast and highly configurable. The patterns are more flexible, allowing me to hack out experimental stuff in less time. I have started rewriting my CMS in OOPHP on top of CodeIgniter.
Lidgren Gen 3
Several years ago I worked with a buddy on a 2-D, top-down, multi-player tank game. We used the Lidgren networking library to handle network communication. At the time, my understanding of game programming, networking and C#/XNA was rudimentary at best so I couldn’t really appreciate the code my buddy wrote and how Lidgren worked.
Fast forward four years, two games and about 50,000 lines of code and I was ready to try some multiplayer programming
Last weekend (when I wasn’t playing with CodeIgniter) I also downloaded, installed and created a working client/server implementation of Lidgren Gen3 that sends simple messages back and forth. While the library is still lacking in documentation, the provided samples make it pretty clear how everything fits together. I don’t have a lot of time to play with this right now but I’ll probably be coming back to this on future games.
Netbeans
I hate Eclipse. I’ve been using it at work some for Android Dev and it drives me nuts. At the same time, I was looking for a good editor for HTML, CSS and JS/jQuery that would also work for PHP. I downloaded Netbeans and have been extremely happy with it. It has a lot of features that I’m used to from VSE, some new stuff such as the Navigator which lets you quick-jump to method and class definitions in a file, and remote sync. It’s been an excellent editor for a variety of projects that I’ve been working on and will now be a staple on my systems (already installed it on 3 of my 4 computers). Oh, it works for Java too? Meh.
UPDATE:
I forgot to post some sort of code. I’m trying to post a little code every week. So…obligatory code. This is a jQuery/jQueryMobile method that recursively creates a jQM nested list from a JSON object of unknown depth. Yay!
function listFromJson(listData) {
var ul, li, i;
ul = $('<ul data-role="listview" />');
for (i = 0; i < listData.length; i += 1) {
li = $('<li />');
li.append(listData[i].Name);
if (listData[i].Children.length > 0) {
li.append(listFromJson(listData[i].Children));
}
ul.append(li);
}
return ul;
}
Example JSON:
{
"listType" : "department",
"listData" :
[
{
"Id" : 1,
"ParentId" : null,
"Name" : "Clothing",
"Children" : [
{
"Id" : 2,
"ParentId" : 1,
"Name" : "Men's Clothing",
"Children" : []
},
{
"Id" : 3,
"ParentId" : 1,
"Name" : "Kid's Clothing",
"Children" : []
},
{
"Id" : 4,
"ParentId": 1,
"Name" : "Women's Clothing",
"Children" : []
}
]
},
{
"Id" : 5,
"ParentId" : null,
"Name" : "Shoes",
"Children" : [
{
"Id" : 6,
"ParentId" : 5,
"Name" : "Men's Shoes",
"Children" : []
},
{
"Id" : 7,
"ParentId" : 5,
"Name" : "Kid's Shoes",
"Children" : []
},
{
"Id" : 8,
"ParentId": 5,
"Name" : "Women's Shoes",
"Children" : []
}
]
}
]
}
