Javascript Snake Game

This is a very simple snake game written by me. It has been entirely written in javascript.Please send in some comments and suggestions if you like it .

Click on Start Button. Use Arrow Keys to navigate.



Score:0
Copyrights 2006 -2019 Ashish Patil [ashishware.com]. Permission granted to use/modiy this script for any reason with following RESTRICTIONS:
1] You WILL RETAIN this original notice.This notice should be also included in derivative works
2] You will include a notice on the page running this script which says "Copyrights 2006 Ashish Patil [http://ashishware.com]"
3] The page running the script should have link to http://ashishware.com.

Running Linux on Windows Like Normal Programs

Using small Linux distro like Puppy Linux and open source emulator like QEMU, it is possible to run and stop Linux like normal windows programs. By creating virtual hard disks and using software like WinImage you can actually transfer data between Linux and Window. You can also create a virtual network between Windows and the guest OS for sharing and transferring files. And not to forget SAMBA in this context.

Screenshot of Puppy Linux

About Puppy Linux

1. Its small size 60-70 MB with full fledged GUI.
2. Rich collection of software like text editors, Mozilla, multimedia players ,ghostscript and support for networking.
3. Nice GUI tools for performing common and configuration tasks. This is something which windows users are very used to.
4. It even has a small web server and Tcl/Tk.

About QEMU

QEMU is an open source and fast emulator. The best thing about it is size (only 6MB).Though for now windows port is in alpha stage, it rocks. I like its simple command line interface for starting.

Getting Started

First download QEMU for Windows (Alpha)and unzip it to some directory.QEMU comes with a demonstration Linux distro image. Open the qemu-win.bat file, you see the following:

1
2
3
4
5
REM Start qemu on windows.
@ECHO OFF
START qemu.exe -L . -m 128 -hda linux.img -enable-audio -localtime
CLS
EXIT

Now download puppy Linux from any of its sites. I downloaded puppy-1.0.3-mozilla.iso which is about 62 MB in size. It has Mozilla as default browser. Copy it to same directory as qemu-win.bat file. Modify the qemu-win.bat file to:

1
2
3
4
REM Start qemu on windows.
@ECHO OFF START qemu.exe -L . -m 128 -hda linux.img -cdrom puppy-1.0.3-mozilla.iso -enable-audio -localtime -boot d -user-net
CLS
EXIT

Hey! you have a full fledged Linux system running inside windows.

Starting Network

At the Puppy Linux shell type the following:

1
2
#dhcpcd eth0
#ifconfig

Get the address for eth0 of emulator.I always get the address for eth0 as 10.0.2.15 .On your windows machine you can get your ip using ipconfig (say it is xxx.xxx.xxx.xxx).From Puppy Linux shell type:

1
#ping xxx.xxx.xxx.xxx

If it is successful, start Mozilla and point it to some site on your IIS web server (Assuming you have one or else install one). In the screen shot you can see a site hosted on IIS server being accessed with Puppy Linux running Mozilla. By enabling directory browsing of the site you can even share files between both operating systems. Below is screenshot of Mozilla on Puppy displaying a page hosted by IIS on Windows 2003.

Enabling Sound

Enabling sound is also very easy.QEMU supports SB16 emulation .This is something I like about running Linux on QEMU , no problems with sound card .But Puppy could not detect sound card by itself. I used help documentation accompanying with puppy was of great help. Make sure you started QEMU with ‘audio’ option.

1
2
3
4
#cd /lib/modules/2.4.27/sound
#ls
#modprobe -v sb
#lsmod

You should see following entries in output of lsmod

1
2
3
sb
sb\_lib
soundcore

I just put a simple audio file on my web server and pointed Mozilla to the site. From directory listing you can save the file and/or play it using gxine. Below is screenshot showing gxine playing a wave file. The sound may be quite squeaky though ;-)

Transferring Data using Virtual Hard disk Images

If you are a samba fan then you should definitely try installing and running samba with QEMU+PuppyLinux. Another nice way of sharing data between host and guest OS is using ‘disk images’. QEMU comes with a utility qemu-win.exe which can convert different types and sized virtual hard disks for use with Puppy Linux .I could successfully create qcow and raw formatted disk images. The advantage of qcow format is its small size which grows as you write to it. The advantage of raw format is that you can format it and use with a program like WinImage.Now comes the question of accessing this data .WinImage is an excellent program for this. It can even write(inject) files into a (raw formatted) virtual image files with FAT. Then I used FreeDOS floppy image and QEMU to format it to FAT16. Now you can use such a hardisk as ‘hda’ or ‘hdb’ of QEMU , mount it on puppy Linux and save data on it.

