0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

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

Posted at

lua3
data={}
maxh=property.getNumber("max")
minh=property.getNumber("min")
w,h=0,0

function onTick()
    local i
    if w~=0 then
    	table.insert(data,input.getNumber(1))
    	if #data>w then
    		table.remove(data,1)
    	end
    end
end

function onDraw()
	local i,number2pixel
	w=screen.getWidth()
	h=screen.getHeight()
	
	number2pixel=h/(maxh-minh)
	
	if #data>0 then 
		screen.drawText(0,0,data[#data])
	end
	
	if #data>=2 then
		for i=2,#data do
			screen.drawLine(i-1,h-(data[i-1]-minh)*number2pixel,i,h-(data[i]-minh)*number2pixel)
		end
	end
end
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?