Пример #1
0
void Ground::update(int deltaTime)
{

    setOffsetX(getOffsetX() - (getVelocityX() * (deltaTime/1000.0f)));
    //cout << "Ground Offset X: " << getOffsetX() << endl;
    if (getOffsetX() <= -808.0f)
    {
        setOffsetX(0.0f);
    }

    //Shift the collision boxes
    shiftCollisionBoxes();

}
Пример #2
0
/*
 * This is the plane's constructor
 */
Plane::Plane() : collisionBoxes_(7) {
    //Randomly select color of the plane from the start
    srand(time(0));
    color_ = (Color)(rand() % 4);

    //Initialize the motion of the plane
    motion_ = MOTION_Falling;
    //Initialize the frame counter
    frameCounter_ = 0;

    //Initialize the offset x and offset y of the plane
    //The offset x of the plane is constant
    setOffsetX(INITIAL_OFFSET_X);
    setOffsetY(INITIAL_OFFSET_Y);

    //Set the width and height of the plane
    //Width and height are constant
    setSourceWidth(SPRITE_WIDTH);
    setSourceHeight(SPRITE_HEIGHT);

    //Velocity of plane on the x axis is constant and does not change
    setVelocityX(0.0f);
    setVelocityY(0.0f);

    elapseTime_ = 0;

    puffCloud_.setOffsetY(getOffsetY() + 10.0f);


    //Initialize the collision boxes width and height
    for (int i = 0; i < collisionBoxes_.size(); i++) {
        collisionBoxes_[i].w = COLLISION_BOX_W[i];
        collisionBoxes_[i].h = COLLISION_BOX_H[i];
    }
}
Пример #3
0
/*
 * The ground class constructor
 */
Ground::Ground() : collisionBoxes_(34), collisionBoxes_Loop_(34)
{
    //Randomly initialize the type of the ground
    srand(time(0));
    type_ = (Type)(rand() % 4);

    //Set the initial location of the ground
    setOffsetX(INITIAL_OFFSET_X);
    setOffsetY(INITIAL_OFFSET_Y);

    //Initialize the ground's velocity
    setVelocityX(GROUND_VELOCITY_X);
    setVelocityY(GROUND_VELOCITY_Y);

    //Initialize the width and height of the collision boxes
    for (int i = 0; i < collisionBoxes_.size(); i++)
    {

        collisionBoxes_[i].w = COLLISION_BOX_W[i];
        collisionBoxes_[i].h = COLLISION_BOX_H[i];
    }


    for (int i = 0; i < collisionBoxes_Loop_.size(); i++)
    {

        collisionBoxes_Loop_[i].w = COLLISION_BOX_W[i];
        collisionBoxes_Loop_[i].h = COLLISION_BOX_H[i];
    }

}
Пример #4
0
	int32_t LuaDrawable::setOffsetX(lua_State *L)
	{
		auto drawable = Lua::getObject<Drawable>(L, 1, LuaType::Drawable);
		auto offsetX = static_cast<float>(Lua::getNumber(L, 2));
		drawable->setOffsetX(offsetX);
		return 0;
	}
Пример #5
0
Background::Background()
{
    setOffsetX(INITIAL_OFFSET_X);
    setOffsetY(INITIAL_OFFSET_Y);

    setSourceWidth(BACKGROUND_WIDTH);
    setSourceHeight(BACKGROUND_HEIGHT);
}
Пример #6
0
PuffCloud::PuffCloud()
{
    frameCounter_ = 0;
    elapseTime_ = 0;

    //The x offset of the cloud is constant and does not change
    setOffsetX(INITIAL_OFFSET_X);

    //Set the initial source width of the cloud
    setSourceWidth(CLOUD_WIDTH[frameCounter_]);
    setSourceHeight(CLOUD_HEIGHT[frameCounter_]);


}
Пример #7
0
/**
 * Slot for horizontal scroll events.
 */
void QG_GraphicView::slotHScrolled(int value) {
    // Scrollbar behaviour tends to change with every Qt version..
    // so let's keep old code in here for now

    //static int running = false;
    //if (!running) {
    //running = true;
    ////RS_DEBUG->print("value x: %d\n", value);
    if (hScrollBar->maximum()==hScrollBar->minimum()) {
        centerOffsetX();
    } else {
        setOffsetX(-value);
    }
    //if (isUpdateEnabled()) {
//         updateGrid();
    redraw();
}
Пример #8
0
int Tiled::Internal::ResizeHelper::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: offsetChanged((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
        case 1: offsetXChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 2: offsetYChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: offsetBoundsChanged((*reinterpret_cast< const QRect(*)>(_a[1]))); break;
        case 4: setOldSize((*reinterpret_cast< const QSize(*)>(_a[1]))); break;
        case 5: setNewSize((*reinterpret_cast< const QSize(*)>(_a[1]))); break;
        case 6: setOffset((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
        case 7: setOffsetX((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 8: setOffsetY((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 9: setNewWidth((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 10: setNewHeight((*reinterpret_cast< int(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 11;
    }
    return _id;
}
Пример #9
0
void RS_GraphicView::setOffset(int ox, int oy) {
	//    DEBUG_HEADER
	//    RS_DEBUG->print(/*RS_Debug::D_WARNING, */"set offset from (%d, %d) to (%d, %d)", getOffsetX(), getOffsetY(), ox, oy);
	setOffsetX(ox);
	setOffsetY(oy);
}
Пример #10
0
void File::_initialize()
{
    if (_initialized) return;
    Dat::Item::_initialize();
    Dat::Item::setPosition(0);

    _version = uint32();
    _framesPerSecond = uint16();
    _actionFrame = uint16();
    _framesPerDirection = uint16();

    uint16_t shiftX[6];
    uint16_t shiftY[6];
    uint32_t dataOffset[6];
    for (unsigned int i = 0; i != 6; ++i) shiftX[i] = uint16();
    for (unsigned int i = 0; i != 6; ++i) shiftY[i] = uint16();
    for (unsigned int i = 0; i != 6; ++i)
    {
        dataOffset[i] = uint32();
        if (i > 0 && dataOffset[i-1] == dataOffset[i])
        {
            continue;
        }

        auto direction = new Direction();
        direction->setDataOffset(dataOffset[i]);
        direction->setShiftX(shiftX[i]);
        direction->setShiftY(shiftY[i]);
        _directions.push_back(direction);
    }

    // for each direction
    for (auto direction : _directions)
    {
        // jump to frames data at frames area
        Dat::Item::setPosition(direction->dataOffset() + 62);

        // read all frames
        for (unsigned i = 0; i != _framesPerDirection; ++i)
        {            
            uint16_t width = uint16();
            uint16_t height = uint16();
            auto frame = new Frame(width, height);

            // Number of pixels for this frame
            // We don't need this, because we already have width*height
            uint32();

            frame->setOffsetX(int16());
            frame->setOffsetY(int16());

            // Pixels data
            for (unsigned y = 0; y != frame->height(); ++y)
            {
                for (unsigned x = 0; x != frame->width(); ++x)
                {
                    frame->setIndex(x, y, uint8());
                }
            }
            direction->frames()->push_back(frame);
        }
    }
}