// Automatically generated file. Do not edit! 'use strict'; var e=Number,f,g=window.location.search.match(/[?&]level=([^&]+)/);f=g?decodeURIComponent(g[1].replace(/\+/g,"%20")):"NaN";e(f);if(!h){var h,k="";"undefined"!==typeof navigator&&navigator&&"string"==typeof navigator.userAgent&&(k=navigator.userAgent);var l=0==k.indexOf("Opera");h={l:{g:"ScriptEngine"in window},i:l,h:!l&&-1!=k.indexOf("MSIE"),j:!l&&-1!=k.indexOf("WebKit")}}if(!m)var m={};if(!n)var n={};if(!p)var p={};if(!q)var q={};if(!r)var r={};if(!t)var t={}; function u(b){b=b.currentTarget;var a=document.getElementById(b.id+"-content"),c="zippy-content-expanded"==a.className;b.className="zippy-header-"+(c?"collapsed":"expanded");a.className="zippy-content-"+(c?"collapsed":"expanded");a.style.maxHeight=c?0:a.scrollHeight+"px"} window.addEventListener("load",function(){var b=window.location.search.match(/[?&]mode=([^&]+)/);b=b?Number(b[1]):Infinity;var a=b%2?"blocks":"js";document.body.innerHTML='

Pond Documentation

Pond

Angles

The compass is oriented so that due east (right) is 0 degrees, 90 is north, 180 is west, 270 is south. Angles wrap as expected: -90 is south, 450 is north.

Cannon

'+("blocks"== a?'

cannon(,);0\u00b070

': "js"==a?'
cannon(angle, range)
':"")+"

The cannon() function fires a cannonball towards the specified angle and range. The angle is independent of the direction of the duck. The range can be 0-70 metres, with greater ranges truncated to 70.

The cannon takes about one second to reload after firing. If cannon() is called during this time, nothing happens."+("js"==a?" cannon() returns true if a cannonball was fired, or false if the cannon is reloading.": "")+"

"+(5<=b?"

Scan

"+("blocks"==a?'

scan()0\u00b0

': "js"==a?'
scan(angle)\nscan(angle, width)
':"")+"

The scan() function activates the duck's radar. This function returns the range to the nearest opponent in the specified direction. The angle is independent of the direction of the duck. Sunk opponents are not detected. If there is no opponent in that direction, then Infinity is returned.

"+("js"==a?"

The second (optional) parameter of scan() specifies the width of the scanning beam. This can be from 1 degree to 20 degrees. Advanced players may wish to start scanning with a width of 20 for a fast scan, then progressively decrease the width to get more accuracy. If not specified, the width is 5. This parameter is only available with JavaScript, not with blocks.

": ""):"")+(7<=b?"

Swim

"+("blocks"==a?'

swim();0\u00b0

': "js"==a?'
swim(angle)\nswim(angle, speed)
':"")+"

The swim() function starts the duck moving. The duck will continue moving in the specified direction indefinitely.

"+("js"==a?"

The second (optional) parameter of swim() specifies the speed. This can be from 0 (stopped) to 100 (fast). Direction of movement may only be changed if the speed is 50 or less. If not specified, the speed is 50. This parameter is only available with JavaScript, not with blocks.

": "")+"

Crashing into the edges of the pond will damage your duck. Crashing into other ducks will damage both ducks. The amount of damage is proportional to your speed.

":"")+(9<=b?"

Stop

"+("blocks"==a?'

stop();

': "js"==a?'
stop()
':"")+"

The stop() function stops the duck from moving. The duck will take a moment to slow down before stopping completely."+("js"==a?"This is the same as calling swim() with a speed of zero.":"")+"

":"")+(9<=b?"

Location

"+("blocks"==a?'

getX()   getY()

': "js"==a?'
getX()\ngetY()
':"")+'

The getX() and getY() functions return the duck\'s horizontal and vertical positions. Values are between 0 and 100, starting from the lower-left corner.

':"")+(11<=b?"

Speed

"+("blocks"==a?'

speed()

': "js"==a?'
speed()
':"")+"

The speed() function returns the duck's current speed. Values are between 0 (stopped) and 100 (fast). This function may be used to detect collisions (which instantly stop the duck).

":"")+(11<=b?"

Health

"+("blocks"==a?'

health()

': "js"==a?'
health()
':"")+"

The health() function returns the duck's current health level. Values are between 0 (sunk) and 100 (perfect). Advanced players may wish to store the health in a variable, then periodically check to see if the health has decreased, thus indicating that the duck is under attack.

There is no way to repair health.

":"")+"
"+(3<=b?'\x3c!-- ---------------------------------------------------------------------- --\x3e

Logic

'+ (9<=b?"

If

"+("blocks"==a?'

if () {}

': "js"==a?'
if (condition) {\n  statements\n}\n\n\nif (condition) {\n  statements\n} else if (condition) {\n  statements\n}\n\n\nif (condition) {\n  statements\n} else {\n  statements\n}
':"")+"

If the condition is true, then execute the contained statements. The if may be followed by any number of other else if conditions, and at the end by an optional else condition that executes if none of the previous conditions were true.

": "")+(9<=b?"

Equality

"+("blocks"==a?'

== \u25be

': "js"==a?'
==    !=    <    <=    >    >=
':"")+"

These expressions compare two numbers and return true or false. The six available equality operators are:

OperatorExampleReturns
Equals5 == 10false
Not equals5 != 10true
Less than5 < 10true
Less than or equal5 <= 10true
Greater than5 > 10false
Greater than or equal5 >= 10false

