Simple windowed application: Difference between revisions
Content added Content deleted
(Added gForth/tk) |
(Added Wren) |
||
Line 3,482: | Line 3,482: | ||
and the resulting form definition file was converted to Web 68 by the program |
and the resulting form definition file was converted to Web 68 by the program |
||
<b>fdtow68</b>.</lang> |
<b>fdtow68</b>.</lang> |
||
=={{header|Wren}}== |
|||
{{libheader|DOME}} |
|||
<lang ecmascript>import "graphics" for Canvas, Color |
|||
import "input" for Mouse |
|||
import "dome" for Window |
|||
class SimpleWindowedApplication { |
|||
construct new(width, height) { |
|||
Window.title = "Simple windowed application" |
|||
_fore = Color.white |
|||
_clicks = 0 |
|||
} |
|||
init() { |
|||
drawControls() |
|||
} |
|||
update() { |
|||
if (Mouse["left"].justPressed && insideButton) _clicks = _clicks + 1 |
|||
} |
|||
draw(alpha) { |
|||
drawControls() |
|||
} |
|||
insideButton { |
|||
var p = Mouse.position |
|||
return p.x >= 120 && p.x <= 200 && p.y >= 90 && p.y <= 170 |
|||
} |
|||
drawControls() { |
|||
Canvas.cls() |
|||
if (_clicks == 0) { |
|||
Canvas.print("There have been no clicks yet", 40, 40, _fore) |
|||
} else if (_clicks == 1) { |
|||
Canvas.print("The button has been clicked once", 30, 40, _fore) |
|||
} else { |
|||
Canvas.print("The button has been clicked %(_clicks) times", 10, 40, _fore) |
|||
} |
|||
Canvas.rectfill(120, 90, 80, 80, Color.red) |
|||
Canvas.rect(120, 90, 80, 80, Color.blue) |
|||
Canvas.print("click me", 130, 125, _fore) |
|||
} |
|||
} |
|||
var Game = SimpleWindowedApplication.new(600, 600)</lang> |
|||
=={{header|XPL0}}== |
=={{header|XPL0}}== |