MoveAvatar: Java script

The most common use of JavaScript is to write functions that are embedded in or included from HTML pages and that interact with the Document Object Model (DOM) of the page. Some simple examples of this usage are:

You are the maker of the program and which integrates data .... let's join here

  • Loading new page content or submitting data to the server via AJAX without reloading the page (for example, a social network might allow the user to post status updates without leaving the page)
  • Animation of page elements, fading them in and out, resizing them, moving them, etc.
  • Interactive content, for example games, and playing audio and video
  • Validating input values of a web form to make sure that they are acceptable before being submitted to the server.
  • Transmitting information about the user's reading habits and browsing activities to various websites. Web pages frequently do this for web analytics, ad tracking, personalizationor other purposes.





Because JavaScript code can run locally in a user's browser (rather than on a remote server), the browser can respond to user actions quickly, making an application more responsive. Furthermore, JavaScript code can detect user actions which HTML alone cannot, such as individual keystrokes. Applications such as Gmail take advantage of this: much of the user-interface logic is written in JavaScript, and JavaScript dispatches requests for information (such as the content of an e-mail message) to the server. The wider trend of Ajax programming similarly exploits this strength.


A JavaScript engine (also known as JavaScript interpreter or JavaScript implementation) is an interpreter that interprets JavaScript source code and executes the script accordingly. The first JavaScript engine was created by Brendan Eich at Netscape Communications Corporation, for the Netscape Navigator web browser. The engine, code-namedSpiderMonkey, is implemented in C. It has since been updated (in JavaScript 1.5) to conform to ECMA-262 Edition 3. The Rhino engine, created primarily by Norris Boyd (formerly of Netscape; now at Google) is a JavaScript implementation in Java. Rhino, like SpiderMonkey, is ECMA-262 Edition 3 compliant.
A web browser is by far the most common host environment for JavaScript. Web browsers typically create "host objects" to represent the Document Object Model (DOM) in JavaScript. The web server is another common host environment. A JavaScript webserver would typically expose host objects representing HTTP request and response objects, which a JavaScript program could then interrogate and manipulate to dynamically generate web pages.
var moveSpeed : float = 2; // The speed in game units that the bouncer moves per secondvar rotateSpeed : float = 90; // The rotation speed in degrees per secondstatic var moveable : boolean = true;var forwardBackward : boolean = false; // Whether we're moving forward or backwardvar goingNowhere : boolean = false; // Whether we're going nowhere or notvar jumping : boolean = true; // Whether we're jumping or not
var speed = 2.0;var controller : CharacterController;

function Update() // This function is walk once every frame{ if (Input.GetKey(KeyCode.W)) { // If the user presses W rigidbody.velocity = transform.forward * moveSpeed + Vector3(0, rigidbody.velocity.y, 50); // Set the velocity to move forward while keeping gravity if (!forwardBackward || goingNowhere) { // If we used to be going backward or not moving forwardBackward = true; // Set it so that we're going forward goingNowhere = false; // Set it so that we're going somewhere jumping = false; animation.CrossFade("run", 1); // CrossFade the walk animation over one second animation.wrapMode = WrapMode.Loop; } } else { // Otherwise if (goingNowhere == false) { // If we used to be going somewhere goingNowhere = true; // Set it so that we're going nowhere animation.CrossFade("idle", 1); // CrossFade the idle animation over one second animation.wrapMode = WrapMode.Loop; } rigidbody.velocity = Vector3.zero + Vector3(0, rigidbody.velocity.y, 0); // Set the velocity to move nowhere while keeping gravity if (Input.GetKey(KeyCode.D)) { // If the user presses W transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0); // Set the velocity to move forward while keeping gravity if (goingNowhere == false) { // If we used to be going somewhere goingNowhere = true; // Set it so that we're going nowhere forwardBackward = true; // Set it so that we're going forward } } if (Input.GetKey(KeyCode.A)) { // If the user presses W transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0); // Set the velocity to move forward while keeping gravity if (goingNowhere == false) { // If we used to be going somewhere goingNowhere = true; // Set it so that we're going nowhere forwardBackward = true; // Set it so that we're going forward } } if (Input.GetKey(KeyCode.Q)) { // If the user presses W animation.CrossFade("hello", 1); // CrossFade the idle animation over one second animation.wrapMode = WrapMode.Once; } if (Input.GetKey(KeyCode.E)) { // If the user presses W animation.CrossFade("talk", 1); // CrossFade the idle animation over one second animation.wrapMode = WrapMode.Once; } if (Input.GetKey(KeyCode.S)) { // If the user presses W rigidbody.velocity = transform.forward * moveSpeed + Vector3(0, rigidbody.velocity.y, 50); // Set the velocity to move forward while keeping gravity if (!forwardBackward || goingNowhere) { // If we used to be going backward or not moving forwardBackward = true; // Set it so that we're going forward goingNowhere = false; // Set it so that we're going somewhere jumping = false; animation.CrossFade("walk", 1); // CrossFade the walk animation over one second animation.wrapMode = WrapMode.Loop; } } if (Input.GetKey(KeyCode.Space) && jumping == false) { // If the user presses space and we aren't jumping already rigidbody.velocity.y += 15; // jump upwards animation.Blend("jump", 2, .5); // Blend the jump animation towards one blend weight over .5 (1) seconds jumping = true; // Toggle the jumping boolean on animation.wrapMode = WrapMode.Once; jumping = false; } }}

Because JavaScript is the only language that the most popular browsers share support for, it has become a target language for many frameworks in other languages, even though JavaScript was never intended to be such a language. Despite the performance limitations inherent to its dynamic nature, the increasing speed of JavaScript engines has made the language a surprisingly feasible compilation target.