[size=150:1o1zlee0]General expression features[/size:1o1zlee0]

Javascript does not actually support an integer datatype, but support is emulated by the runtime by rounding floats. However, any operator involving a float returns a float (so e.g. 5 + 0.5 returns 5.5 like you expect) so this probably isn't going to be an issue for anyone. Also, division always returns a float, so 5 / 2 = 2.5 (as with 0.x), if you want integer rounded division, explicitly specify it with int(5 / 2).

There are no expression shortcuts like in 0.x: you can't type .X as a substitute for Self.X. However, the Self keyword works.

You can specify specific instances in object expressions: Sprite(0).X gets the

*first picked*Sprite's X co-ordinate, Sprite(1).X the second, and so on. Sprite(N) when there are N sprites will wrap-around and return the first Sprite's X again, Sprite(N+1) the second, and so on. Sprite(-1).X will return the

*last picked*Sprite's X co-ordinate, Sprite(-2).X the second last, and so on. You can use any expression for the instance to pick, you don't have to just enter a number.

The usual arithmetic operators are supported: + - * / % ^

There's a new unary minus operator, so you can write -Sprite.X instead of 0 - Sprite.X.

The conditional a ? b : c operator was a bit buggy in 0.x - it should be working correctly in C2. Example: Sprite.X < 100 ? -1 : 1

The & operator is string concatenation as in 0.x, or logical AND when both operands are numbers. The | operator is logical OR (and has no special behavior with strings).

[size=150:1o1zlee0]System[/size:1o1zlee0]

**int(x)**- convert x to integer

**float(x)**- convert x to float

**str(x)**- convert x to string

**len(x)**- return length of the string x

**random(x)**- return a random

*float*from 0 (inclusive) to x (exclusive) - note this differs from Construct 0.x where random would return an integer if you passed it an integer. Use int(random(x)) to reproduce this behavior.

**random(a, b)**- return a random float from a (inclusive) to b (exclusive).

**sqrt(x)**- compute square root of x.

**abs(x)**- absolute (positive) value of x.

**round(x)**- round x to the nearest whole number.

**floor(x)**- round x to the lowest next whole number.

**ceil(x)**- round x to the highest next whole number.

**sin(x), cos(x), tan(x), asin(x), acos(x), atan(x)**- trigonometric functions, which work in degrees

**exp(x)**- e raised to the power x

**ln(x)**- log to base e of x

**log10(x)**- log to base 10 of x

**lerp(a, b, x)**- linearly interpolate a to b by x

**distance(x1, y1, x2, y2)**- distance between two points

**angle(x1, y1, x2, y2)**- angle between two points (degrees)

**loopindex**- current (top-level) loop index

**loopindex(name)**- loop index of 'for' loop of given name

**max(x, y [, z...]), min(x, y [, z...])**- returns maximum/minimum of any number passed - like 0.x you can pass any number of parameters here.

**newline**- text string containing a line break character.

**dt**- new name for 'timedelta' which is the standard used in games programming (it's actually usually referred to as 'delta time', so 0.x got this the wrong way round!). Currently always returns a fixed value (1/60th of a second) because Javascript does not have a high-resolution timer. You should still use it so you're future-proofed in case dt is ever modified to actually be a time measurement, and when implemented, timescale will modify this value.

**timescale**- always 1.0 at this time.

**time**- time in seconds since the game started.

**tickcount**- number of ticks elapsed since the game started.

**objectcount**- total number of object instances in the game.

**fps**- current framerate in frames per second.

**scrollx, scrolly**- current scroll position

[size=150:1o1zlee0]Common object expressions[/size:1o1zlee0]

Currently, Sprite and Text implement these.

**X**,

**Y**,

**Width**,

**Height**- as with 0.x

**Angle**- (Sprite only) Angle in degrees

**Count**- number of instances

[size=150:1o1zlee0]Other object expressions[/size:1o1zlee0]

There are no longer MouseX or MouseY system expressions - insert the Mouse object and use Mouse.X and Mouse.Y for the mouse position in the layout, or Mouse.AbsoluteX and Mouse.AbsoluteY for the position on the canvas.

The text object also has a 'Text' expression (surprise!).

[size=150:1o1zlee0]Instance variables[/size:1o1zlee0]

Access these by their name like this:

MyObject.MyInstanceVariable

You can't name an instance variable the same as an object expression.