Following are samples of JavaScript codes for certain actions used in creating a game.

1. Write an image to a particular position of the screen using Javascript:
Image is an object of a window. To display an image, you need to write an image object to screen and

2. Make an image disappeared using Javascript:
Example: click the image and it will disappear

3: Automatically move a image in a desired area using Javascript:
Moving of an image is actually changing the position(x,y) of the image. To move image in horizontal direction, you only change X; to move image in parpendicular direction, you change Y only; other situation, you can change both X and Y.
Click the image to start moving, click "stop" button to stop moving.

4. Use mouse to control the movement of a image:
Mouse actions are events and you can define functions to handle those events. In this sample, we defined an handler for onMouseMove event so that the image will move following the move of mouse. Click the image to turn the handler on and click it again to turn it off.

5. Use keyboard to control the move of an image:
Keyboard typing is another kind of event and you also can define functions to handle those events. In this sample, we defined an handler for onKeyPress event so that the image will move in different direction based on the key you type. Click the image to turn the handler on and click it again to turn it off. "i": move image up, "k": move image down, "j": move image left, "k": move image right.