Changed static method (README)
@@ -39,42 +39,45 @@ Run `./dome [gamefile.wren]` to run your game. If your initial file is called `m
## Basics
-Your game's entry point must contain a `Game` class which contains at least `static init()`, `static update()` and `static draw(_)` methods.
+Your game's entry point must contain a `Game` class which contains at least `init()`, `update()` and `draw(_)` methods.
```wren
import "input" for Keyboard
import "graphics" for Canvas, Color
class Game {
+ construct new() {}
- static init() {
- __x = 10
- __y = 10
- __w = 5
- __h = 5
+ init() {
+ _x = 10
+ _y = 10
+ _w = 5
+ _h = 5
}
static update() {
if (Keyboard.isKeyDown("left")) {
- __x = __x - 1
+ _x = _x - 1
}
if (Keyboard.isKeyDown("right")) {
- __x = __x+ 1
+ _x = _x+ 1
}
if (Keyboard.isKeyDown("up")) {
- __y = __y - 1
+ _y = _y - 1
}
if (Keyboard.isKeyDown("down")) {
- __y = __y + 1
+ _y = _y + 1
}
}
- static draw(alpha) {
+
+ draw(alpha) {
Canvas.cls()
var color = Color.rgb(171, 82, 54)
- Canvas.rectfill(__x, __y, __w, __h, color)
+ Canvas.rectfill(_x, _y, _w, _h, color)
}
}
+var Game = Main.new()
```
## Modules
