First of all, I've stopped working on CanLaro for quite some time now and I'm not sure if I'll continue working on it anytime soon. There are some other HTML5 libraries and game engines out there such as ImpactJS that works pretty well already. I'll be keeping the repository up on GitHub though, just in case.
I've also decided to make the switch from WordPress to Posterous. I will not have any control over what features gets added or removed to the blogging engine, but I think I can live with that. These limitations allow me to focus on what's important: the contents and the projects I'm working on.
Finally, I'll be starting a dev diary for my projects. I'm writing it mostly for myself, but you're welcome to read it. I'll still be posting some dev work here on my main blog, but I'll be restricting it to about major or minor releases and other reladed stuff I'd like to share.
While looking around for some HTML5 Canvas code, I found a lot of examples, but only a handful of reusable libraries. The drawing functions, are useful and there are draw image functions that draw a part of an image, useful for a sprite. Nice but it can get troublesome with tiled animation and transformations. In the end, I decided to make one myself: CanLaro!
Can: short for canvas, also "to be able to"
Laro: Tagalog word for game
My goal for this library is mainly to provide code that can help any 2D game get started as long as you know some Javascript and know what a game loop is. I wrote/am writing this mainly as a helper and you are free to write your game as you please.
Here it is in action: CanLaro Demo: BobCanvas.
At the moment, here's what it offers:
Check the README at the CanLaro github project repository for more details and updated documentation.
Planned possible updates:
"Community commands (those hosted on individual servers, locally, or on the herd), however, cannot be localized at this time." (via: Labs/Ubiquity/Ubiquity 0.5 Making Commands Localizable - 09.07.10)Maybe soon...
In one of my projects, I had to look for certain objects using certain qualifiers: ID, Name, ID & Name, etc… Without optional parameters (Hello C# 4.0!), I ended up with copying & pasting whole blocks of code: initializing, filtering, returning the result, error handling, etc. I wondered if there was an easier solution to that and then it hit me! LINQ & delegates!
Let’s start with a simple class:
public class Employee
{
public string FirstName { get; protected set; }
public string LastName { get; protected set; }
public int Id { get; protected set; }
//...and other methods...
}Then, we have a List of Employees:
List<Employee> Employees = new List<Employee>() { new Employee("Juan", "dela Cruz", 1), new Employee("John", "Doe", 2), //and so on... };
Now let’s try making some convenience methods for retrieving a collection of filtered Employees.
public IEnumerable<Employee> GetByLastName(string last) { IEnumerable<Employee> result = Employees.Where(emp => emp.LastName == last); return result; } public IEnumerable<Employee> GetById(int id) { IEnumerable<Employee> result = Employees.Where(emp => emp.Id == id); return result; }
Quick & easy, yes? Now what if instead of a List, our collection of Employees isn’t that stable. We’d need to put each of them in try-catch blocks and add error handling. This can quickly become high-maintenance code.
We then basically need one method that will contain all the error handling, initialization and whatnot. We just pass a delegate will filter the collection:
public IEnumerable<Employee> GetEmployee(Func<Employee, bool> query) { try { //initialization IEnumerable<Employee> result = Employees.Where(query); return result; } //handling other exceptions... catch (Exception ex) { //Error handling return null; } }
Did you notice: Func<Employee, bool>? All we need is to pass an expression that uses the Employee as input and returns a boolean (true if it passes the condition or false if not).
What does this mean? Well, we can now replace the convenience methods we wrote earlier with this:
public IEnumerable<Employee> GetByFirstName(string first) { Func<Employee, bool> query = emp => emp.FirstName == first; return GetEmployee(query); } public IEnumerable<Employee> GetById(int id) { Func<Employee, bool> query = emp => emp.Id == id; return GetEmployee(query); }
We’re back to code that’s easy to maintain with all the initializations, error handling and other code blocks that you need.
You could even do away with the convenience methods and use lambda expressions all the way!
GetEmployee(emp => true); //get everything GetEmployee(emp => emp.LastName.Contains("Locs")); GetEmployee(emp => emp.FirstName == "Richard" && emp.LastName == "Locsin");
Have fun!
Related resources:
Just something I said a while ago to Oyen on drawing...something I have to keep in mind myself.
Don't censor what you think. Don't throw away any ideas, just sort and archive. No matter how bad you think you draw, just do it. Pick up styles that you like and try to copy them. Explore other styles & copy them again. Along the way, you'll keep a certain style that's uniquely you.
I should really be carrying my Moleskine notebook and a few pens around...
Braid is finally out on the PC. Jonathan Blow is working on some bugs. AAAAND there's the official release of the Braid Soundtrack, and a Level Editor!
Soundtrack
The Braid Soundtrack is available on Magnatune with two remixes of songs from the game (Maenam and Undercurrent by Jami Sieber, Jon Schatz remix)! The soundtrack itself is amazing. You can stream the music and listen if you don't believe me.
Level Editor
To get the level editor on Braid, add a "-editor" argument when running the game and press F11. The interface might be a little confusing but fortunately, documentation will be released soon:
Yeah, after I get a new version out in a few days that fixes the problems some people are having, and when more people have played/finished the game, I am going to post some documentation for the editor. The way it works is you can make levels with the editor (up to a full game, potentially) and run that with -universe later... also a tool will be released that lets you take Photoshop files and import them into the game, if you want to put new graphics in your levels.
Now that the "what if" there was a level editor has been fulfilled, we can expect user-created "what ifs" in the coming months, weeks, ...or even days? I'm excited :D
[gallery]I just love the Quick Launch toolbar since it provides easy access the usual programs and folders I use without much clutter on the taskbar. No Shaking Required In my previous post, I also mentioned that the Aero Shake seemed impractical for non-touch/pen input. I guess Microsoft's answer to that is the shortcut: [Win+Home]. (#3) Hide and Go Peek When on keyboard intensive tasks such as writing and coding, I hate to move my right hand and reach for the mouse. Good thing there's [Win+Space] that reveals the Destkop like Aero Peek (#17), and [Win+1], [Win+2], ...[Win+5] for quick access to the first 5 items on the taskbar (#11), and [Win+T] to shift focus to the taskbar (#21). (Note: [Win+T] works on Vista, too) Still More? These are just my favorite "secrets" from what Tim Sneath posted. I can't help but wonder what Microsoft is intentionally hiding from us, especialy after reading this from the Windows 7 Beta 1 review on TechRadar UK:
- Right-click the taskbar, choose Toolbars / New Toolbar
- In the folder selection dialog, enter the following string and hit OK: %userprofile%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch
- Turn off the “lock the taskbar” setting, and right-click on the divider. Make sure that “Show text” and “Show title” are disabled and the view is set to “small icons”.
- Use the dividers to rearrange the toolbar ordering to choice, and then lock the taskbar again.
The beta is feature complete; although there are "a couple of things that we're holding back", according to general manager Mike Ybarra. ... "all of the code is in the build, just the discoverability is not." ...Very Interesting...