Doing More interesting things!

There are many more interesting things still you can try out. Firstly you can try out samba and experiment using OpenVPN(QEMU TAP version). There are many additional packages called dot-pups available for Pupply Linux here.I think combination of QEMU and Puppy Linux is just the perfect combination for small Linux that runs inside windows like normal programs. Moreover the executables for QEMU and Puppy Linux ISO occupy just around 70 MB of disk space and give you a full fledged Linux system with GUI and networking. This combination I think will be very helpful for those interesting in making small Linux distro ,students and hackers.

Puppy Linux download
http://distro.ibiblio.org/pub/linux/distributions/puppylinux/

Puppy DotPups
http://www.goosee.com/puppy/wikka/DotPups

WinImage
http://www.winimage.com/download.htm

Puppy Home Site
http://www.goosee.com/puppy

QEMU for Windows TAP patch
http://www.h7.dion.ne.jp/~qemu-win/

QEMU with OpenVPN
http://www.h7.dion.ne.jp/~qemu-win/TapWin32-en.html

Transliteration Tools for Indian Languages

Do you frequently type Marathi or Hindi using English alphabets . Ever wished you could write your stuff in Devanagari , without much hassles, then you should definitely read this.Transliteration is process of converting letters of one language to their phonetic equivalent representation in another . In simple language if you type ‘Kaise ho‘ you should get ‘कैसे हो‘ . Imagine how easy and fast it would make typing your mother tongue .

  • kaay kam karato = क्या काम कर रहे हो
  • kyaa chal rahaa hai = क्या चल रहा है

If you ever tried writing in Devanagari into your text editor then you must be very well aware of special fonts that one has to install on his/her machine. Also the person who reads your document should have same fonts installed. This can be a bit of pain. Well, this is the older way, before Unicode existed.

So what is Unicode ?

Unicode is an encoding standard for characters, that gives a unique number to every single character in every single language. It is consistent across all platforms and operating systems. It means if I write something in Unicode and email it to a friend using Linux, he will be able to read my message, without having to install any special software. This is because most modern operating systems and software libraries have inbuilt support for Unicode. To find if your system is capable of showing Unicode stuff visit this link , you should see something meaningful.Let me tell you, thought Unicode is universally supported these days , you need at least one Unicode complaint font like ‘Mangal’ or ‘Arial Unicode’ installed . Generally such a font is bundled with operating system , very rarely need should arise to download them separately.Okay lets get to business. The following are a few well known software packages that perform transliteration.


Google Input Tools

By far, the most popular and convinient online transliteration package. Supports many Indian languages and has already been integrated into Google’s online product ecosystem. You can try it here http://www.google.co.in/inputtools/cloud/try/ .

There also exists an desktop version of the tool in form of Google Input Tools for Windows . These are basically IMEs (Input Method Editor) for Indian languages available for many Indian languages. Once installed an IME can be basically used with any program you want like messengers,browsers, text editors etc.

ITRANS

ITRANS is a well known old transliteration software. It works with special Indic fonts which the user has to download before using it. It is no longer under active development. The reason is UNICODE. But if you are using older system then you may want to have a look at it. ITRANS provides transliteration for Devanagari (Sanskrit/Hindi/Marathi), Tamil, Telugu, Kannada, Bengali, Gujarati and Gurmukhi. The very first thing you will want to look before using it is the ‘Transliteration Map’. It shows you which letters in English will produce what output in Indian languages. There is an online interface for ITRANS , which was not working at the time of writing.

JTRANS

JTRANS is a package similar to ITRANS , but has been written in javascript. So you can download it and use it offline.It also makes use of special fonts (instead of Unicode) for output. The online interface for JTRANS works really well and you should try it after installing required fonts.

INDIAN LANGUAGE CONVERTER

You all will like this , because it supports Unicode. So you don’t have to have any special fonts installed . Just following this link . Now, there’s a small problem. I couldn’t get it working on IE , but it works just fine on FireFox. On more small problem I noticed was, I couldn’t see joined words properly.For example for ‘kra’ I was expecting the output क्र , but end up getting क् and र seperately. This problem seems to be of FireFox or rather of ‘FireFox for windows’. If you copy the hindi text for ‘kra’ and paste it in Microsoft Word you get correct letter! If you are interested to know how ‘joins’ are rendered in Indic languages read this. On this page search(Ctrl +F) for “half forms” of Devanagari letters and read the answer to the question. The FAQ is very interesting.

