Waterbear Playground

Controls

Contains flow control, messaging, looping, variables, and conditionals.

each frame frame elapsed set to update to loop over broadcast message with data when I receive message with data if
if
else
if then else log Ask and store answer as ignore blocks comment alert
Sprites

Sprites are images or shapes that can have momentum and heading direction applied to them for animation and games.

sprite with accelerate by set velocity to get velocity get speed get X velocity get Y velocity get X position get Y position rotate by rotate to degrees move move to draw apply force bounce at edge wrap at edge stop at edge is collision
Sound

Play and manipulate existing sound files or synthesize new sounds.

synth wave attack release audio note octave beats play chord synth note octave play audio play notes synth mml set tempo pause keys synth sound effect
Arrays

Arrays are lists of things. You can add, remove, and loop over these lists.

create array copy array item from at index combine with Make string from separated by append prepend length remove item at remove last value remove first value reverse
Boolean

Booleans are either True or False. There are many operations for comparing and mixing them.

true false and or xor not
Date

Dates are used to represent a date and to do basic calculations.

today yyyy mm dd date +/- days date +/- months date +/- years get day of week get day get month get month by name get year
Stage

Stage is the area where scripts are performed.

clear to Stage Width Stage Height Center x Center y Center point Random x Random y
Colors

There are several ways to specify colors.

red green blue red green blue alpha grey hue saturation lightness hue saturation lightness alpha fill style stroke style shadow color shadow blur
Images

Images are pictures loaded from the web. They can be positioned and resized.

image from url blank image with width height image width image height set width set height scale by flip horizontal flip vertical flip both set size draw at draw on
Math

In addition to performing math on numbers you can also use many operations on arrays and vectors too.

as number + × ÷ = < > modulus round absolute value sign of floor ceiling to the power of square root of cube root of root of to degree logarithm of to base max min sine cosine tangent arcsine arcosine arctangent pi e tau degrees to radians radians to degrees
Random

There are many types of randomness in Waterbear.

random float random int from to noise from x y z random item from
Vectors (Points)

Waterbear vectors are x,y coordinates that can be used as points, but also have a direction and magnitude (useful for speed, acceleration, distance).

vector at x y vector at angle magnitude rotate to degrees rotate by degrees degrees magnitude x y × + normalize random unit vector from array random point unit vector <1,1> zero vector <0,0> as array
Objects

Objects are general-purpose containers where you can associate names (keys) with objects (values) like in a dictionary.

empty object key with value from value of keys from
Strings

Strings are simple bits of text. You can search them, combine them, and break them up.

convertto string split on separator concatenate with repeat times get character from get character from end of substring of starting at of length substring of from to is substring of position of in in replace with trim whitespace of convert to uppercase convert to lowercase matches doesn't match starts with ends with

The blocks below are for writing your text to the screen.

font align text to the text baseline fill text x y fill text x y max width stroke text x y stroke text x y max width width of text
Shapes

Shapes are pictures made by drawing a geometric shape rather than loading an image file.

draw the shape line width line cap style line join style circle at radius ellipse at horizontal radius verticle radius rotation rectangle at width height triangle with points a b c polygon with points regular polygon at sides corner radius star at points inner radius outer radius line from to arc with radius centered at point start angle end angle bezier curve from to first control point second control point quadratic curve from to control point clip with path type last point bezier point at position start point end point first control point second control point tangent to bezier curve at position start point end point first control point second control point
Rects

It turns out to be frequently useful to be able to represent a rectangle.

x y width height position size from array position of size of x of y of width of height of
Input

Programs can get input from the mouse, touch, key presses, and more.

Pointer x Pointer y Pointer Down Key Pressed? when key pressed when pointer pressed when pointer released when pointer moves tilt direction
Geolocation

Where in the world is your progam running?

my current location when my location changes my current location latitude of longitude of altitude (m) of direction from north of speed (m/s) of
Sizes

A size captures both width and height in one convenient package.

size from width width units height height units size from array width units height units width from size width units height from size height units size as array
Workspace