絶対値

 数値の絶対値を返すサンプルです。
関数:math.abs(x)

-- mathabs.lua
-- 数値の絶対値を返します。
 
while not Keys.newPress.Start do
 
	Controls.read()
 
	startDrawing()
 
	screen.print(SCREEN_UP, 0, 0, "Press START to quit")
 
	screen.print(SCREEN_DOWN, 0, 0, "math.abs(-12) = " .. math.abs(-12))
	screen.print(SCREEN_DOWN, 0, 8, "math.abs(34) = " .. math.abs(34))
	screen.print(SCREEN_DOWN, 0,16, "math.abs(0) = " .. math.abs(0))
 
	stopDrawing()
 
end
 





タグ:

+ タグ編集
  • タグ:
最終更新:2010年09月27日 22:57
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。