Esempio n. 1
0
                    hit_model=bg_color + Graphics.Sprites.DECIDUOUS_TREE +
                    Utils.Style.RESET_ALL,
                    hit_callback=sprout,
                )
                row = g.player.pos[0]
                column = g.player.pos[1] + 1
                if key == "w" or key == "z":
                    projectile.set_direction(Constants.UP)
                    row = g.player.pos[0] - 1
                    column = g.player.pos[1]
                elif key == "s":
                    projectile.set_direction(Constants.DOWN)
                    row = g.player.pos[0] + 1
                    column = g.player.pos[1]
                elif key == "a" or key == "q":
                    projectile.set_direction(Constants.LEFT)
                    row = g.player.pos[0]
                    column = g.player.pos[1] - 1
                hit_wave_obj.play()
                g.add_projectile(g.current_level, projectile, row, column)
                g.timer -= projectile.range
            elif key == "p":
                if g.state == Constants.RUNNING:
                    g.pause()
                else:
                    g.start()
            key = Utils.get_key()
        current_state = "title"

g.save_config("settings", "settings-suparex.json")
Esempio n. 2
0
            fireball = Projectile(
                name="fireball",
                model=Utils.red_bright(black_circle),
                hit_model=Sprites.EXPLOSION,
            )
            fireball.animation = Animation(
                auto_replay=True,
                animated_object=fireball,
                refresh_screen=None,
                display_time=0.5,
            )
            fireball.animation.add_frame(Utils.red_bright(black_circle))
            fireball.animation.add_frame(Utils.red_bright(circle_jot))
            fireball.range = 7
            fireball.set_direction(Constants.RIGHT)
            g.add_projectile(1, fireball, g.player.pos[0], g.player.pos[1] + 1)
            g.player.mp -= 4

    elif key == Utils.key.UP:
        g.move_player(Constants.UP, 1)
    elif key == Utils.key.DOWN:
        g.move_player(Constants.DOWN, 1)
    elif key == Utils.key.LEFT:
        g.move_player(Constants.LEFT, 1)
    elif key == Utils.key.RIGHT:
        g.move_player(Constants.RIGHT, 1)

    redraw_screen()
    print("Screen just redrawn")
    g.actuate_npcs(1)
    g.actuate_projectiles(1)
    elif key == "2":
        viewport = [15, 30]
        g.partial_display_viewport = viewport
    elif key == "3":
        viewport = [20, 20]
        g.partial_display_viewport = viewport
    elif key == "9":
        current_spell_template = fireball_template
    elif key == "0":
        current_spell_template = zap_template
    if key == Utils.key.SPACE:
        if g.player.mp >= 4:
            spell = deepcopy(current_spell_template)
            if last_direction == Constants.LEFT:
                spell.set_direction(Constants.LEFT)
                g.add_projectile(1, spell, g.player.pos[0],
                                 g.player.pos[1] - 1)
            elif last_direction == Constants.UP:
                spell.set_direction(Constants.UP)
                g.add_projectile(1, spell, g.player.pos[0] - 1,
                                 g.player.pos[1])
            elif last_direction == Constants.DOWN:
                spell.set_direction(Constants.DOWN)
                g.add_projectile(1, spell, g.player.pos[0] + 1,
                                 g.player.pos[1])
            else:
                spell.set_direction(Constants.RIGHT)
                g.add_projectile(1, spell, g.player.pos[0],
                                 g.player.pos[1] + 1)

            if current_spell_template == fireball_template:
                _thread.start_new_thread(playsound,