abs()
Purpose
Returns absolute value of the given argument.
Description
Always returns the positive value of a given number. For instance: abs( -1 ) = 1
Syntax
absolute = abs( number )
Arguments
number A positive or negative number
absolute The positive value of number (the number without the - sign)
Example
image = loadImage( "Untied Games/Enemy small top C", false )
ship = createSprite()
setSpriteImage( ship, image )
lastpos = { gWidth() / 2, gHeight() / 2 }
setSpriteLocation( ship, lastpos )
setSpriteScale( ship, { 10, 10 } )
maxrs = 240 // max rotation speed
accr = 1 // accelaration
loop
clear()
rs = getSpriteRotationSpeed( ship )
if ( abs( rs ) > maxrs ) then
accr = -accr
endIf
setSpriteRotationSpeed( ship, rs + accr )
updateSprites()
drawSprites()
update()
repeat
Associated Commands