Coffee Coder

Shubham Jain's Weblog

Creating Side-scroller Game in HTML5 and Javascript

| Comments

Recently I completed my first game, Penguin Walk, with help of free art in Javascript and it gave me empirical experience of a known-fact surrounding game development – “The hardest thing about developing a game is finishing it.”

Although, the game is dead simple and code runs in only few hundreds of lines, it took a lot of effort to finish it. The reason? I believe the hard thing related to game development, is that you are attempting to build something complex out of very simple elements (pixels). The same reason why building a programming language is hard – you are trying to ensure that a stream of characters obeys formal grammatical rules and convert them into something that can execute. In this post, I will describe how I created my side-scroller game.

Is Game Programming hard?

Think about it. What does it take to project a bird from a slingshot, show it flying in projectile motion, hitting a set of object which are then animated to move accurately, in accordance to laws of physics? Well, a lot. You can only tell computer what to paint on the screen, rest of all the higher level abstractions, you build on your own.

Although, using a library might help a lot; after all, who can be expected to complete a desktop application if he has to program all controls on his own but if you compare the two, there are two complications that arise in game development –

Hackers Are the Real 10x Engineers.

| Comments

The notion of 10x programmer was first mentioned by John Brooks (of, Brook’s law fame) in his essay No Silver Bullet, according to which, ‘there is as much as a tenfold difference between an ordinary designer (programmer) and a great one’. The idea has been widely debated, sometimes refuted and many times defended which is unsurprising for it is impossible to accurately measure a programmer’s productivity.

Sadly, the idea of 10x coder is usually visualized as a screen glued junkie, moving fingers over keyboard without a break. While the picture may be popular for sci-fi films, it is hardly close to reality.

My Perfect Reason to Avoid PHP: Type Juggling

| Comments

If there was an award for the most hated language, the unanimous winner would be PHP. Lots of write-ups criticize it for its nonsensical function naming conventions, inconsistent parameters, sheer absence of what we call, “a well thought design”. However, people on the other side, suggest that writing good code is upto the programmer showcasing “Zend Framework”, they assert, PHP is a very reasonable language to write clean code. They say its easy to ignore the inconsistencies with a good editor or IDE and adopting good practices. True they are, I believed, until, I encountered something which is completely inexcusable, an ugly case of type juggling.

Type Juggling

Type Juggling (or, automatic type casting) is a PHP mechanism which transforms one type to another depending upon the context. As the manual explains, if you add a string to a number, the string will be type casted to a number and not the other way round which results in something like this.

20 + "10Hello World" = 30

Why Should You Use Tmux?

| Comments

Terminals are an essential place frequented by developers in their daily use. In contrast to GUIs, command line gives you more folds of power and transparency when you dealing with a complicated tool like git, or when you need to pull off some networking stats using netstat. In this blog post, I’ll explain why tmux is a great productivity enhancer when working with command line.

What is tmux?

tmux or terminal multiplexer is a simpler version of GNU screen, both of which are tools to split, combine and create terminal windows. Yes, that is indeed similar to what terminator does but guess what, you can’t run terminator on SSH, can you? but that is not the selling point here. tmux is command line based tool which is very easy to use and in fact for any beginner, a little primer should be enough to start using it to its full extent.

Using Git for Introducing Temporary Changes

| Comments

Lately, on independence day we needed to introduce a small logo change on our website to acknowledge it. The change wasn’t meant to last for more than a few days and hence, the problem of introducing a temporary change which shouldn’t be a part of the history arose. Out of ignorance, we went through the path of making a commit and later reverting it with git-revert. Recently I found about excellent patching system of git which makes an impressive solution for the problem.

Patching

Patching used in git isn’t unique. It derives itself from an old patch program written by Larry Wall in 1985. patch program is pretty simple. It takes a diff file as its input and applies those changes to corresponding files. Because of this simplicity, it makes patch files very easy to send. Perhaps, before the advent of github, they were the old man’s pull request. Another great thing about patches is that they can painlessly be reversed.

Git’s format-patch is an extension of patch and offers two advantages over it. First, it generates an email formatted patch file which is much easier to be sent via mailutils. Secondly, it supports binary diffs which means if you have a binary file which was created in the patch, git’s patch file will have record of it and it will be created when patch is applied. The best thing about git’s patching system is that it can be applied even if the folder is not a git repository, making it suitable for use over production servers.