A Sprite Editor in One line of code?

If you search on the Internet, you will find many claims that have the silver bullet, where you can do miracles, walk on water, etc all in one line of code. Where as the same would have taken like 100's of lines of code in C/C++ or Objective-C type languages. So what is the truth of these miraculous claims, can you do miracles in one line of code?

Short answer, YES, you can perform miracles in one line of code. To illustrate this, can you play an entire orchestra piece yourself in front of a live audience while standing on stage looking pretty and not moving your lips? Difficult, eh? But... you can record yourself playing each instrument in the Orchestra separately, then compositing them together, making a recording which you can then play on a live stage in front of an Audience and stand looking pretty. Cheating, you call it? Think again... you have done all of that, so how is it cheating?

It is the same when it comes to the claims of one or few lines of code. There is a whole lot of stuff that is done behind the scenes that you are oblivious to and what you get is the entire orchestra in one line of code. So is it fair in slamming other languages that actually help build this, absolutely not. They serve their purpose. I saw this recently in a movie, where the person asked the hero, What would you like to do, Look at the plated excellence that you have in front of you in a fine dining restaurant, or go to the kitchen and see it made but then never be able to enjoy this meal again? You might not want to get your hands dirty with the intricacies of Objective-C or C++ libraries, but you would want to enjoy being able to use them.

For the sake of this article, I tried writing a SpriteEditor Demo (which I *might* expand as a tool, time permits). The idea behind is simple, you can create a board in the size you want, you can set the width and height and the square size. Clicking on each square toggles the square. Simple as that. Now creating this is not going to be easy, is it? At least not in one line of code, guess again

require("spriteEditor")

newBoard(10,10,15)


well you might call that two lines, but then you have to have an include statement, the way the newBoard works, is it takes the Width, Height and the Size and creates a board accordingly. So this code above will create a board 10 wide, 10 high and each square size is 15 pixels. Here's a screenshot of it in action.


Yes, One line of code and it caters for all touches, toggling of the squares when touched, etc.

NOTE: This is lua code but will *currently* work only for GiderosStudio not any other framework.



So while you can buy all sorts of miracle cures, you can also note that there is no such thing as a Free Lunch, even Free Beer is not really FREE, or all the developers would be drinking it rather than kool-aid. So when you make a decision based on how easy things are, please note that easy or difficult is all a very relative term. Duplo blocks can connect only one way as they are meant for kids and not to confuse them, then Technic blocks can connect in many ways because they are not meant for kids. So easy might be abstracting a whole lot of features from you and offering you the kiddie version like in a sandbox. Ultimately, you need to decide as to do you still want to play in the sandbox or out on the field? Choose a framework that allows you to work with it the way you want, down to the bare-bones if you need to or high up with the sandbox if required as in this demo example.

If you want to try using this SpriteEditor in your projects, please let me know, I can make this a control that you can drop into your projects and have a sprite editor. Also if you want certain features to be included, let me know.

You can give GiderosStudio a try by downloading a demo version from their site at http://www.giderosmobile.com/ They have a fully functional FREE license for those test drivers that want to publish their apps and do not mind having a Splash Screen at the start. They have offline compilation, so you can export to xCode and compile on your computer and they do not bar or cull subscriptions on their whims and fancies. It even works on WINE on a *nix box.

Comments

Popular Posts