Use of != may be dangerous if the numbers being compared are fractions. Consider this code that is designed to swim to 50 then stop:

while (getY() != 50) {\n  swim(90"+
("js"==a?", 50":"")+");\n}\nstop();

The above code will fail because getY() may be 49.4 on one execution, then 50.6 on the next execution. Since the value was not seen at exactly 50, the loop continues forever. Below is better code:

while (getY() < 50) {\n  swim(90"+("js"==a?", 50":"")+");\n}\nstop();
":"")+(11<=b?"

And/Or

"+("blocks"==a?'

&& \u25be

': "js"==a?'
&&    ||
':"")+"

'And' is represented by the && operator. It returns true only if both inputs are true. For example this code will only fire the cannon if the range is both greater than 5 and less than 70:

if (range > 5 && range < 70) {\n  cannon(angle, range);\n}

'Or' is represented by the || operator. It returns true if either input is true. For example this code will stop if the duck is close to any wall:

if (getX() < 10 || getX() > 90 ||\n    getY() < 10 || getY() > 90) {\n  stop();\n}
": "")+"

Booleans

"+("blocks"==a?'

true \u25be

': "js"==a?'
true    false
':"")+"

The value true is mainly used by the while loop to make a loop that executes forever. The value false is also available.

":"")+(3<=b?'\x3c!-- ---------------------------------------------------------------------- --\x3e

Loops

While

'+("blocks"==a?'

while () {}

': "js"==a?'
while (condition) {\n  statements\n}
':"")+"

Loops will repeat executing the enclosed statements as long as the condition is true. Thus, the following will fire the cannon west forever:

while (true) {\n  cannon(180, 50);\n}

Whereas the following will fire the canon west as long as an opponent is in range:

while (scan(180"+("js"==a?", 5":"")+") <= 70) {\n  cannon(180, scan(180"+("js"==a?", 5":"")+"));\n}
": "")+'\x3c!-- ---------------------------------------------------------------------- --\x3e

Math

Number

'+("blocks"==a?'

0

': "js"==a?'
123
':"")+"

Numbers are used for many things, including ranges, angles, and counters. Numbers may be negative (e.g. -360), or fractional (e.g. 3.14159), or very large (e.g. 9007199254740992). There is even a special number called Infinity.

Do not use thousands separators (e.g. 9,000).

"+(11<=b?"

Arithmetic

"+("blocks"==a?'

+ \u25be21

': "js"==a?'
+    -    *    /
':"")+"

These operators take two numbers and return a single number. The four available arithmetic operators are:

OperatorExampleReturns
Plus3 + 47
Minus3 - 4-1
Multiply3 * 412
Divide3 / 40.75
": "")+(11<=b?"

Trigonometry

"+("blocks"==a?'

Math.sqrt \u25be()9

': "js"==a?'
Math.operation(number)
':"")+"

These functions take a number and return a number. The eight available functions are:

FunctionExampleReturns
Square rootMath.sqrt(25)5
AbsoluteMath.abs(-25)25
SineMath.sin_deg(30)0.5
CosineMath.cos_deg(30)0.866
TangentMath.tan_deg(30)0.577
ArcsineMath.asin_deg(0.5)30
ArccosineMath.acos_deg(0.866)30.003
ArctangentMath.atan_deg(0.577)29.985

Note that these trigonmetric functions are custom to the Pond game and all use degrees. The standard JavaScript functions use radians.

": "")+(11<=b?"

Random

"+("blocks"==a?'

Math.random  (  )

': "js"==a?'
Math.random()
':"")+"

This function returns a random fraction from 0.0 to 1.0. To get a random number in a larger range, just multiply it by the maximum value. Here's an example of getting a random angle:

var angle = Math.random() * 360;
":"")+"
"+(11<=b?'\x3c!-- ---------------------------------------------------------------------- --\x3e

Variables

Assigning

'+("blocks"==a?'

varname \u25be=;0

': "js"==a?'
var name = value;
':"")+"

Assigns a value (usually a number) to the named variable. The name of the variable should be something that makes sense, such as range or angle.

"+("js"==a?"

Note that variable names are case-sensitive, thus angle and Angle are two completely different variables. Variable names must only use the English letters a-z, and numbers. Variable names may not start with a number.

The var keyword may be omitted on all but the first assignment, but there is no harm in using it.

": "")+"

Incrementing

"+("blocks"==a?'

name \u25be+=;1

': "js"==a?'
name += number;
':"")+"

This is a shortcut for adding a number to an existing variable. There is no difference between the following two lines:

angle += 10;\nvar angle = angle + 10;

Do not use += on a variable that has not already been defined. If in doubt, assign the variable to 0 at the beginning of the program.

Retrieving

"+("blocks"==a?'

name \u25be

': "js"==a?'
name
':"")+"

Retrieves the value (usually a number) that had previously been assigned to the named variable.

":"")+(11<=b?'\x3c!-- ---------------------------------------------------------------------- --\x3e

Functions

TODO

':"");b=document.getElementsByTagName("h2");a=0;for(var c;c=b[a];a++){var d=document.createElement("img");d.src="../common/1x1.gif";c.insertBefore(d,c.firstChild); c.className="zippy-header-collapsed";document.getElementById(c.id+"-content").className="zippy-content-collapsed";d=u;if(!c)throw TypeError("Element not found: "+c);"string"==typeof c&&(c=document.getElementById(c));c.addEventListener("click",d,!0);c.addEventListener("touchend",d,!0)}});