Ancient Brain
  
Drag the background!
 

Step 10. Make the object move

We want the object to move on every time step. So we must now define "AB.world.nextStep".

Insert the following code at the end of the program. (Remember the program structure.)

AB.world.nextStep = function()
{
    theobject.position.x = theobject.position.x + AB.randomIntAtoB ( -30, 30 );        
};


Change the movement

  1. The above code makes a random move in the x dimension on each step.
  2. Change the code to make larger or smaller moves.
  3. Change the code to move smoothly in one direction.

  4. Change the code to make moves in 3 dimensions using:
     theobject.position.y 
    and:
     theobject.position.z 
The background is a program, showing the JavaScript graphics used on this site.
The globes light up when you log in. Drag the background to move the camera.
Customise background:  
Font:

Website © Ancient Brain 2025.
Users retain ownership of user content.

Platforms      Stats      The name      Terms and conditions

Call for partners      Contact

Call for partners!
Ancient Brain is looking for a partner to co-write a JavaScript coding book for schools, to be used worldwide. This would be a course for students in learning to code from scratch. The book and course will be integrated into the Ancient Brain site. This is an opportunity for someone looking to develop a course and textbook to partner with a site to promote it. Read more.