next up previous contents
Next: Keyboard Shortcuts Up: JavaCarrots 1.0 - User Previous: The Properties Window

The Scripting Language

The JavaCarrots scripting language supports the following commands:


The JavaCarrots scripting language is perhaps the most important ingredient to making a successful game. By combining the scripting commands together in the right combinations, it is possible to execute animations or implement game logic. For instance, the following script shows how to make an object named ``bunny'' in the document jump when clicked and eat a carrot when fed:

		      * Sample Bunny script.

		     /* The bunny jumps when clicked. */
		     on click
		         move bunny 9 -28  delay 100
		         move bunny 9 -20  delay 100
		         move bunny 9 -12  delay 100
		         move bunny 9  -4  delay 100
		         move bunny 9   4  delay 100
		         move bunny 9  12  delay 100
		         move bunny 9  20  delay 100
		         move bunny 9  28  delay 100;

		     /* The bunny eats any carrot dropped on it. */
		     on drop carrot
		         setimage bunny eatingbunny.gif
		         delay 1000
		         setimage bunny normalbunny.gif;

Note that the final semicolon is not necessary as the semicolons serve only to separate clauses.

JavaCarrots 1.0 by Chuong Do and Xinan Wu