LoginSignup
2
2

More than 1 year has passed since last update.

ストワで始めるLua 第一回 のコード

Posted at

『ストワで始めるLua 第一回第一回変数と入出力』で使われたコードです。
動画はこちら
https://www.nicovideo.jp/watch/sm42026411
https://www.nicovideo.jp/watch/sm42026442

ストワのスクリーンに円を表示して入力の数値で動かすサンプルコード。

lua1
--initialize
positionX=0
positionY=0

function onTick()
	--input
	positionX=input.getNumber(1)
	positionY=input.getNumber(2)

	--output
	output.setNumber(1,positionX)
	output.setNumber(2,positionY)
end

function onDraw()
	--display
	local w=screen.getWidth()
	local h=screen.getHeight()
	
	local x=positionx*(w/2)
	local y=positionY*(h/2)
	
	screen.setColor(0, 255, 0)
	screen.drawCircleF(w/2+x,h/2-y,20)
end

2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2