cools maths gamesSurprise me

Block Code Duck Pond

Write programs that make a cannon duck scan, swim and shoot, first with blocks and then in typed JavaScript.

Block Code Duck Pond title screen
  • Partly works on mobile
Report a problem

Turn your phone sideways for a bigger view of this game.

Block Code Duck Pond is a coding game set in a pond full of rubber ducks. Your orange duck can swim, scan and fire a cannon, and you control all of it with a program. The goal is to write code that knocks out each opponent duck, first with blocks and then in real JavaScript.

How Block Code Duck Pond Works

The pond sits on the left with your duck and a rival. Health bars underneath track damage. Block levels let you snap together commands like cannon, scan and swim, and text levels have you type the same commands into an editor.

Press Run Program and your duck follows the code in real time. When the rival’s health reaches zero, you see the JavaScript behind your program and move on.

There are five challenges, each played twice. The first needs one well-aimed shot. Then come a target that takes many hits, a moving duck you track with scan, a distant duck you swim toward, a level where you stop before contact, and an opponent that runs when hit.

Your First Few Minutes

  1. Look at where the rival duck sits compared with yours.
  2. Open the Documentation panel to see the compass and commands.
  3. Drag a cannon block in and set its angle and range.
  4. Press Run Program and watch where the shot lands.
  5. Adjust the numbers, then try the typed version on the next level.

Controls for Block Code Duck Pond

Keyboard, mouse and touch controls for Block Code Duck Pond
To do thisKeyboardMouseTouch screen
Build a program (block levels)not usedDrag blocks from the Pond and Math categoriesDrag blocks with your finger
Write a program (JavaScript levels)Type in the code editorClick in the editor to place the cursornot used
Set an angle or a numberType the number and press EnterClick the value and type a new oneTap the value
Run or reset the battlenot usedClick Run Program, then ResetTap Run Program, then Reset
Look up the commandsnot usedClick DocumentationTap Documentation

What It Trains

Here you practice real coding ideas. You use while loops to keep firing and feed the result of scan into the cannon so a shot follows a moving target.

There is plenty of math too. You work out angles, where 0 degrees is right and 90 is up, and compare distances against the cannon’s 70-meter reach.

Strategy Notes

  • Sketch the angle first. Straight up is 90 degrees and straight right is 0.
  • Use scan as the range. Passing scan(angle) to the cannon keeps shots on a moving duck.
  • Loop your attack. One shot rarely wins, so wrap firing in while (true).
  • Mind your health. Bumping into a duck hurts you as well.
  • Check the docs for late levels. loc_x, loc_y, speed and health help with the last fights.

Good to Know

Block levels work with touch, but the JavaScript levels need a keyboard, so a computer is best. The typed levels have a code editor with line numbers and syntax coloring.

Block Code Duck Pond questions and answers

Do I need to know JavaScript first?

No. Each challenge appears first as a block level, and the success message shows the JavaScript your blocks made. The next level asks you to type that same idea, so you learn by comparing.

How do I win a level?

Bring the opponent duck health to zero. Health bars under the pond show how much damage each duck can still take. When you win, press OK to move to the next level.

Can my own duck get hurt?

Yes. Ramming into another duck damages you as well. That is why one level asks you to swim partway, stop and then fire instead of charging in.

How far can the cannon shoot?

Up to 70 meters in a 100 by 100 meter pond. Anything farther away has to be reached by swimming closer first.

Games that use coding like Block Code Duck Pond

Different rules, same kind of thinking.

Try something from another shelf