If-blocks Edit

An if statement is a task which can be used to select between two different values depending on a boolean. It is most commonly used to switch between code procedures. The syntax is:

boolean ? value1 : value2;

The question mark, colon, and are required syntax (a semicolon is also required, but only if there are multiple if blocks, in which case you write a semicolon for every line except the last one). The values can be replaced with whatever data you want to put in there.

When an If-statement is executed, the value of the boolean is determined and, depending on the outcome, either compile the first value or the second. Usually said values are code values (written in {}), but other values are possible as well as long as they can be compiled in the current expression. The boolean value is commonly created using logic operators and comparisons, which create a boolean value by comparing multiple values with each other and combining the results afterwards. Existing comparison operators are:

  • == — Compares both values to see if the first value is equal to the second value. This is not limited to Integers or Floats. Note: This is different from =, which assigning a value instead of comparing values.
  • >= — Compares both values to see if the first value is greater than or equal to the second value.
  • <= — Compares both values to see if the first value is less than or equal to the second value.
  •  != — Compares both values to see if the first value is not equal to the second value. This is not limited to Integers or Floats.
  • > — Compares both values to see if the first value is greater to the second value.
  • < — Compares both values to see if the first value is less than the second value.

Additionally, boolean values can be combined using logic operators in a way similar to calculation operators.

Existing operators are:

valueA && valueB && valueC… — Is true if both values are true, and false if not, a.k.a. AND-statement

valueA || valueB || valueC… — Is true if at least one value is true, a.k.a. OR-statement

! valueA — inverts the value, a.k.a. NOT-statement

Examples of IF-blocks:

sim.running && e.this.vel(0) < 4 ? {code1} : {}

This script checks sim.running, a variable created in Algodoo, which is stored as a boolean. sim.running gets combined by using an AND (&&), which makes the script also compare the x-velocity of the object and asks if the object 4 meters a second or slower in the x-axis. If both are true, then code1 gets executed, else nothing happens.

_hp <= 0 || _die ? {code1} : {code2}

first the script checks if _hp is 0 or less, and then checks if _die is true. If either is true, it will execute code1, else code2

pos = pos(0) > 0 ?  : 

Assigns either or to pos, depending on whether the x value is greater or less than 0.

Creating custom Events Edit

Since Algodoo’s events are basic functions embedded into the source code of the program, one can create their own events embedded into the pre-existing events algodoo provides. A common use of this is to run code if certain conditions are met while keeping the structure of the entire algorithm organized. The following lines demonstrate the use of a custom event onDamage usable for geometries acting as game entities:

