Пример #1
0
bool MapNode::overlapsMap()
{
    if(map == NULL)
        return false;

    for(int x = getX(); x < getX2(); x+= map->getTileWidth())
    {
        for(int y = getY(); y < getY2(); y+= map->getTileHeight())
        {
            if(map->checkSolid(x/map->getTileWidth(), y/map->getTileHeight()))
            {
                return true;
            }
        }

        if(map->checkSolid(x/map->getTileWidth(), getY2()/map->getTileHeight()))
        {
            return true;
        }
    }

    for(int y = getY(); y < getY2(); y+= map->getTileHeight())
    {
        if(map->checkSolid(getX2()/map->getTileWidth(), y/map->getTileHeight()))
        {
            return true;
        }
    }

    return map->checkSolid(getX2()/map->getTileWidth(), getY2()/map->getTileHeight());
}
Пример #2
0
void MapNode::move(int x, int y) {
	if (!solid || map == NULL) {
		setX(getX() + x);
		setY(getY() + y);
		return;
	}
	setX(getX() + x);
	if (x < 0) {
		if (overlapsMap()) {
			setX(((getX() / map->getTileWidth()) + 1) * map->getTileWidth());
		}
	}
	if (x > 0) {
		if (overlapsMap()) {
			setX2((getX2() / map->getTileWidth()) * map->getTileWidth() - 1);
		}
	}
	setY(getY() + y);
	if (y < 0) {
		if (overlapsMap()) {
			setY(((getY() / map->getTileHeight()) + 1) * map->getTileHeight());
		}
	}
	if (y > 0) {
		if (overlapsMap()) {
			setY2((getY2() / map->getTileHeight()) * map->getTileHeight() - 1);
		}
	}
}
/// Draw the Slider
void Slider::draw() const
{
    if(showing)
    {
        if( type == HORIZONTAL )
        {
            gl::color( ColorA( 0.2,0.3,0.4, alpha) );
            gl::drawSolidRoundedRect( *this, 5.0, 32 );
          
            Rectf pctg_rect = Rectf( Vec2f( getX1(), getY1() ), Vec2f( getX1() + pctg*getWidth(), getY2() ) ) ;
            gl::color( color );
            gl::drawSolidRoundedRect( pctg_rect, 5.0, 32);
        }
        else if( type == VERTICAL )
        {
            gl::color( ColorA( 0.2,0.3,0.4, alpha) );
            gl::drawSolidRoundedRect( *this, 5.0, 32 );
           
            Rectf pctg_rect = Rectf( Vec2f( getX1(), getY2() - pctg*getHeight() ), Vec2f( getX2(), getY2() ) ) ;
            gl::color( color );
            gl::drawSolidRoundedRect( pctg_rect, 5.0, 32);
        }
        else if( type == CIRCULAR )
        {
            gl::color( ColorA( 0.2,0.3,0.4, alpha) );
            _drawArc( getCenter(), getWidth(), getHeight(), 0.0, 2*3.14159     , 10 );
            gl::color( color );
            _drawArc( getCenter(), getWidth(), getHeight(), 0.0, 2*3.14159*pctg, 7 );
        }
    }
}
Пример #4
0
bool Rectangle::contains(int x, int y)
{
    if(x >= getX() && y >= getY() && x <= getX2() && y <= getY2())
        return true;

    return false;
}
void Utility::Yuv422FileSaver::savePlanar() {
	for(std::size_t k=0; k<video_->getNumberOfFrames()&&isRunning_; k++) {
		QVector<unsigned char> uBuffer;
		QVector<unsigned char> vBuffer;
		auto frame=video_->getFrame(k);
		for(int i=0; i<width_*height_; i+=2) {
			int y1=i/width_;
			int x1=i%width_;
			int y2=(i+1)/width_;
			int x2=(i+1)%width_;

			if(!frame->valid(x1,y1)||!frame->valid(x2,y2)) {
				qDebug()<<"Wrong pixel coordinates";
				continue;
			}

			auto vec=Rgb888ToYuv422(frame->pixel(x1,y1),frame->pixel(x2,y2));
			dataStream_<<vec.getY1()<<vec.getY2();
			uBuffer.push_back(vec.getU());
			vBuffer.push_back(vec.getV());
		}
		while (!uBuffer.isEmpty()) {
			dataStream_<<uBuffer.takeFirst();
		}
		while (!vBuffer.isEmpty()) {
			dataStream_<<vBuffer.takeFirst();
		}
	}
}
Пример #6
0
void BossEntity::updateMoving()
{
    setY(getY()+yVel);

    if(getY() < camera->getY())
    {
        yVel = ENTITY_SPEED;
    }

    if(getY2() > camera->getY2())
    {
        yVel = -ENTITY_SPEED;
    }

    if(rand()%100 == 1)
    {
        state = STATE_ATTACKING;
        attackCounter = 0;
    }

    if(health <= 200)
    {
        panicCounter = 0;
        state = STATE_PANIC;
    }
}
Пример #7
0
//----------------------------------------------------------
bool Rect::operator == (const Rect & rect) const {
    bool bSame = true;
    bSame = bSame && (getX1() == rect.getX1());
    bSame = bSame && (getX2() == rect.getX2());
    bSame = bSame && (getY1() == rect.getY1());
    bSame = bSame && (getY2() == rect.getY2());
    return bSame;
}
void TestYuv411FileSaver::testRgb888ToYuv411() {
	auto vector = Utility::Yuv411FileSaver::Rgb888ToYuv411(pixel1,pixel2,pixel3,pixel4);
	QVERIFY(vector.getY1() == 16);
	QVERIFY(vector.getU() == 128);
	QVERIFY(vector.getV() == 128);
	QVERIFY(vector.getY2() == 16);
	QVERIFY(vector.getY3() == 16);
	QVERIFY(vector.getY4() == 16);
}
Пример #9
0
void QFCropPixelsEdit::spinValueChanged()
{
    connectWidgets(false);
    if (spinX2->value()<=spinX1->value()) {
        spinX1->setValue(spinX2->value()+1);
    }
    if (spinY2->value()<=spinY1->value()) {
        spinY1->setValue(spinY2->value()+1);
    }
    connectWidgets(true);
    emit valueChanged(getX1(), getX2(), getY1(), getY2());
}
Пример #10
0
std::vector<Line> HourGlass::getLines() const {
  std::vector<Line> lines;
  float x1 = getX1()+2;
  float x2 = getX2()-2;
  float y1 = getY1()+2;
  float y2 = getY2()-2;
  lines.push_back(Line(x1,y1,x2,y2));
  lines.push_back(Line(x2,y1,x1,y2));
  lines.push_back(Line(x1,y1,x2,y1));
  lines.push_back(Line(x1,y2,x2,y2));
  return lines;
}
Пример #11
0
//----------------------------------------------------------
void Rect::lerp(const Rect & rect, float p) {

    float _x1 = coc::lerp(getX1(), rect.getX1(), p);
    float _x2 = coc::lerp(getX2(), rect.getX2(), p);
    float _y1 = coc::lerp(getY1(), rect.getY1(), p);
    float _y2 = coc::lerp(getY2(), rect.getY2(), p);

    setX1(_x1);
    setX2(_x2);
    setY1(_y1);
    setY2(_y2);
}
Пример #12
0
bool Rectangle::overlaps(Rectangle rect)
{
    if(getX() > rect.getX2())
        return false;

    if(getY() > rect.getY2())
        return false;

    if(rect.getX() > getX2())
        return false;

    if(rect.getY() > getY2())
        return false;

    return true;
}
Пример #13
0
void BossEntity::updatePanic()
{
    getScene()->addNode(factory->makeEntity(ENTITY_SILENT_EXPLOSION, getX() + rand()%getWidth(), getY() + rand()%getHeight()));

    panicCounter++;

    if(panicCounter > 100)
        panicCounter = 0;


    setY(getY()+yVel);

    if(getY() < camera->getY())
    {
        yVel = ENTITY_SPEED;
    }

    if(getY2() > camera->getY2())
    {
        yVel = -ENTITY_SPEED;
    }

    if(panicCounter %5 != 0)
        return;

    if(health < 0)
    {
        remove();
    }

    if(panicCounter > 10 && panicCounter < 30)
    {
        getScene()->addNode(factory->makeEntity(ENTITY_ENEMY_BULLET, getX(), getY()+(rand()%getHeight())));
    }

    if(panicCounter > 30 && panicCounter < 60 && rand()%4)
    {
        getScene()->addNode(factory->makeEntity(ENTITY_ALIEN_SCOUT, getX(), getY()+(rand()%getHeight())));
    }

    if(panicCounter > 60 && panicCounter < 100 && rand()%4)
    {
        getScene()->addNode(factory->makeEntity(ENTITY_ALIEN_SCOUT, getX(), getY()+(rand()%getHeight())));
        getScene()->addNode(factory->makeEntity(ENTITY_ENEMY_BULLET, getX(), getY()+(rand()%getHeight())));
    }
}
Пример #14
0
void BossEntity::updateAttacking()
{
    attackCounter++;

    if(attackCounter == 10)
    {
        for(int i = 0; i < getHeight(); i+= getHeight()/5)
        {
            getScene()->addNode(factory->makeEntity(ENTITY_ENEMY_BULLET, getX(), getY()+i));
        }
    }

    if(attackCounter > 20)
    {
        setY(getY()+yVel);

        if(getY() < camera->getY())
        {
            yVel = ENTITY_SPEED;
        }

        if(getY2() > camera->getY2())
        {
            yVel = -ENTITY_SPEED;
        }
    }

    if(attackCounter == 30)
    {
        for(int i = 0; i < getHeight(); i+= getHeight()/5)
        {
            getScene()->addNode(factory->makeEntity(ENTITY_ALIEN_SCOUT, getX(), getY()+i));
        }
    }

    if(attackCounter >= 50)
    {
        for(int i = 0; i < getHeight(); i+= getHeight()/10)
        {
            getScene()->addNode(factory->makeEntity(ENTITY_ENEMY_BULLET, getX(), getY()+i));
        }

        state = STATE_MOVING;
    }
}
void Utility::Yuv422FileSaver::savePacked() {
	for(std::size_t k=0; k<video_->getNumberOfFrames()&&isRunning_; k++) {
		auto frame=video_->getFrame(k);
		for(int i=0; i<width_*height_; i+=2) {
			int y1=i/width_;
			int x1=i%width_;
			int y2=(i+1)/width_;
			int x2=(i+1)%width_;

			if(!frame->valid(x1,y1)||!frame->valid(x2,y2)) {
				qDebug()<<"Wrong pixel coordinates";
				continue;
			}

			auto vec=Rgb888ToYuv422(frame->pixel(x1,y1),frame->pixel(x2,y2));
			dataStream_<<vec.getU()<<vec.getY1()<<vec.getV()<<vec.getY2();
		}
	}
}
Пример #16
0
/** Other Functions **/
void Wall::draw(Renderer & g_renderer)
{
	/*
	* Draw the line for this Wall object. Use the simple SDL
	* functions. The hexidecimal can also be written as decimal.
	*/
	SDL_SetRenderDrawColor(g_renderer, 0x20, 0x20, 0x20, 0x20);
	SDL_RenderDrawLine(g_renderer, getX(), getY(), getX2(), getY2());
	/*
	int y = getY();
	int z;
	do
	{
		SDL_RenderDrawPoint(g_renderer, getX(), y);
		if (getO() == TOP) y--;
		else y++;
		std::cin >> z;
	} while (y != 0 && y != 479);
	*/
}
Пример #17
0
int QFCropPixelsEdit::getHEIGHT() const
{
    return getY2()-getY1()+1;
}
Пример #18
0
int Line::interpolate(int x){
    float f;
    f = ( ( x - getX() )*( getY2() - getY()) / ( getX2() - getX()) ) + getY();
    return round(f);

}
Пример #19
0
void Line::check(){
    cout << "------------ LINE PARAMETERS -------------" << endl;
    cout << "Position: " << Shape::getX() << "*" << getY() << " (X,Y)" << endl;
    cout << "End: " << getX2() << "*" << getY2() << " (X2,Y2)" << endl;
    cout << "------------------------------------------" << endl;
}
Пример #20
0
void UMLInheritanceLink::draw(Gtk::DrawingArea* drawingArea)
{
	Cairo::RefPtr<Cairo::Context> cr = drawingArea->get_window()->create_cairo_context();

	Arrows::draw_arrow(cr, getX1(), getY1(), getX2(), getY2(), Line::FULL, Arrow::NORMAL, Arrow::NONE, isSelected());
}