コード例 #1
0
ファイル: Stage.cpp プロジェクト: Rosalila/STG-Android
void Stage::logic()
{
    if(getIterateSlowdownFlag())
        iterator++;

    if(dialogues.find(iterator)!=dialogues.end())
    {
        active_dialogues.push_back(dialogues[iterator]);
    }

    std::list<Dialogue*>::iterator i = active_dialogues.begin();
    while (i != active_dialogues.end())
    {
        Dialogue*d=(Dialogue*)*i;
        d->logic();
        if (d->destroyFlag())
        {
            active_dialogues.erase(i++);
        }
        else
        {
            ++i;
        }
    }
}
コード例 #2
0
ファイル: Enemy.cpp プロジェクト: Turupawn/DemoFlatShooter
void Enemy::logic(int stage_velocity, string stage_name, int global_iteration, string username)
{
    animationControl();
    spellControl(stage_velocity);

    for (std::list<Pattern*>::iterator pattern = active_patterns->begin(); pattern != active_patterns->end(); pattern++) {
        Pattern* p =  (Pattern*)*pattern;
        double distance_x= player->getHitbox().getX() - p->getX();
        double distance_y= player->getHitbox().getY() - p->getY();

        if (p->getHoming() != 0)
        {
            p->setAngle(-atan2(distance_y,distance_x)*180/PI);
        }
        else if(p->getAimPlayer())
        {
            p->setAngle(p->getAngle()-atan2(distance_y,distance_x)*180/PI);
        }


    }


    if(this->hp>0)
        modifiersControl();
    else
    {
        if(orientation!="destroyed" && flag_begin_upload)
        {
            orientation="destroyed";
            if(this->sonido->soundExists(name+".destroyed"))
                this->sonido->playSound(name+".destroyed");

            this->hitbox.setValues(0,0,0,0,0);

            //Delete bullets
            std::list<Pattern*>* active_patterns=getActivePatterns();
            std::list<Pattern*>::iterator i = active_patterns->begin();
            while (i != active_patterns->end())
            {
                Pattern*p=(Pattern*)*i;
                active_patterns->erase(i++);
                delete p;
            }

//            RosalilaNetwork network(painter);
//            //score_upload_message = network.runTcpClientSendScore(31716, "108.59.1.187",stage_name, username, global_iteration);
//            score_upload_message = network.runTcpClientSendScore(31716, "localhost",stage_name, username, global_iteration);
        }
    }

    this->angle+=this->angle_change / getSlowdown();

    this->x += cos (angle*PI/180) * velocity / getSlowdown() + stage_velocity;
    this->y -= sin (angle*PI/180) * velocity / getSlowdown();

    getIterateSlowdownFlag();
}
コード例 #3
0
void Character::animationControl()
{
    if(orientation=="destroyed")
        visible=false;
    if(animation_iteration>=animation_velocity)
    {
        current_sprite++;
        if(current_sprite>=(int)sprites[orientation].size())
        {
            current_sprite=0;
        }
        animation_iteration=0;
    }
    if(getIterateSlowdownFlag())
        animation_iteration++;
}
コード例 #4
0
ファイル: Enemy.cpp プロジェクト: Turupawn/DemoFlatShooter
void Enemy::modifiersControl()
{
    bool flag_iterator_change=false;

    vector<Modifier*>* current_modifiers = this->modifiers[iteration];
    if(current_modifiers!=NULL)
    {
        for(int i=0; i<(int)current_modifiers->size(); i++)
        {
            Modifier* modifier=(*current_modifiers)[i];
            if(modifier->variable=="velocity")
            {
                this->velocity=atoi(modifier->value.c_str());
            }
            if(modifier->variable=="angle")
            {
                this->angle=atoi(modifier->value.c_str());
            }
            if(modifier->variable=="angle_change")
            {
                this->angle_change=atoi(modifier->value.c_str());
            }
            if(modifier->variable=="iterator")
            {
                this->iteration=atoi(modifier->value.c_str());
                flag_iterator_change=true;
            }
            if(modifier->variable=="pattern_type")
            {
                //Reset cooldowns
                for(int i=0; i<type[current_type].size(); i++)
                {
                    type[current_type][i]->current_cooldown=0;
                    type[current_type][i]->current_startup=0;
                    type[current_type][i]->iteration=0;
                    type[current_type][i]->state="startup";
                }
                this->current_type=modifier->value;
            }
        }
    }

    if(!flag_iterator_change && getIterateSlowdownFlag())
        iteration++;
}
コード例 #5
0
ファイル: Stage.cpp プロジェクト: Rosalila/STG
void Stage::logic()
{
    if(getIterateSlowdownFlag())
        iterator++;
}
コード例 #6
0
ファイル: Stage.cpp プロジェクト: Rosalila/STG
void Stage::drawLayer(Layer* layer)
{
    //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->layer_frames.size())
        layer->current_frame=0;

    if(getGameOver())
    {
        if(getPlayerWon())
        {
            layer_transparency=128;
        }else
        {
            layer->color.red -= 3;
            layer->color.green -= 3;
            layer->color.blue -= 3;
            if(layer->color.red < 0)
                layer->color.red = 0;
            if(layer->color.green < 0)
                layer->color.green = 0;
            if(layer->color.blue < 0)
                layer->color.blue = 0;
        }
    }

    //Paint

    LayerFrame* current_layer_frame = layer->layer_frames[layer->current_frame];

    int frame_width=current_layer_frame->width;
    int frame_heigth=current_layer_frame->height;

    vector<DrawableRectangle*>rectangles;

    for(int i=0;i<rosalila()->graphics->screen_width/(frame_width+layer->separation_x)+2;i++)
    {

        int pos_x = layer->alignment_x + i*(frame_width+layer->separation_x);
        int pos_y = rosalila()->graphics->screen_height - frame_heigth - layer->alignment_y;

        if(current_layer_frame->type == "image")
        {
            Image* image = current_layer_frame->image;

            rosalila()->graphics->draw2DImage
            (   image,
                frame_width,frame_heigth,
                pos_x,pos_y,
                1.0,
                0.0,
                false,
                layer->depth_effect_x,
                layer->depth_effect_y,
                Color(layer->color.red,layer->color.green,layer->color.blue,layer->color.alpha),
                0,0,
                false,
                FlatShadow());
        }
        if(current_layer_frame->type == "rectangle")
        {
            rectangles.push_back(new DrawableRectangle(pos_x,pos_y,frame_width,frame_heigth,0,Color(layer->color.red,layer->color.green,layer->color.blue,layer->color.alpha)));
        }
    }

    rosalila()->graphics->drawRectangles(rectangles,layer->depth_effect_x,layer->depth_effect_y,true);

    for(int i=0;i<(int)rectangles.size();i++)
    {
        delete rectangles[i];
    }

    if(layer->depth_effect_x>0)
    {
        if(rosalila()->graphics->camera_x/layer->depth_effect_x>frame_width+layer->separation_x+layer->alignment_x)
        {
            layer->alignment_x+=frame_width+layer->separation_x;
        }
    }else if(layer->depth_effect_x<0)
    {
        if(rosalila()->graphics->camera_x*-layer->depth_effect_x > frame_width+layer->separation_x+layer->alignment_x)
        {
            layer->alignment_x+=frame_width+layer->separation_x;
        }
    }

}
コード例 #7
0
ファイル: Stage.cpp プロジェクト: Rosalila/STG-Android
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;
        }
    }

}