Ejemplo n.º 1
0
void STG::logic()
{
    if(receiver->IsKeyPressed(SDLK_1))
    {
        player->setType("1");
    }
    if(receiver->IsKeyPressed(SDLK_2))
    {
        player->setType("2");
    }
    if(receiver->IsKeyPressed(SDLK_3))
    {
        player->setType("3");
    }
    if(receiver->IsKeyPressed(SDLK_4))
    {
        player->setType("4");
    }
    if(receiver->IsKeyPressed(SDLK_5))
    {
        player->setType("5");
    }
    if(receiver->IsKeyPressed(SDLK_6))
    {
        player->setType("6");
    }
    if(receiver->IsKeyPressed(SDLK_7))
    {
        player->setType("7");
    }
    if(receiver->IsKeyPressed(SDLK_8))
    {
        player->setType("8");
    }
    if(receiver->IsKeyPressed(SDLK_9))
    {
        player->setType("9");
    }

    int stage_displacement = stage->getVelocity();
    if(isSlowActive())
        stage_displacement/=3;
    painter->camera_x+=stage_displacement;
    player->logic(stage_displacement);
    enemy->logic(stage_displacement,stage->getName(),iteration,username);
    stage->logic();

    deletePatterns();
    checkCharacterOutOfBounds();
    slowExtraControl();

    if(enemy->getHP()>0)
        iteration++;
}
Ejemplo n.º 2
0
void slowExtraControl()
{
    //slow extra control
    if(isSlowActive())
    {
        iterate_slowdown_flag=false;
        current_slowdown_iteration++;
        if(current_slowdown_iteration>=3)
        {
            current_slowdown_iteration=0;
            iterate_slowdown_flag=true;
        }
    }
}
Ejemplo n.º 3
0
void Player::render()
{
    //HP
    painter->drawRectangle(life_bar_x+life_bar_rect_offset_x,life_bar_y+life_bar_rect_offset_y,(life_bar_rect_width*hp)/max_hp,life_bar_rect_height,0,this->color.getRed(),this->color.getGreen(),this->color.getBlue(),this->color.getAlpha(),false);
    if(!slow_in_cooldown)
        painter->drawRectangle(slow_bar_x+slow_bar_rect_offset_x,slow_bar_y+slow_bar_rect_offset_y,(slow_bar_rect_width*current_slow)/max_slow,slow_bar_rect_height,0,this->slow_bar_color.getRed(),this->slow_bar_color.getGreen(),this->slow_bar_color.getBlue(),this->slow_bar_color.getAlpha(),false);
    else
        painter->drawRectangle(slow_bar_x+slow_bar_rect_offset_x,slow_bar_y+slow_bar_rect_offset_y,(slow_bar_rect_width*current_slow)/max_slow,slow_bar_rect_height,0,this->slow_bar_cooldown_color.getRed(),this->slow_bar_cooldown_color.getGreen(),this->slow_bar_cooldown_color.getBlue(),this->slow_bar_cooldown_color.getAlpha(),false);
    parrentRender();

    painter->draw2DImage
    (   life_bar,
        life_bar->getWidth(),life_bar->getHeight(),
        painter->camera_x+life_bar_x,life_bar_y,
        1.0,
        0.0,
        false,
        0,0,
        Color(255,255,255,255),
        0,0,
        true,
        FlatShadow());

    if(isSlowActive())
    {
        painter->draw3DCube(this->getHitbox().getX(),this->getHitbox().getY(),2.0,Color(255,0,0,180));
    }else
    {
        painter->draw3DCube(this->getHitbox().getX(),this->getHitbox().getY(),2.0,Color(255,0,0,100));
    }

//    if(shooting)
//    {
//        if(iteration%10==0)
//            painter->addExplosion(this->x,this->y);
//    }
    painter->draw3D();
}
Ejemplo n.º 4
0
bool getIterateSlowdownFlag()
{
    return !isSlowActive() || iterate_slowdown_flag;
}
Ejemplo n.º 5
0
void Stage::drawLayer(Layer* layer,bool alpha_enabled)
{
    //Animation speed
    if(layer->time_elapsed>layer->frame_duration)
    {
        layer->current_frame++;
        layer->time_elapsed=0;
    }

    //Loop animation
    if(getIterateSlowdownFlag())
        layer->time_elapsed++;

    if(layer->current_frame>=(int)layer->textures.size())
        layer->current_frame=0;

    //Get current image
    Image* texture=layer->textures[layer->current_frame];

    //Paint
    int size_x=layer->textures_size_x[layer->current_frame];
    int size_y=layer->textures_size_y[layer->current_frame];

    int pos_x=layer->alignment_x;
    int pos_y=painter->screen_height-size_y-layer->alignment_y;


	if(isSlowActive())
	{
		transparency_effect--;
	}else
	{
		transparency_effect++;
	}

	if(transparency_effect>255)
		transparency_effect=255;

	if(isSlowActive()
		&& receiver->isOuyaDown('m') && receiver->isOuyaDown('s'))
	{
		if(transparency_effect<64)
		{
			transparency_effect=64;
		}
	}else if(transparency_effect<128)
	{
		transparency_effect=128;
	}
/**/

    for(int i=0;i<painter->screen_width/(size_x+layer->separation_x)+2;i++)
    {
        painter->draw2DImage
        (   texture,
            size_x,size_y,
            pos_x+i*(size_x+layer->separation_x),pos_y,
            1.0,
            0.0,
            false,
            layer->depth_effect_x,
            layer->depth_effect_y,
            Color(255,255,255,transparency_effect),
            false,
            alpha_enabled);
    }

    if(layer->depth_effect_x>0)
    {
        if(painter->camera_x/layer->depth_effect_x>size_x+layer->separation_x+layer->alignment_x)
        {
            layer->alignment_x+=size_x+layer->separation_x;
        }
    }else if(layer->depth_effect_x<0)
    {
        if(painter->camera_x-layer->depth_effect_x>size_x+layer->alignment_x)
        {
            layer->alignment_x+=size_x;
        }
    }

}
Ejemplo n.º 6
0
Archivo: STG.cpp Proyecto: Rosalila/STG
void STG::logic()
{
    float distance_x=enemy->x - player->x;
    float distance_y=enemy->y - player->y;
    float distance=sqrt(distance_x*distance_x+distance_y*distance_y);
    float damage_level=6-distance/250.0;

    for (std::list<Pattern*>::iterator pattern = enemy->active_patterns->begin(); pattern != enemy->active_patterns->end(); pattern++)
    {
        Pattern*p=(Pattern*)*pattern;
        if(!p->is_hit)
        {
            for(int i=0;i<(int)p->bullet->hitboxes.size();i++)
            {
                Hitbox h=p->bullet->hitboxes[i]->getPlacedHitbox(p->x,p->y,p->getBulletAngle());
                if(player->isParrying() || player->isInvulnerable())
                {
                    if(!p->is_hit && p->collides_opponent && (player->collidesParry(h,0,0,0)||player->collides(h,0,0,0)))
                    {
                        p->hit(player->sound_channel_base+1,true);
                        rosalila()->graphics->point_explosion_effect->explode(p->x,p->y,Color(255,255,255,200),15);
                        if(player->isInvulnerable())
                        {
                            if(!player->isOnIntro())
                            {

                                int counter = rosalila()->api_integrator->getStat("TotalParryDashDestroys") + 1;
                                rosalila()->api_integrator->setStat("TotalParryDashDestroys",counter);

                                if(counter >= 15)
                                {
                                    rosalila()->api_integrator->unlockAchievement("ParryDash1");
                                }
                                if(counter >= 50)
                                {
                                    rosalila()->api_integrator->unlockAchievement("ParryDash2");
                                }
                                if(counter >= 200)
                                {
                                    rosalila()->api_integrator->unlockAchievement("ParryDash3");
                                }
                                if(counter >= 500)
                                {
                                    rosalila()->api_integrator->unlockAchievement("ParryDash4");
                                }

                                parry_dash_count++;
                                if(game_mode=="parry dash training" && parry_dash_count==parry_dash_count_objective)
                                {
                                    win();
                                }
                            }
                        }
                        if(game_mode=="parry training" || game_mode=="parry dash training")
                        {
                            player->parry(true);
                        }else
                        {
                            player->parry(false);
                        }
                        if(player->isParrying())
                        {
                            if(!player->isOnIntro())
                            {
                                if(player->invulnerable_frames_left==15)
                                {
                                    int counter = rosalila()->api_integrator->getStat("TotalParries") + 1;
                                    rosalila()->api_integrator->setStat("TotalParries",counter);

                                    if(counter >= 3)
                                    {
                                        rosalila()->api_integrator->unlockAchievement("Parry1");
                                    }
                                    if(counter >= 20)
                                    {
                                        rosalila()->api_integrator->unlockAchievement("Parry2");
                                    }
                                    if(counter >= 100)
                                    {
                                        rosalila()->api_integrator->unlockAchievement("Parry3");
                                    }
                                    if(counter >= 250)
                                    {
                                        rosalila()->api_integrator->unlockAchievement("Parry4");
                                    }
                                }
                                parry_count++;
                                if(game_mode=="parry training" && parry_count==parry_count_objective)
                                {
                                    win();
                                }
                            }
                        }
                        if(p->x>player->x)
                        {
                            p->angle=135;
                        }else
                        {
                            p->angle=-135;
                        }
                    }
                }else if(p->collides_opponent && player->collides(h,0,0,0))
                {
                    rosalila()->graphics->point_explosion_effect->explode(p->x,p->y,Color(255,255,255,200),p->bullet->damage);
                    p->hit(enemy->sound_channel_base+1,false);
                    if(!player_is_immortal)
                        player->hit(p->bullet->damage);
                    parry_count = 0;
                    rosalila()->graphics->screen_shake_effect.set(30,10,rosalila()->graphics->camera_x,rosalila()->graphics->camera_y);
                    if(rosalila()->sound->soundExists(player->name+".hit"))
                        rosalila()->sound->playSound(player->name+".hit", 3, 0, player->x, true);
                    if(player->hp==0)
                    {
                        lose();
                    }
                }
            }
        }
    }

    for (std::list<Pattern*>::iterator pattern = player->active_patterns->begin(); pattern != player->active_patterns->end(); pattern++)
    {
        Pattern*p=(Pattern*)*pattern;
        if(!p->is_hit)
        {
            for(int i=0;i<(int)p->bullet->hitboxes.size();i++)
            {
                Hitbox h=p->bullet->hitboxes[i]->getPlacedHitbox(p->x,p->y,p->getBulletAngle());
                if(p->collides_opponent && enemy->collides(h,0,0,0))
                {
                    rosalila()->graphics->point_explosion_effect->explode(p->x,p->y,Color(255,255,255,200),p->bullet->damage+damage_level*5);
                    p->hit(player->sound_channel_base+1,false);
                    enemy->hit(p->bullet->damage+damage_level);
                    enemy->shakeScreen(p->bullet->damage+damage_level*3,p->bullet->damage+damage_level*2);
                    if(rosalila()->sound->soundExists(enemy->name+".hit"))
                        rosalila()->sound->playSound(enemy->name+".hit", 1, 0, enemy->x, true);
                    if(enemy->hp==0)
                    {
                        win();
                    }
                }
            }
        }
    }

    //BulletxBullet Collision
    for (std::list<Pattern*>::iterator enemy_pattern_iterator = enemy->active_patterns->begin(); enemy_pattern_iterator != enemy->active_patterns->end(); enemy_pattern_iterator++)
    {
        Pattern*enemy_pattern=(Pattern*)*enemy_pattern_iterator;
        if(!enemy_pattern->is_hit)
        {
            for (std::list<Pattern*>::iterator player_pattern_iterator = player->active_patterns->begin(); player_pattern_iterator != player->active_patterns->end(); player_pattern_iterator++)
            {
                Pattern*player_pattern=(Pattern*)*player_pattern_iterator;
                if(player_pattern->collides_bullets||enemy_pattern->collides_bullets)
                {
                    if(!player_pattern->is_hit)
                    {
                        vector<Hitbox*>enemy_hitboxes=enemy_pattern->bullet->hitboxes;
                        for(int i=0;i<(int)enemy_hitboxes.size();i++)
                        {
                            Hitbox enemy_hitbox=enemy_hitboxes[i]->getPlacedHitbox(enemy_pattern->x,enemy_pattern->y,enemy_pattern->getBulletAngle());
                            vector<Hitbox*>player_hitboxes=player_pattern->bullet->hitboxes;
                            for(int j=0;j<(int)player_hitboxes.size();j++)
                            {
                                Hitbox player_hitbox=player_hitboxes[j]->getPlacedHitbox(player_pattern->x,player_pattern->y,player_pattern->getBulletAngle());
                                if(!enemy_pattern->is_hit&&!player_pattern->is_hit&&enemy_hitbox.collides(player_hitbox))
                                {
                                    if(!player->isOnIntro())
                                    {
                                        int counter = rosalila()->api_integrator->getStat("TotalChargeBulletDestroys") + 1;
                                        rosalila()->api_integrator->setStat("TotalChargeBulletDestroys",counter);

                                        if(counter >= 300)
                                        {
                                            rosalila()->api_integrator->unlockAchievement("ChargeDestroy1");
                                        }
                                        if(counter >= 1000)
                                        {
                                            rosalila()->api_integrator->unlockAchievement("ChargeDestroy2");
                                        }
                                        if(counter >= 5000)
                                        {
                                            rosalila()->api_integrator->unlockAchievement("ChargeDestroy3");
                                        }
                                        if(counter >= 10000)
                                        {
                                            rosalila()->api_integrator->unlockAchievement("ChargeDestroy4");
                                        }

                                        charge_destroy_count++;
                                        if(game_mode=="charge training" && charge_destroy_count==charge_destroy_count_objective)
                                        {
                                            win();
                                        }
                                    }
                                    enemy_pattern->hit(enemy->sound_channel_base+1,false);
                                    player_pattern->hit(player->sound_channel_base+1,false);
                                    rosalila()->graphics->point_explosion_effect->explode(enemy_pattern->x,enemy_pattern->y,Color(255,255,255,200),15);
                                }
                            }

                        }
                    }
                }
            }
        }
    }

    int stage_displacement = stage->velocity;
    if(isSlowActive())
        stage_displacement/=3;
    rosalila()->graphics->camera_x+=stage_displacement;
    player->logic(stage_displacement);
    player->x=player->x+stage_displacement;
    enemy->logic(stage_displacement,stage->name);
    //enemy->setX(enemy->x+stage_displacement);
    stage->logic();

    deletePatterns();
    checkCharacterOutOfBounds();
    slowExtraControl();

    if(api_state == "uploading score")
    {
        if(rosalila()->api_integrator->getState()=="finished")
        {
            uploadReplay();
            rosalila()->utility->writeLogLine("uploading replay");
        }

        if(rosalila()->api_integrator->getState()=="error")
        {
            uploadErrorLoop();
            uploadScore();
        }
    }
    if(api_state == "uploading replay")
    {
        if(rosalila()->api_integrator->getState()=="finished")
        {
            findLeaderboard();
            rosalila()->utility->writeLogLine("finding leaderboard");
        }

        if(rosalila()->api_integrator->getState()=="error")
        {
            uploadErrorLoop();
            uploadReplay();
        }
    }

    if(api_state == "finding leaderboard")
    {
        if(rosalila()->api_integrator->getState()=="finished")
        {
            rosalila()->graphics->notification_handler.interruptCurrentNotification();
            rosalila()->graphics->notification_handler.notifications.push_back(
                new Notification(getSuccessImage(), rosalila()->graphics->screen_width/2-getSuccessImage()->getWidth()/2,
                                    rosalila()->graphics->screen_height,
                                    rosalila()->graphics->screen_height-getSuccessImage()->getHeight(),
                                    getNotificationDuration()));

            api_state="";
            rosalila()->utility->writeLogLine("finished");
        }

        if(rosalila()->api_integrator->getState()=="error")
        {
            uploadErrorLoop();
            findLeaderboard();
        }
    }

    if(!getGameOver())
        frame++;
}