Computer Science: Map - XLJasonHuo/Starfield GitHub Wiki

Map() function can take any number and scale it to a new number that could essentially change your project. In our Starfield Summative. We used the map function to let the user control the speed of the starfield, by user's mouse movement. If the user's mouseX is negative, the speed will decrease, lowest to 0. If the user's mouseX is positive, the speed will increase, highest to 30.

speed = map(mouseX, 0, width, 0, 30);

Syntax

map(value, start1, stop1, start2, stop2, )

Syntax Description

value: the value that the coder wants to convert

start1: lower bound of the value's current range

stop1: upper bound of the value's current range

start2: lower bound of the value's target range

stop2: upper bound of the value's target range