Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Introduction to JavaScript and Ninja Game | Basic Controls
Ninja Game
course content

Course Content

Ninja Game

Ninja Game

1. Basic Controls
2. Functions
3. Loops
4. If-Else Statements
5. Challenges

book
Introduction to JavaScript and Ninja Game

What is Ninja Game ?

Welcome to the exciting world of the Ninja Game! This game is a fun and interactive way to learn programming concepts using JavaScript. In this game, you will control a ninja character who moves around a grid, picking up and placing sushi. Your task is to guide the ninja using JavaScript code to complete various challenges.

To get started, let's explore the basic controls of the ninja. You can move the ninja in four directions: right, left, up, and down. The methods to control these movements are goRight(), goLeft(), goUp(), and goDown(). Additionally, the ninja can interact with sushi on the grid. You can use pickSushi() to pick up sushi and add it to the ninja's inventory, and putSushi() to place sushi from the inventory onto the grid.

Now, let's see an example of how you can guide the ninja using these methods. In the following code, the ninja moves down three times and picks up a piece of sushi:

js

ninja.js

html

index.html

js

preset.js

copy

Now, try it yourself.

Task
test

Swipe to show code editor

Goal: Collect all sushi.

Write code in the code editor to move the ninja around the map and interact with sushi. Run the code and watch ninja follow your instructions. You can view starter map below task or run code in the editor to see the map.

Use the movement methods (goRight()) and the sushi interaction methods (pickSushi()) to complete the task.

Solution

Starter Map

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 1
js

ninja.js

html

index.html

js

preset.js

toggle bottom row

book
Introduction to JavaScript and Ninja Game

What is Ninja Game ?

Welcome to the exciting world of the Ninja Game! This game is a fun and interactive way to learn programming concepts using JavaScript. In this game, you will control a ninja character who moves around a grid, picking up and placing sushi. Your task is to guide the ninja using JavaScript code to complete various challenges.

To get started, let's explore the basic controls of the ninja. You can move the ninja in four directions: right, left, up, and down. The methods to control these movements are goRight(), goLeft(), goUp(), and goDown(). Additionally, the ninja can interact with sushi on the grid. You can use pickSushi() to pick up sushi and add it to the ninja's inventory, and putSushi() to place sushi from the inventory onto the grid.

Now, let's see an example of how you can guide the ninja using these methods. In the following code, the ninja moves down three times and picks up a piece of sushi:

js

ninja.js

html

index.html

js

preset.js

copy

Now, try it yourself.

Task
test

Swipe to show code editor

Goal: Collect all sushi.

Write code in the code editor to move the ninja around the map and interact with sushi. Run the code and watch ninja follow your instructions. You can view starter map below task or run code in the editor to see the map.

Use the movement methods (goRight()) and the sushi interaction methods (pickSushi()) to complete the task.

Solution

Starter Map

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 1
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt