Esempio n. 1
0
File: menu.cpp Progetto: PNCG/neuron
void MenuImpl::save_cursor(Canvas* c) {
    if (!saved_cursor_) {
	Window* w = c->window();
	cursor_ = w->cursor();
	saved_cursor_ = true;
	w->cursor(menu_cursor());
    }
}
Esempio n. 2
0
int	gere_key(int key, t_all *all)
{
    int	x = 12;
    int	y;

    menu_cursor(key, all);
    start_cursor(key, all);
    if (key == 32)
    {
        if (all->system.phase == 0)
        {
            all->system.phase = 3;
            start(all);
        }
        if (all->system.phase == 4)
            menu(all);
        if (all->system.phase == 2)
        {
            init_game(all);
            all->system.phase = 1;
            mlx_clear_window(all->system.mlx_p, all->system.mlx_w);
            put_ui_to_window(all);
        }
    }
    if (all->system.phase == 0 && key == 269025053)
    {
        all->system.phase = 42;
        mlx_clear_window(all->system.mlx_p, all->system.mlx_w);
        while (x < 500)
        {
            y = 0;
            while (y < 500)
            {
                mlx_string_put(all->system.mlx_p, all->system.mlx_w, x, y,
                               0xFF0000, "ASTEK ENCULE !!!");
                y += 15;
            }
            x += 102;
        }
    }
    if (key == 65307 && all->system.phase != 2 && all->system.phase != 4)
        exit(1);
    if (key == 65307 && (all->system.phase == 2 || all->system.phase == 4))
        menu(all);
    if (all->system.phase == 1)
    {
        if (key == 38)
        {
            attack(all, &(all->p1), &(all->p2));
            all->p1.energy += all->p1.regen_energy;
            if (all->p1.meditate_last > 0)
                all->p1.meditate_last -= 1;
            if (all->p1.meditate_last == 0)
                all->p1.regen_energy = all->p1.regen_base;
            if (all->system.phase == 1)
            {
                clear_sides(all);
                put_ui_to_window(all);
                enemy_phase(all, &(all->p2), &(all->p1));
                clear_sides(all);
                put_ui_to_window(all);
            }
        }
        if (key == 233)
        {
            if (all->p1.energy >= 40)
            {
                magic(all, &(all->p1), &(all->p2));
                all->p1.energy += all->p1.regen_energy;
                if (all->p1.meditate_last > 0)
                    all->p1.meditate_last -= 1;
                if (all->p1.meditate_last == 0)
                    all->p1.regen_energy = all->p1.regen_base;
                if (all->system.phase == 1)
                {
                    clear_sides(all);
                    put_ui_to_window(all);
                    enemy_phase(all, &(all->p2), &(all->p1));
                    clear_sides(all);
                    put_ui_to_window(all);
                }
            }
            else
            {
                all->system.error_msg = 1;
                put_ui_to_window(all);
            }
        }
        if (key == 34)
        {
            if (all->p1.energy >= 60)
            {
                potion(all, &(all->p1), &(all->p2));
                all->p1.energy += all->p1.regen_energy;
                if (all->p1.meditate_last > 0)
                    all->p1.meditate_last -= 1;
                if (all->p1.meditate_last == 0)
                    all->p1.regen_energy = all->p1.regen_base;
                if (all->system.phase == 1)
                {
                    clear_sides(all);
                    put_ui_to_window(all);
                    enemy_phase(all, &(all->p2), &(all->p1));
                    clear_sides(all);
                    put_ui_to_window(all);
                }
            }
            else
            {
                all->system.error_msg = 1;
                put_ui_to_window(all);
            }
        }
        if (key == 39)
        {
            all->p1.energy += all->p1.regen_energy;
            all->p1.regen_energy = all->p1.regen_base * 2;
            all->p1.meditate_last = 3;
            if (all->system.phase == 1)
            {
                clear_sides(all);
                put_ui_to_window(all);
                enemy_phase(all, &(all->p2), &(all->p1));
                clear_sides(all);
                put_ui_to_window(all);
            }
        }
    }
}