Ejemplo n.º 1
0
    explicit Star(Animation& animation)
    :   animation(animation)
    {
        color.setAlpha(255);
        double red = Gosu::random(40, 255);
        color.setRed(static_cast<Gosu::Color::Channel>(red));
        double green = Gosu::random(40, 255);
        color.setGreen(static_cast<Gosu::Color::Channel>(green));
        double blue = Gosu::random(40, 255);
        color.setBlue(static_cast<Gosu::Color::Channel>(blue));

        posX = Gosu::random(0, 640);
        posY = Gosu::random(0, 480);
    }
Ejemplo n.º 2
0
void RenderComponent::encodeWith(Json::Value *_val)
{
	if (m_Sprite) {
		(*_val)["Type"] = Json::Value("Sprite");
		(*_val)["Image"] = Json::Value(Gosu::narrow(m_Sprite->fileName()));
		(*_val)["Layer"] = Json::Value(m_Sprite->layer());
		
		(*_val)["xScale"] = Json::Value(m_Sprite->factX());
		(*_val)["yScale"] = Json::Value(m_Sprite->factY());
		(*_val)["CenterX"] = Json::Value(m_Sprite->centerX());
		(*_val)["CenterY"] = Json::Value(m_Sprite->centerY());
		
		(*_val)["Position"][0u] = Json::Value(m_Sprite->posX());
		(*_val)["Position"][1u] = Json::Value(m_Sprite->posY());

		
		(*_val)["Rotation"] = Json::Value(m_Sprite->angle());
		
		Gosu::Color color = m_Sprite->colorMod();
		(*_val)["ColorMod"][0u] = Json::Value(color.alpha());
		(*_val)["ColorMod"][1u] = Json::Value(color.red());
		(*_val)["ColorMod"][2u] = Json::Value(color.green());
		(*_val)["ColorMod"][3u] = Json::Value(color.blue());
	}else{
		(*_val)["Type"] = Json::Value("SpriteSheet");
		(*_val)["Image"] = Json::Value(Gosu::narrow(m_SpriteSheet->fileName()));
		(*_val)["Layer"] = Json::Value(m_SpriteSheet->layer());
		(*_val)["Width"] = Json::Value(m_SpriteSheet->width());
		(*_val)["Height"] = Json::Value(m_SpriteSheet->height());
		(*_val)["Duration"] = Json::Value(m_SpriteSheet->delay());
		
		(*_val)["xScale"] = Json::Value(m_SpriteSheet->factX());
		(*_val)["yScale"] = Json::Value(m_SpriteSheet->factY());
		(*_val)["CenterX"] = Json::Value(m_SpriteSheet->centerX());
		(*_val)["CenterY"] = Json::Value(m_SpriteSheet->centerY());
		
		(*_val)["Position"][0u] = Json::Value(m_SpriteSheet->posX());
		(*_val)["Position"][1u] = Json::Value(m_SpriteSheet->posY());
		
		Gosu::Color color = m_SpriteSheet->colorMod();
		(*_val)["ColorMod"][0u] = Json::Value(color.alpha());
		(*_val)["ColorMod"][1u] = Json::Value(color.red());
		(*_val)["ColorMod"][2u] = Json::Value(color.green());
		(*_val)["ColorMod"][3u] = Json::Value(color.blue());
	}
}
Ejemplo n.º 3
0
bool Gosu::Graphics::begin(Gosu::Color clearWithColor)
{
    // If recording is in process, cancel it.
    assert (pimpl->queues.size() == 1);
    pimpl->queues.resize(1);
    // Clear leftover clippings.
    pimpl->queues.front().clear();
    
    #ifdef GOSU_IS_IPHONE
    pimpl->updateBaseTransform();
    #endif
    glClearColor(clearWithColor.red() / 255.f, clearWithColor.green() / 255.f,
        clearWithColor.blue() / 255.f, clearWithColor.alpha() / 255.f);
    glClear(GL_COLOR_BUFFER_BIT);
    
    return true;
}
Ejemplo n.º 4
0
bool Gosu::Graphics::begin(Gosu::Color clearWithColor)
{
    // If there is a recording in process, stop it.
    // TODO: Raise exception?
    pimpl->queues.resize(1);
    // Clear leftover clippings.
    pimpl->queues.front().clear();
    
    pimpl->currentTransforms.resize(1);
    #ifdef GOSU_IS_IPHONE
    pimpl->updateBaseTransform();
    #endif
    pimpl->absoluteTransforms = pimpl->currentTransforms;
    
    glClearColor(clearWithColor.red()/255.0,
                 clearWithColor.green()/255.0,
                 clearWithColor.blue()/255.0,
                 clearWithColor.alpha()/255.0);
    glClear(GL_COLOR_BUFFER_BIT);
    
    return true;
}