- Code: Select all
w=platform.window:width()
h=platform.window:height()
local s
function on.paint(gc)
gc:fillRect(0,0,w,h)
gc:setColorRGB(255,255,255)
gc:drawLine(0,25,w,25)
for i=0,25,0.1 do gc:setColorRGB(3*i,3*i,3*i) gc:drawLine(0,i,w,i) end
s = scratchpad(gc)
s:paint(gc)
end
function on.enterKey() timer.start(1) end
-------------------------------------------------------Scratchpad
scratchpad = class()
function scratchpad:init(gc)
wscratchpad=gc:getStringWidth("Scratchpad")
hscratchpad=gc:getStringHeight("Scratchpad")
self.xpos = w/4 - wscratchpad/2
self.ypos = 25 + hscratchpad
end
function scratchpad:paint(gc)
self.taille=11
gc:setFont("sansserif","b",self.taille)
gc:setColorRGB(80,80,255)
gc:drawString("Scratchpad",self.xpos,self.ypos)
end
function scratchpad:doTheHarlemShake()
if self.taille~=3 then self.taille = self.taille-0.5 else self.taille=self.taille+5 end
if self.xpos~=w/4 - wscratchpad/2-40 then self.xpos = self.xpos - 2 end
if self.ypos~=25 + hscratchpad+40 then self.ypos = self.ypos + 2 end
platform.window:invalidate()
end
function on.timer()
s:doTheHarlemShake()
platform.window:invalidate()
end
Voici un code en lua
problème, quand j'appuye sur entrée, rien ne se passe pk?