Exemple #1
0
void draw_lives(void){
	move_cursor(LIFE_LABEL_X,LIFE_LABEL_Y);
	printf_P(PSTR("Lives:"));
	move_cursor(LIFE_X,LIFE_Y);
	if (get_lives() == 1){
		set_display_attribute(LIFE_COLOUR);
	}
	printf_P(PSTR("%d/5"),get_lives());
	set_display_attribute(0);
	
	move_cursor(WIDTH,HEIGHT);
}
void Combat_Screen::bossAttacks(){
    QObject::connect(enemy_display_timer,SIGNAL(timeout()),
                     this,SLOT(set_enemy_action_display()));
    QObject::connect(hero_display_timer,SIGNAL(timeout()),
                     this,SLOT(set_hero_action_display()));

    if(get_defend()==true){

        enemy_action_label->setText("Boss was defended! -0");
        enemy_action_label->setStyleSheet("font: 8pt; color: red;");
        hero_action_label->setText("you defended the attack!");
        hero_action_label->setStyleSheet("font: 8pt; color: red;");
        enemy_display_timer->start(3000);
        hero_display_timer->start(3000);
        set_defend(false);

    }else{
        int random;
        random = rand()&100+1;
        if(random <=20){
            calculate_hero_damage(getMassiveAttack());
            hero_health_bar->setValue(get_hero_health());
            enemy_action_label->setText("Boss Used Massive Attack! -20");
            enemy_action_label->setStyleSheet("font: 8pt; color: red;");
            enemy_display_timer->start(3000);
        }else if(random >20 && random <= 60){
            calculate_hero_damage(getMediumAttack());
            hero_health_bar->setValue(get_hero_health());
            enemy_action_label->setText("Boss Used Medium Attack! -10");
            enemy_action_label->setStyleSheet("font: 8pt; color: red;");
            enemy_display_timer->start(3000);
        }else if(random >60){
            calculate_hero_damage(getSmallAttack());
            hero_health_bar->setValue(get_hero_health());
            enemy_action_label->setText("Boss Used Small Attack! -5");
            enemy_action_label->setStyleSheet("font: 8pt; color: red;");
            enemy_display_timer->start(3000);
        }
    if(get_hero_health()<=0){
        lose_screen dialog(this);
        set_lives(get_lives()-1);
        if(dialog.exec()==1){
            if(get_lives()==0){
                std::cout<<"YOU LOSE!"<<std::endl;
            }
            close();
        }
    }
}
}
void Combat_Screen::calculate_standard_attack(){

    QObject::connect(enemy_display_timer,SIGNAL(timeout()),
                     this,SLOT(set_enemy_action_display()));
    QObject::connect(hero_display_timer,SIGNAL(timeout()),
                     this,SLOT(set_hero_action_display()));

    if(get_defend()==true){

        enemy_action_label->setText("Enemy attack defended!");
        enemy_action_label->setStyleSheet("font: 8pt; color: red;");
        hero_action_label->setText("you defended the attack!");
        hero_action_label->setStyleSheet("font: 8pt; color: red;");
        enemy_display_timer->start(3000);
        hero_display_timer->start(3000);
        set_defend(false);

    }else{

    calculate_hero_damage(3);
    hero_health_bar->setValue(get_hero_health());
    enemy_action_label->setText("Enemy Used small attack! -3");
    enemy_action_label->setStyleSheet("font: 8pt; color: red;");
    enemy_display_timer->start(3000);

    if(get_hero_health()<=0){
        lose_screen dialog(this);
        set_lives(get_lives()-1);
        if(dialog.exec()==1){
            if(get_lives()==0){
                std::cout<<"YOU LOSE!"<<std::endl;
            }
            close();
        }
    }
}
}