_onDamage = (e)=>{
    _hp = _hp - e.dmg;
    e.other._score = e.other._score + e.dmg;
    _hp <= 0 ? {
        timetolive = 0
    } : {}
    e.other.materialname == "bullet" ? {
        // Note the := to force the creation of a new value "dmg" in e
        e.dmg := e.other._dmg;
    } : {}

As can be seen, the event _onDamage is used to extend onCollide without having to place the code in the same event. This helps keeping the code organized and can help accessing such functions in some cases. One does not have to use events for every action, in fact, it’s often easier to just use the root Event instead of creating new ones for every task. Major processes in a code should however be seperated in order to easily find and access it.

So, what simulation methods are actually used in Algodoo?

Warning – technical description…

Well, Algodoo basically simulates mechanical systems that are described by Newton’s equations. However, rather than starting with Newton’s laws, resulting in coupled differential equations and thereafter discretizing these, we start with a Lagrangian formulation of mechanics. The Lagrangian is discretized in
time and space, and thereafter we apply a discrete variational principle resulting in difference (or “stepping”)
equations for the system. In this way we can describe particle systems, rigid body systems
with constraints and motors, impacts, contacts and dry friction, as well as incompressible fluids and visco-elasto-plastic materials.

List of useful Thyme Variables and Expressions Edit

The following list contains a series of Thyme expressions. Should you find that you know code that should belong in this list, feel free to add it as long as it is no duplicate.

  •* — All camera influencing variables are listed here
  • sim.gravity* — All gravity influencing variables are listed under sim prefixed by gravity
  • rotation = math.atan2(e.other.pos(1)-pos(1),e.other.pos(0)-pos(0)) — Determines the angle between 2 objects in the coordinate system and rotates the first object accordingly.

vel = vel + /sim.frequency + *sim.gravityforce/sim.frequency — Neutralizes the effect of standard scene gravity with the first part and applies new gravity in your specified Angle to the object using the second part. Leave out the 2nd part to achieve zero-gravity.

System administrator simulator/Симулятор системного администратора (2008)

Компания HP совместно с Intel специально для системных администраторов создали игру-квест . Это первая в мире игра, предназначенная исключительно и только для сисадминов: открывается она тестом «на сисадминство» — таким образом, ни один простой пользователь ПК сыграть в нее не сможет. Пространство игры – консоль и схема сети – имитируют р …

Год выпуска: 2008Жанр: ЛогикаРазработчик: HP & IntelИздательство: HP&IntelСайт разработчика:Язык интерфейса: только русскийПлатформа: PC *Система: 98/XP/Vista, поддерживающая SWF; IE; *Процессор: Intel Pentium 400 МГц;; *Память: 128 MB; * Видео-карта: 1024×768, 16bit, 32MB; *

Capacitors Edit

A capacitor is a device that holds a small charge and quickly releases it. They can be used in the real world to convert AC to DC, up voltage by turning current from DC to AC, and more.

They’re even more useful in Algodoo since capacitors can power light bulbs, batteries, protection circuits, and even more. They’re quite easy to make. Put this in your code to create a basic capacitor. Set _charge to 0 and set _action1 and _action2 to the code you want.


(e)=>{_charge = _charge = 1;
charge > 0 ? {_action1(e)} : {_action2(e)}}


(e)=>{_charge = 3}

The scripting menu of the glowing part of an LED by little.

Variable Types

Variables in Algodoo are typeless, meaning they can contain any form of data dynamically without having to cast the variable to a new type. Some basic types used in Algodoo are:

Integer — A number without decimal digits:

_hs = 64;

Float — A number containing decimal digits:

math.pi = 3.14;

String — A chain of symbols, usually as text. Assigned using «»: = "Algodoo Wiki";

Boolean — A variable only able to take the state True and False:

_visible = true;

More advanced variables do exist, often containing basic variables in return:

Array — A variable containing multiple values of any type as a list. Assigned using square brackets with every value separated using comma. Values contained inside the array don’t have to be of the same variable type:

_data = ];

Code — Stores executable thyme code. The code gets executed by placing variable in code. It can also return values:

_code = {e.this.text = "Hello World"};

Function — Similar to Code, except the Thyme code is executable. It is also able to take and return variables. A function gets stored in form of:

(par1, par2,…)=>{code here}

_function = (f, g)=>{f + g};

Code is called as:

var(par1, par2,…):

e.other.pos = ;

Functions and regular Codes return the value that was used in the last line. In this example, the result of f + g would be the last value used.

This also shows that the events listed above are merely a special type of function, using the parameter e, which contains all information about the event in form of a class.

Classes are the only variable type that can’t be made by the user. They act like arrays, with the difference of their content being named variables as well. Their contents can be accessed with the syntax: var.content. While it is not possible to make the variable’s classes, as Thyme does not auto-cast to this type, it is possible to edit and even create new variables within an existing class. The only class type variables available to the user is the event data value’s «e». Most of Algodoo’s global variable organization (,, etc.) and variables referring to objects. For example: When copying an object into a textbox, or using entityByGeomId().

Displaying the e-value of an onClick event as text:

