You should have a look at termping, if you haven’t yet.
But this prototype runs in your system’s terminal
One thing that I just feel, I am getting good at is “reading and understanding other people’s code” #notprasingmyself
In this summer I have explored unlimited repository out there on GitHub. some for solving any kind of issues I was facing in using them or some for just sake of learning anything new, be it any new language(Ruby) or a new field(Vim) for me.
One interesting recap is that I was working on a project for my team(SDSLabs) and I was using a ruby library as HTTP client, Rest-Client. I started facing issue(obviously) as I was new to Ruby. So I started reading code of Rest-Client just to take a look that what are the ingredients and their quantity in this library.
finally I completed Rest-Client with a better understanding that solved all my issues with it and gave me introduction to a new field, which is : > How does HTTP and REST clients works
Also while learning about the large world of Vim, I started developing on a rough idea in my mind. which was to develop a Pong like game, playable in Vim editor itself. I tried it, under the name of vingvong.. But I was unable to complete it because Vim does not support Asynchronous subprocesses, so I stopped the development.
May be you have any other way of implementing same or I’m wrong somewhere. If so, please let me know.
In the same mission, one day I was going through project nshell of one and only visionmedia. I selected this repository because I recently developed an interest in bash, shells and dotfiles management.
Before that day, I have seen many people starring the stream-handbook in my GitHub feed. But I was like this thing does not belongs to me, right now.
But that day I opened stream-handbook with a motive to learn something. I started reading it and found that Streams is a nice topic to learn.
Suddenly my mind searched something from it’s index and showed me result in form of an idea. It was : > Why don’t you just restart that Pingpong thing with this Stream ?
That’s all I wanted.
when I started thinking about Developing, shaping it as a Node Module was the only and right option. I knew already that writing a Node Module in CoffeeScript is both fancy(for world) and easy(for me).
I was a cool opportunity to learn and do more things in CoffeeScript, so finally I was like : > OK, lets move with CoffeeScript.
One coolest thing is that for CoffeeScript, I have only used The Little Book on CoffeeScript, no StackOverflow here.
The current version of termping is open-sourced at GitHub, feel free to contribute to it.
Now I’ll try to explain Source Code of termping.
Here is the current file structure of the repository, once you browse it.
. |__.npmignore |__src | |__objects.coffee | |__game.coffee | |__movement.coffee | |__status.coffee | |__source.coffee |__Cakefile |__bin | |__termping |__package.json |__.gitignore |__README.md |__docs | |__termping.gif
PS : this tree structure is generated from treegen, my own attempt as the alternative of the great
you can see, main things are inside
Object class keeps the game objects, including ball, paddle and data to be rendered on screen. It also helps to populate the data initially according to terminal size.
Game class combines all available things at one place and makes it possible to play the game. It also invoke things in other classes on some particular events like left/right or SpaceBar key press, that enable pause/resume or movement of paddle.
Movement class handles all movement related things. Ex. moving of user’s paddle, movement of ball, movement of computer’s paddle and one most useful thing Collision Detection.
status.coffee carries all variable and their values that different classes use throughout the game. which includes, velocity of ball, paddle positions, ball positions, state of game etc.
Source class is leading character in the movie. This is the place where all that Stream thing shows the magic. What it does is to pipe the data to the stdout that is to be rendered on screen. That’s why I named it as Source. Other classes just work together and periodically update the data.
finally the thing is that, was this all worth doing ?
Answer is : Obviously, Yes. It’s always good to be pragmatic.
Extra learning just means, things that I explored while developing it.
termping is still not complete, what you can contribute is :
I am not directly writing any more code to it right now, because I have to get involved with some other necessary things, but I will try to helps anyone interested.
It was a great journey so far, with nice learning experience.