Indian Languages Type Pad

A cool transliteration software entirely written in javascript by Vishal Monpara. It offers transliteration in quite a few Indian languages. It integrates into your existing web applications effortlessly. Just add the following HTML to your webpage:

1
2
3
4
5
6
7
8
<input type="button" value="Type Hindi" 
onclick="win = window.open('','Comment',
'toolbar=0,menubar=0,location=0,width=560,height=590');
win.document.write('<script language=\\'javascript\\'>
var id=\\'TEXTAREAID\\';</script><script
src=\\'http://demo.vishalon.net/HindiPad.js\\'
language=javascript></script>');
win.focus();">

You can also check out an online demo on his site here. The best part is that this is a free software.

Baraha

Baraha is nice source for Transliteration tools. This site offers you a complete IDE for composing Indian Language documents , which can be downloaded here. I haven’t tried it out though. BarahaIME is very interesting, it is an Input Method Editor which works with Windows. Once you install it , you will see a small icon to right of your taskbar. Now start any editor or program . Click on taskbar icon and select the Indian language of your choice and just start typing into the editor/program. One important thing here, if you see some meaningless characters as you type change the font of the editor to a Unicode complaint one. IMEs are a great way of transliteration as it allows you to use multiple languages simultaneously. For example you can chat with someone in Hindi in one window and Kannada in another one.

Menu that appears on clicking on BarahaIME taskbar icon

Typing Indian language text directly into messenger using BarahaIME

iLeap

iLeap is from CDAC ! You might have used it . I have tried the older version . Hope the newer versions support Unicode and don’t rely on special fonts.You can download iLeap from this site . Ileap is the only true ‘editor’ for Indic languages . I would really love to see Unicode support.If anyone has any news on this please write a comment.

Vachak

Vachak is a Indian language Text to speech software . An impressive online demo is available here, which performs transliteration as well as text to speech ! Don’t miss this one.

KICKKEYS

I just found this tool from the internet . I haven’t used it, yet . If you know anything on this please inform me http://www.kickkeys.com/

More !

Implementing a transliterator is not very difficult. If you have descent knowledge of a programming language and have a descent transliteration map at hand, you can make your own transliterator (as I did sometime back). I prefer transliteration to onscreen keyboards.People tend to expect a lot from transliteration , then often confuse it with ‘translation’.I see transliteration as an effective method on inputting ‘Unicode text’ . It can work wonders if used in mobile phones ,handhelds and instant messengers. If you know of more such tools , do post a comment .

How to use my album script on your website

I assume you have very basic knowledge of HTML. There are quite a few steps to be followed:


1] Download the zip archive from this location and unzip it to a folder.

2] Get all your images into the ‘hh’ folder. You will have to resize all images to 640*480 for displaying. Also thumbnails of 100*75 are required. Put the thumbnails into same directory with a different name. You can use GIMP to do the job of creating thumbnails and Picassa to resize images to 640*480.

3] Once you have thumbnails and images, the fun begins. Now you need to get a Google Map key. Visit this site and register to get your 86 charactor Google Map Key. Edit the photoalbum.html page and replace the #######… in first <script> tag with your google map id.

4] Open the images.xml file in notepad or any XML Editor. It is this file that contains all important information. To find latitude and longitude you can search for the place in wikimapia. Move the desired location to the center of the screen for maximum accuracy. On the address bar you should be able to see something like http://wikimapia.org/#y=17991438&x=73027003&z=17&l=0&m=a . You can get the coordinates from this query string. Here latitude of place is 17.991438 and longitude =73.027003 . If you see closely you can even get the zoom !(z=17). Enter one tag for each image . Make sure that you entered the right paths for images and thumbnails. An example file is given here:

1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="images.xsl"?>
<images>
<image>
<path>hh/IMG\_3099.jpg</path>
<tmbnail>hh/IMG\_3099\_t.jpg</tmbnail>
<lat>17.991846</lat>
<long>73.027411</long>
<caption>Nice big mushrooms in the garden.</caption>
<tooltip>Somewhere here (I think!)</tooltip>
<zoom>17</zoom>
</image>
</images>

5] Do not enter any special charactors or line breaks into the text inside <caption> and <tooltip> tags. Right now the script is unable to handle it and produces errors.

6] Now upload all the files to your website , simple access the photoalbum.html file and your album should be working ! You can comment on this using email address specified in the FAQ section of the website or drop a comment.