Basic Concepts of L2

< About L2

Variables

In programming, a variable is just a value to which you assign a name. It's no different than in Pre-Algebra. You can name the variable anything you want, but it should usually be a word that explains what it represents (instead of using x or y like in math class).

With L2 you will define each variable by declaring its type, which L2 currently supports three: string, number, or object.

Strings

A string is just a line of text that can be letters, numbers, and other symbols. It can be a word or multiple words. One way we might use a string variable is to set a color that we want to paint something on the screen. That variable can be reused multiple times, and you only have to change the place where the value is set.

It's very simple:

        string eyeColor = blue 
        string hairColor = brown 
    

Now have two string variables that we can use later in our L2 app.

Numbers

This is very similar to a string type, except (as you might guess) it is designed to contain numbers. So you might use this to store the size or position of certain elements, for example.

        number eyeWidth = 20
        number eyeHeight = 15
    

Objects

Now this is where the power comes in! Objects in L2 are the on-screen display. You use objects to create shapes, display text, and other elements.

There are five types of objects currently supported:

Examples:

        object background = new rectangle
        object head = new circle
        object title = new text