loading
main.py
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
import miniworldmaker as mwm


class MyBoard(mwm.TiledBoard):
    def on_setup(self):
        self.add_image("images/rasen.jpg")
        Player((4, 4))
        Ball((6, 6))
        self.background.grid_overlay = True


class Player(mwm.Token):

    def on_setup(self):
        self.add_image("images/player.png")
        self.orientation = -90

    def on_key_down(self, keys):
        if 'A' in keys:
            self.direction = "left"
        if 'S' in keys:
            self.direction = "down"
        if 'W' in keys:
            self.direction = "up"
        if 'D' in keys:
            self.direction = "right"
        self.move()

    def on_sensing_ball(self, ball):
        ball.direction = self.direction
        ball.move(2)


class Ball(Token):

    def on_setup(self):
        self.add_image("images/ball.png")


myboard = MyBoard(10, 10, 40, 0)
myboard.show(fullscreen = True)