O'Reilly logo

Lingo in a Nutshell by Bruce A. Epstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Math (and Gambling)

Dust off your dunce cap. This chapter covers mathematical, geometric, and trigonometric operations for both the mathematically adept and the numerically challenged. If you are one of the latter, at least you’ll enjoy the section on gambling at the end of the chapter. Refer to Chapter 5, for details on data type conversion, expression evaluation, logical operators, and comparison operators. See Chapter 6, for an introduction to rects and points and mathematical operations with lists. Refer to Chapter 5, Coordinates, Alignment, and Registration Points, in Director in a Nutshell for more details on rects, points, coordinate systems, and alignment of sprites on the Stage.

Tip

The cross-platform MathXtras from Maxwell Technologies (http://www.maxwell.com/mathxtras) provide these math-related functions: customizable on-screen calculator, scrolling odometer-style counter, equation editor, graphing functions, spreadsheet tables, and even sliders and speedometers.

Arithmetic Operators

Director supports the usual complement of arithmetic operators, as shown in Table 8-1. Operations with a higher precedence are performed first. Operations with the same precedence are performed left to right. The order of evaluation can be overridden with parentheses. Refer also to Table 5-7 and Table 5-8, which detail the precedence of comparison and Boolean operators. If one or both operands in an expression are floats, the result is a float. If both operands are integers, the result ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required