Keyboard Movement

Mindtools Home

Home
Getting Started
Building Programs
Appearance and Terrain
Keyboard Movement
Modelling
Fish and Plankton
Tasmanian Devil Model
Science Teachers
Other Links

Flash Player

This site makes use of the Macromedia Flash plugin to display videos.

Click here to download the Macromedia Flash player.


Video Tutorials

Wherever you see the eye icon on this site,
it is a link to a video tutorial.

 

  Using Starlogo TNG you can create keyboard controlled movement very simply.

We will look at two types of movement - First Person 3D movement, where you move forward using the up arrow and steer left or right using the left and right arrow keys, and 2D movement, similar to that used in 2D games like Pacman.

First Person 3D Movement

Start off by creating a procedure for movement.  This is what we want in the Turtles area:

Look at the video if you are not sure how to build it.

Setup SpaceLand

We need to ensure that SpaceLand is clear and only has one turtle.  Do this by creating a Setup block as below in the Setup workspace.

Create a Runtime Button and Test

Next we will move to the Runtime area and create a button to run our move procedure.

Add in the following:


2D Movement

In 2D movement the turtle moves up, down, left or right depending on which key is pressed, similar to the way a Pacman character is moved.  We do this by setting the heading for the turtle.  Heading directions can be seen in the diagram below.

To create 2D movement, change the Move procedure from above (leave everything else the same) to the following:

Create a very simple game using keyboard movement. 

Back ] Up ] Next ]


This page has been produced by Margaret Meijers.  Questions concerning its content may be directed by email to margaret.meijers@education.tas.gov.au.  This page was last modified on Monday, 23 June 2008. The URL for this page is http://www.mindtools.tased.edu.au/starlogo_tng/keyboard_movement.htm .

 Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.
Attribution should include the statement: "This has been adapted from a resource originally created by Margaret Meijers at http://www.mindtools.tased.edu.au"