ClassObject with children:
clickCount = 1;
handled = false;
pos = ;
this -> {
    inertiaMultiplier = 1.0;
    resources = [];
    timeToLive = ∞;
    textureClamped = ;

This also shows the reason why we use e.this…, e.other…, e.pos, etc. When using the event variable. «This», «Other», and often more variables are actually variables stored within the class type variable e, and we access them this way.

Create Educational Scenes

In session 2 you will learn more about how to create educational scenes with Algodoo. In our step-by-step lesson tutorials you will learn how to create your own educational scenes and what educational aspects and related questions that should be considered. The lesson tutorials require a little more of your patience and skills, yet at the same time they will encourage you to find your own ways of creating components and scenes within Algodoo.

  1. Start by opening the “Float and Sink” lesson tutorial. In this lesson you will learn how to work with water and density inside Algodoo. Take time stepping through the guide and answer the given questions. Tip: When opening a lesson tutorial. Move the tutorial window to the upper right corner in Algodoo. In this way you will be given more space for creating your scenes.

  2. Step forward to the next lesson tutorial – “Friction of a sliding object”. In this tutorial you will learn more about working with friction and different materials and how to visualize forces and velocities.

  3. Start the last lesson tutorial – “Rainbows”. This tutorial will teach you how to create and experiment with optics.

Beginner Scripts Edit

Circle Spawner

        onclick = (e)=>{};
        oncollide = (e)=>{};
        ondie = (e)=>{};
        onhitbylaser = (e)=>{};
        onkey = onkey;
        onspawn = (e)=>{};
        inertiamultiplier = inertiamultiplier;
        resources = resources;
        timetolive = timetolive;
        textureclamped = textureclamped;
        adhesion = adhesion;
        attractiontype = attractiontype;
        attraction = attraction;
        texture = texture;
        update = update;
        vel = vel;
        restitution = restitution;
        materialvelocity = materialvelocity;
        showforcearrows = showforcearrows;
        refractiveondex = refractiveindex;
        texturematrix = texturematrix;
        protractor = protractor;
        collideset = collideset;
        drawborder = drawborder;
        reflectiveness = reflectiveness;
        friction = friction;
        materialname = materialname;
        pos = pos;
        density = density;
        colorhsva = colorhsva;
        angvel = 0;
        poststep = poststep;
        edgeblur = edgeblur;
        angle = angle

Box Spawner

(e)=>{scene.addBox({size := ; density := 2.00; pos := e.pos; restitution := 0.5; friction = 0.5; angle := 0})}

Self Collision

(e)=>{heteroCollide = false}

Collide Water

(e)=>{collideWater = true}

Change Collision of other objects or itself

(e)=>{e.this.collideSet = 1} or (e)=>{e.other.collideSet = 1}

Change Shape Color  : R=red, G=green, B=blue, A=visibility-attribute: value-range = 0.0 to 1.0

(e)=>{color = }

Text Color

(e)=>{textColor = }

Text Size

(e)=>{textScale = 3}


(e)=>{density = 10.02}


(e)=>{attraction = 50}

To repel — use a negative number with parentheses.

(e)=>{attraction = (-20)}


(e)=>{killer = true}

Set destroy key (With spawned objects)

(e)=>{buttonDestroy := "e"}

Set Collision (With spawned objects)

(e)=>{collideSet := n} // n is equal to any integer from 0 to 1023

Add Text (With spawned objects)

(e)=>{text := "Hello World!"}

Teleport a Object

(e)=>{e.other.pos} //x,y are coordinates where object will be teleported

The statements below are whole-SCENE variables (the variables only exist in one place). So you don’t need a colon (:) in front of the equal-sign.


(e)=>{Sim.gravityAngleOffset = 3.1415927}

Pause Simulation

(e)=>{sim.running = false}

Change Zoom Level

(e)=>{ = 17.700001}

Change Camera Pan

(e)=>{ = }

Change Simulation Wind Angle

(e)=>{sim.windangle = 3.1415927} // value is in radians, not degrees

Change Simulation Wind Strength

(e)=>{sim.windstrength = 10} // in m/s squared --->   (m/s)^2

Learn the basics

The aim in session 1 is to get familiarized with Algodoo. You will first learn how to create a basic Algodoo scene. When done with that you will learn more about the different tools in Algodoo. The last step in this session is how to master the magic Sketch tool.

  1. Start by running the setup guide (found in the Welcome screen) to customize Algodoo for your personal needs. More settings can be found in the Algodoo top menu under the setting button.

  2. Open Algodoo built-in tutorials by clicking the Tutorial button in the Algodoo welcome screen (or click the ?-mark in the Algodoo top menu)

  3. Start the “Crash course” tutorial. In this guide you will create your first Algodoo scene by stepping through basic features.

  4. When done with the “Crash course” step forward to the next tutorial – “Tools”. In this tutorial you will learn more about the different tools in Algodoo. Take your time to read the info text about the tools for learning more about specific settings and different tips and tricks.

  5. Start the last basic tutorial – “Sketch tool”. The sketch tool is a universal tool that lets you master most of the other tools by using different gestures that minimize the time required for swapping and changing between different tools when creating your scenes.

Are simulations in Algodoo accurate and correct, or is this just a toy?

Algodoo is indeed a digital toy, and nevertheless simulations are of very high quality,
using cutting edge scientific methods for multiphysics simulation.
However, there are some things to keep in mind:

The time step in Algodoo is by default 1/60 second (60 Hz), so any modeling of real-world physics happening at shorter time scales will be hard to reproduce. Typically this also means that the physics occuring on very short length scales is hard to resolve with this timestep, so we don’t recommend sub-centimeter physics at all. This scale limitation also holds for fluids.

When simulating a scene, Algodoo is solving a large system of equations using numerical methods. In order to ensure interactivity, the solution is approximate and this may lead to artefacts in certain cases.

The simulation engine in Algodoo is rather complex, and as with all software it may contain bugs. If you have found an inconsistency in the simulation that you believe should not be there, you should report this!

We do our very best to make sure Algodoo has high fidelity physics, but legally Algoryx has to issue the usual statement that: The software is provided as is, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement of third party rights. In no event shall the authors or copyright holders, Algoryx Simulation AB, be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out or in connection with the software or the use or other dealings in the software.

What sort of computer and operating system do I need to run Algodoo?

Minimum system requirements:

  • Windows XP, Windows Vista or Windows 7, Mac OS X 10.5
  • 1 GHz CPU
  • 256 MB of RAM
  • Video card with 96MB of memory with OpenGL support and the latest drivers
  • 40 MB of free hard disk space
  • An internet connection when unlocking Algodoo

For SMART Board:

  • Windows XP SP3, Windows Vista or Windows 7
  • SMART Notebook 10.8

Recommended system requirements:

  • Windows XP, Windows Vista or Windows 7, Mac OS X 10.6
  • 1.6 GHz CPU or better. Faster processors give faster simulations.
  • 512 Mb of RAM
  • Video card with 256MB of memory with OpenGL support and the latest drivers
  • 100 MB of free hard disk space
  • An internet connection

Algodoo Lessons

In session 3 you will take a closer look at Algodoo Lessons. This is a library with more than 60+ teacher-created lessons, each and every one corresponding to different areas in the curriculum. Algodoo Lessons is also designed for easily drafting, saving and sharing with other teachers or students who need content support when using Algodoo.

  1. Start by opening the lesson library. You will first enter a Welcome screen. Step through the Quick tour that will guide you through basic features and the lesson layout.

  2. You can search among all Algodoo lessons using the search table or by using the search tab in the upper right corner.

    • Start by entering the browsing table and look for lessons by selecting your “Language”, “Target group”, “Lesson category” and “Teaching discipline”. All lessons that match your preferences will then be listed.
    • Example: Language – English, Target – Key stage 3, Category – Demonstration, Discipline – Static forces
    • Try searching for lessons with the quick search.
      Search words: Force, friction, energy, optics, etc.
  3. Open and read your first lesson. Get familiar with the lesson layout and structure. Remember that all lessons in the lesson library are split into three different sections: 1 – General info table about the lesson, 2 – attached scenes to download and run, and 3 – a step-by step description on how to perform the lesson within Algodoo.

    • Run a search for a specific lesson. Open a lesson from the list.
    • Read the lesson information to get familiar with the content.
    • Open the attached scene or follow the step-by step guide on how to design the scene.
    • Reflect over the lesson content and design.
  4. For creating and sharing your own lessons you need a personal account (see step 2). You create a lesson by clicking the “New lesson” button and enter the necessary fields.

    • First open/create a scene that you want to add to the lesson library.
    • Click the “New lesson” button.
    • Enter the general information about the lesson you want to create.
    • Attach a scene.
    • Add steps on how to perform the lesson.
    • Save lesson as a draft. You can then complete it later on.
    • List your drafts by clicking the drafts-icon. Open your lesson again. Make some changes. If ready for publishing, click the publish button or save the lesson as a draft again.

Well done! Your are now a complete Algodooer.

If you like, explore more options in the lesson library, examine how to translate a lesson (there is a translate button for translating a lesson in to you language) or update your account info.

Оцените статью:
Оставить комментарий