Contains flow control, messaging, looping, variables, and conditionals.
each frameframeelapsedsettoupdatetoloop overbroadcastmessage with datawhen I receive messagewith dataififelseifthenelselogAskand store answer asignore blockscommentalert
Sprites
Sprites are images or shapes that can have momentum and heading direction applied to them for animation and games.
sprite withaccelerate byset velocity toget velocityget speedget X velocityget Y velocityget X positionget Y positionrotatebyrotatetodegreesmovemove todrawapply forcebounce at edgewrap at edgestop at edgeis collision
Sound
Play and manipulate existing sound files or synthesize new sounds.
Images are pictures loaded from the web. They can be positioned and resized.
image from urlblank image with widthheightimage widthimage heightsetwidthsetheightscalebyflip horizontalflip verticalflip bothsetsizedrawatdraw on
Math
In addition to performing math on numbers you can also use many operations on arrays and vectors too.
as number+−×÷=≠<≤>≥modulusroundabsolute valuesign offloorceilingto the power of
square root ofcube root ofroot ofto degreelogarithm ofto basemaxminsinecosinetangentarcsinearcosinearctangentpietaudegrees to radiansradians to degrees
Random
There are many types of randomness in Waterbear.
random floatrandom int fromtonoise from xyzrandom 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 xyvector at anglemagnituderotatetodegreesrotatebydegreesdegreesmagnitudexy×+normalizerandom unit vectorfrom arrayrandom pointunit 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 fromvalue ofkeys from
Strings
Strings are simple bits of text. You can search them, combine them, and break them up.
convertto string
spliton separatorconcatenatewithrepeattimes
get characterfromget characterfrom end ofsubstring ofstarting atof lengthsubstring offromtois substring ofposition ofininreplacewithtrim whitespace ofconvert to uppercase
convert to lowercase
matchesdoesn't matchstarts withends with
The blocks below are for writing your text to the screen.
fontalign text to thetext baselinefill textxyfill textxymax widthstroke textxystroke textxymax widthwidth of text
Shapes
Shapes are pictures made by drawing a geometric shape rather than loading an image file.
draw the shapeline widthline cap styleline join stylecircle atradiusellipse athorizontal radiusverticle radiusrotationrectangle atwidthheighttriangle with points abcpolygon with pointsregular polygon atsidescorner radiusstar atpointsinner radiusouter radiusline fromtoarc with radiuscentered at pointstart angleend anglebezier curve fromtofirst control pointsecond control pointquadratic curve fromtocontrol pointclip withpathtype
last point
bezier point at positionstart pointend pointfirst control pointsecond control pointtangent to bezier curve at positionstart pointend pointfirst control pointsecond control point
Rects
It turns out to be frequently useful to be able to represent a rectangle.
xywidthheightpositionsizefrom arrayposition ofsize ofx ofy ofwidth ofheight of
Input
Programs can get input from the mouse, touch, key presses, and more.
Pointer xPointer yPointer Down KeyPressed?whenkey pressedwhen pointer pressedwhen pointer releasedwhen pointer moves
tilt direction
Geolocation
Where in the world is your progam running?
my current location
when my location changesmy current locationlatitude oflongitude ofaltitude (m) ofdirection from north ofspeed (m/s) of
Sizes
A size captures both width and height in one convenient package.
size from widthwidth unitsheightheight unitssize from arraywidth unitsheight unitswidth from sizewidth unitsheight from sizeheight unitssize as arrayWorkspace