|
| 1 | +import "graphics" for Canvas, Color, Font |
| 2 | +import "dome" for Log, Window, Platform, Process |
| 3 | +import "input" for Mouse |
| 4 | +class Main { |
| 5 | + construct new() { |
| 6 | + Window.display = 0 |
| 7 | + _leftButtonColor = Color.white |
| 8 | + _rightButtonColor = Color.white |
| 9 | + _fullScreenButtonColor = Color.white |
| 10 | + _quitButtonColor = Color.white |
| 11 | + _buttonPressed = false |
| 12 | + } |
| 13 | + init() { |
| 14 | + |
| 15 | + } |
| 16 | + update() { |
| 17 | + _leftButtonColor = Color.white |
| 18 | + _rightButtonColor = Color.white |
| 19 | + _fullscreenButtonColor = Color.white |
| 20 | + _quitButtonColor = Color.white |
| 21 | + if(Mouse.x>=10 && Mouse.y>=15 && Mouse.x <= 15 && Mouse.y <= 28) { |
| 22 | + _leftButtonColor = Color.red |
| 23 | + if(!_buttonPressed && Mouse.isButtonPressed("left") ) { |
| 24 | + Window.display = Window.display - 1 |
| 25 | + _buttonPressed = true |
| 26 | + } |
| 27 | + |
| 28 | + } |
| 29 | + |
| 30 | + if (Mouse.x>=105 && Mouse.y>=15 && Mouse.x <= 110 && Mouse.y <= 28) { |
| 31 | + _rightButtonColor = Color.red |
| 32 | + if(!_buttonPressed && Mouse.isButtonPressed("left")) { |
| 33 | + |
| 34 | + Window.display = Window.display + 1 |
| 35 | + _buttonPressed = true |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + if(Mouse.x>=10 && Mouse.y>=30 && Mouse.x <= 100 && Mouse.y <= 38) { |
| 40 | + _fullscreenButtonColor = Color.red |
| 41 | + if(!_buttonPressed && Mouse.isButtonPressed("left")) { |
| 42 | + Window.fullscreen = !Window.fullscreen |
| 43 | + _buttonPressed = true |
| 44 | + } |
| 45 | + } |
| 46 | + if(Mouse.x>=10 && Mouse.y>=40 && Mouse.x <= 60 && Mouse.y <= 48) { |
| 47 | + _quitButtonColor = Color.red |
| 48 | + if(!_buttonPressed && Mouse.isButtonPressed("left")) { |
| 49 | + Process.exit() |
| 50 | + _buttonPressed = true |
| 51 | + } |
| 52 | + } |
| 53 | + if(_buttonPressed && !Mouse.isButtonPressed("left")){ |
| 54 | + _buttonPressed = false |
| 55 | + } |
| 56 | + } |
| 57 | + draw(dt) { |
| 58 | + Canvas.cls() |
| 59 | + Canvas.print("<", 10, 20, _leftButtonColor) |
| 60 | + Canvas.print("Display: %(Window.display)", 20, 20, Color.white) |
| 61 | + Canvas.print(">", 105, 20, _rightButtonColor) |
| 62 | + Canvas.print("Fullscreen", 20, 30, _fullscreenButtonColor) |
| 63 | + Canvas.print("Quit", 20, 40, _quitButtonColor) |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +var Game = Main.new() |
0 commit comments