-
Notifications
You must be signed in to change notification settings - Fork 2
/
movimiento.wlk
32 lines (24 loc) · 694 Bytes
/
movimiento.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
import wollok.game.*
object movimiento {
method configurarFlechas(visual){
keyboard.up().onPressDo{ self.mover(arriba,visual)}
keyboard.down().onPressDo{ self.mover(abajo,visual)}
keyboard.left().onPressDo{ self.mover(izquierda,visual)}
keyboard.right().onPressDo{ self.mover(derecha,visual)}
}
method mover(direccion,personaje){
personaje.position(direccion.siguiente(personaje.position()))
}
}
object izquierda {
method siguiente(position) = position.left(1)
}
object derecha {
method siguiente(position) = position.right(1)
}
object abajo {
method siguiente(position) = position.down(1)
}
object arriba {
method siguiente(position) = position.up(1)
}