-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.wlk
62 lines (42 loc) · 1.05 KB
/
example.wlk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
object juegoDeManzanas{
method iniciar(){
game.height(9)
game.width(9)
game.addVisual(manzana)
game.addVisual(robot)
game.addVisualCharacter(mario)
keyboard.enter().onPressDo({mario.irAlBorde()})
game.onCollideDo(mario, {algo=>algo.agarrar()})
game.onTick(1000, "moverse", {robot.moverseSolo()})
}
}
object robot {
var position = game.at(2,2)
method position() = position
method image() = "robot.png"
method agarrar() {
game.removeVisual(robot)
}
method moverseSolo() {
position = game.at(0.randomUpTo(8),0.randomUpTo(8) )
}
}
object manzana {
method position() = game.center()
method image() = "moneda.jpg"
method agarrar() {
mario.irAlBorde()
}
}
object mario{
var dondeEsta = game.origin()
method position() = dondeEsta
method image() = if (dondeEsta.x() == 8) "vegeta.jpg" else "mario.png"
method position(nueva) {
dondeEsta = nueva
}
method irAlBorde() {
dondeEsta = game.at(8,dondeEsta.y())
game.schedule(300, {dondeEsta = dondeEsta.up(1)})
}
}