def initialize():

    global arena, mario, background, sprites, platforms

    arena = actor.Arena(screen_x, screen_y)

    mario = jumper.Jumper(arena, 16, 248)

    game2d.canvas_init(arena.size())

    platforms = []

    for n in range(len(dk_elements.map_elements)):
        if dk_elements.map_elements[n][0] == "Platform":

            x, y, w, h = dk_elements.map_elements[n][-4:]
            platforms.append(entities.Platform(x, y, w, h, arena))

            print(platforms)

    background = game2d.image_load("dk_background.png")

    sprites = game2d.image_load("dk_sprites.png")

    game2d.handle_keyboard(keydown, keyup)
def setup():
    global arena, turtle, sprites

    arena = Arena(320, 240)
    Ball(arena, 40, 80)
    Ball(arena, 80, 40)

    game2d.canvas_init(arena.size())
    sprites = game2d.image_load("sprites.png")

    game2d.set_interval(update, 1000 // 30)  # millis
Beispiel #3
0
def main():
    global arena, mario, sprites, background

    arena = Arena(224, 256)
    mario = Mario(arena, 50, 230)
    Barrel(arena, 180, 70)
    Barrel(arena, 150, 70)

    for t, x, y, w, h in map_elements:
        if t == "Platform":
            Platform(arena, int(x), int(y))
        elif t == "Ladder":
            Ladder(arena, int(x), int(y), int(h))

    game2d.canvas_init(arena.size())
    sprites = game2d.image_load("dk_sprites.png")
    background = game2d.image_load("dk_background.png")

    game2d.handle_keyboard(keydown, keyup)
    game2d.set_interval(update, 1000 // 30)  # millis
import game2d

dx = 50
dy = 50
screen_x = 500
screen_y = 500
image = game2d.image_load(
    "http://www.sportspearl.com/wp-content/uploads/2017/05/football-150x150.png"
)


def update():
    global dx, dy, verso

    game2d.canvas_fill((255, 255, 255))
    game2d.image_blit(image, (dx, dy))

    if dx < screen_x - 150 and dy < screen_y - 150:
        dx = (dx + 20)
        dy = (dy + 60)
    elif dx < screen_x - 150 and dy == screen_y - 150:
        dx = (dx + 20)


def main():
    game2d.canvas_init((screen_x, screen_y))
    game2d.set_interval(update, 1000 // 30)


if __name__ == "__main__":
    main()