void World::buildScene() { for (std::size_t i = 0; i < LayerCount; ++i) { SceneNode::Ptr layer(new SceneNode()); mSceneLayers[i] = layer.get(); mSceneGraph.attachChild(std::move(layer)); } sf::Texture& texture = mTextures.get(Textures::ID::Desert); sf::IntRect textureRect(mWorldBounds); texture.setRepeated(true); std::unique_ptr<SpriteNode> backgroundSprite(new SpriteNode(texture, textureRect)); backgroundSprite->setPosition(mWorldBounds.left, mWorldBounds.top); mSceneLayers[Layer::Background]->attachChild(std::move(backgroundSprite)); std::unique_ptr<Aircraft> leader(new Aircraft(Aircraft::Type::Eagle, mTextures)); mPlayerAircraft = leader.get(); mPlayerAircraft->setPosition(mSpawnPosition); mPlayerAircraft->setVelocity(0.f, mScrollSpeed); mSceneLayers[Layer::Air]->attachChild(std::move(leader)); std::unique_ptr<Aircraft> leftEscort(new Aircraft(Aircraft::Type::Raptor, mTextures)); leftEscort->setPosition(-80.f, 50.f); mPlayerAircraft->attachChild(std::move(leftEscort)); std::unique_ptr<Aircraft> rightEscort(new Aircraft(Aircraft::Type::Raptor, mTextures)); rightEscort->setPosition(80.f, 50.f); mPlayerAircraft->attachChild(std::move(rightEscort)); }
bool CCControlBase::initWithBackGroundSprite( const char* backgroundSpriteName ) { CCScale9Sprite* backgroundSprite(nullptr); if(isEmptyString(backgroundSpriteName) == false) { backgroundSprite = CCScale9Sprite::create(backgroundSpriteName); } return initWithBackGroundSprite(backgroundSprite); }
void World::buildScene(const Controller& controller) { // Initialize the different scene graph layers for(std::size_t i = 0; i < SceneNode::Layers::Num; i++) { SceneNode::upScNode layer(new SceneNode()); mSceneLayers.at(i) = layer.get(); mSceneGraph.addChild(std::move(layer)); } sf::Vector2f bckgrndSpritePos(mWorldBounds.width / 2.f , mWorldBounds.height / 2.f); std::unique_ptr<SpriteNode> backgroundSprite(new SpriteNode(controller.getTexture(Controller::Textures::GameBackground) , bckgrndSpritePos , true)); mBackground = backgroundSprite.get(); mSceneLayers.at(SceneNode::Layers::Background)->addChild(std::move(backgroundSprite)); mLevel.generateLevel(mSceneLayers, controller); generateAgents(controller); }
void World::buildScene() { // Initialize the different layers for (std::size_t i = 0; i < LayerCount; ++i) { Category::Type category = (i == Air) ? Category::SceneAirLayer : Category::None; SceneNode::Ptr layer(new SceneNode(category)); mSceneLayers[i] = layer.get(); mSceneGraph.attachChild(std::move(layer)); } // Prepare the tiled background sf::Texture& texture = mTextures.get(Textures::Desert); sf::IntRect textureRect(mWorldBounds); texture.setRepeated(true); // Add the background sprite to the scene std::unique_ptr<SpriteNode> backgroundSprite(new SpriteNode(texture, textureRect)); backgroundSprite->setPosition(mWorldBounds.left, mWorldBounds.top); mSceneLayers[Background]->attachChild(std::move(backgroundSprite)); // Add player's aircraft std::unique_ptr<Aircraft> player(new Aircraft(Aircraft::Eagle, mTextures, mFonts)); mPlayerAircraft = player.get(); mPlayerAircraft->setPosition(mSpawnPosition); mSceneLayers[Air]->attachChild(std::move(player)); // Add enemy aircraft addEnemies(); }
void World::buildScene() { // Initialize the different layers for (std::size_t i = 0; i < Layer::count; i++) { SceneNode::Ptr layer(new SceneNode()); sceneLayers[i] = layer.get(); sceneGraph.attachChild(std::move(layer)); } // Prepare the title background sf::Texture &texture = textures.get(Textures::Desert); sf::IntRect textureRect(worldBounds); texture.setRepeated(true); // Add the background sprite to the scene std::unique_ptr<SpriteNode> backgroundSprite(new SpriteNode(texture, textureRect)); backgroundSprite->setPosition(worldBounds.left, worldBounds.top); sceneLayers[Background]->attachChild(std::move(backgroundSprite)); // Add player's aircraft std::unique_ptr<Aircraft> leader(new Aircraft(Aircraft::Eagle, textures)); playerAircraft = leader.get(); playerAircraft->setPosition(spawnPosition); playerAircraft->setVelocity(40.f, scrollSpeed); sceneLayers[Air]->attachChild(std::move(leader)); // Add two escorting aircrafts, placed relatively to the main plane std::unique_ptr<Aircraft> leftEscort(new Aircraft(Aircraft::Raptor, textures)); leftEscort->setPosition(-80.f, 50.f); playerAircraft->attachChild(std::move(leftEscort)); std::unique_ptr<Aircraft> rightEscort(new Aircraft(Aircraft::Raptor, textures)); rightEscort->setPosition(80.f, 50.f); playerAircraft->attachChild(std::move(rightEscort)); }
void TestMap::buildScene() { for (std::size_t i = 0; i < LayerCount; ++i) { SceneNode::Ptr layer(new SceneNode()); mSceneLayers[i] = layer.get(); mSceneGraph.attachChild(std::move(layer)); } // Prepare the tiled background sf::Texture& texture = mTextures.get(Textures::Desert); sf::IntRect textureRect(mWorldBounds); texture.setRepeated(false); // Add the background sprite to the scene std::unique_ptr<SpriteNode> backgroundSprite(new SpriteNode(texture, textureRect)); backgroundSprite->setPosition(mWorldBounds.left, mWorldBounds.top); mSceneLayers[Background]->attachChild(std::move(backgroundSprite)); /*std::unique_ptr<Character> player(new Character(mTextures)); mCharacter = player.get(); mCharacter->setPosition(mWorldBounds.height / 2.f, 50.f); mSceneLayers[NPC]->attachChild(std::move(player));*/ }
int main() { sf::RenderWindow window(sf::VideoMode(800, 600), "Vehicle Handling"); sf::Clock deltaClock, frameClock; window.setFramerateLimit(60); Car car; sf::Texture backgroudTexture; backgroudTexture.loadFromFile("background2.jpg"); sf::Sprite backgroundSprite(backgroudTexture); backgroundSprite.setScale(3,3); while(window.isOpen()) { sf::Event event; while(window.pollEvent(event)) { if (event.type == sf::Event::Closed || (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)) window.close(); } float deltaTime = deltaClock.restart().asSeconds(); frameClock.restart(); window.clear(); window.draw(backgroundSprite); car.checkInputs(deltaTime); car.drawCarInWindow(window); window.display(); const float time = 1.f / frameClock.getElapsedTime().asSeconds(); window.setTitle("Titlu"); } return 0; }
void World::Impl::BuildScene() { for ( std::size_t i = 0; i < LayerCount; ++i ) { Category::Type category = ( i == LowerAir ) ? Category::SceneAirLayer : Category::None; SceneNode::SceneNodePtr layer( new SceneNode( category ) ); mSceneLayers[ i ] = layer.get(); mSceneGraph.AttachChild( std::move( layer ) ); } sf::Texture & texture = mTextures.Get( Texture::Jungle ); texture.setRepeated( true ); float viewHeight = mWorldView.getSize().y; sf::IntRect textureRect( mWorldBounds ); textureRect.height += static_cast<int>( viewHeight ); std::unique_ptr< SpriteNode > backgroundSprite( new SpriteNode( texture, textureRect ) ); backgroundSprite->setPosition( mWorldBounds.left, mWorldBounds.top - viewHeight ); mSceneLayers[ Background ]->AttachChild( std::move( backgroundSprite ) ); // Add particle node to the scene std::unique_ptr<ParticleNode> smokeNode( new ParticleNode( Particle::Type::Smoke, mTextures ) ); mSceneLayers[ LowerAir ]->AttachChild( std::move( smokeNode ) ); // Add propellant particle node to the scene std::unique_ptr<ParticleNode> propellantNode( new ParticleNode( Particle::Type::Propellant, mTextures ) ); mSceneLayers[ LowerAir ]->AttachChild( std::move( propellantNode ) ); // Add sound effect node std::unique_ptr< SoundNode > soundNode( new SoundNode( mSounds ) ); mSceneGraph.AttachChild( std::move( soundNode ) ); // Add network node, if necessary if ( mNetworkedWorld ) { std::unique_ptr<NetworkNode> networkNode( new NetworkNode() ); mNetworkNode = networkNode.get(); mSceneGraph.AttachChild( std::move( networkNode ) ); } b2BodyDef BodyDef; BodyDef.position = b2Vec2( 100.f / 2 / PhysicsNode::Scale, 16.f / 2 / PhysicsNode::Scale ); BodyDef.type = b2_staticBody; b2Body* Body = mPhysics.CreateBody( &BodyDef ); b2PolygonShape Shape; Shape.SetAsBox( ( 100.f / 2 ) / PhysicsNode::Scale, ( 16.f / 2 ) / PhysicsNode::Scale ); b2FixtureDef FixtureDef; FixtureDef.density = 0.f; FixtureDef.shape = &Shape; Body->CreateFixture( &FixtureDef ); }
// Add new world Texture bounds. void World::addNewWorldArea() { sf::Texture& texture = mTextures.get(Textures::Background); mWorldBounds.top -= WorldLeght; sf::IntRect textureRect(mWorldBounds.left, mWorldBounds.top, mWorldBounds.width, mWorldBounds.height); texture.setRepeated(true); std::unique_ptr<SpriteNode> backgroundSprite(new SpriteNode(texture, textureRect)); backgroundSprite->setPosition(mWorldBounds.left, mWorldBounds.top); mSceneLayers[Background]->attachChild(std::move(backgroundSprite)); }
void Menu::constroiCena() { sf::Vector2f telaSize = tela.getDefaultView().getSize(); int i; for (i = 0; i < LayerCount; i++) { NodeCena* layer; layer = new NodeCena; layersCena[i] = layer; cenaTree.insereFilho(layer); } loadTexturas(); SpriteNode* backgroundSprite(new SpriteNode(texturas[Estrelas])); backgroundSprite->setPosition(0, 0); backgroundSprite->setScale(0.5,0.5); layersCena[Background]->insereFilho(backgroundSprite); logoSprite = new SpriteNode(texturas[Logo]); logoSprite->setOriginCenter(); logoSprite->setPosition(backgroundSprite->getBoundingRect().width/2, backgroundSprite->getBoundingRect().height/2); backgroundSprite->insereFilho(logoSprite); SpriteNode* elementosSprite(new SpriteNode(texturas[Elementos])); elementosSprite->setOriginCenter(); logoSprite->insereFilho(elementosSprite); SpriteNode* tituloSprite(new SpriteNode(texturas[Titulo])); tituloSprite->setScale(0.5, 0.5); tituloSprite->setOriginCenter(); tituloSprite->setPosition(16*telaSize.x/20.f, 2.5*telaSize.y/10.f); layersCena[Background]->insereFilho(tituloSprite); jogar = new Button(texturas[JogarD], texturas[JogarS]); jogar->setPosition(16*telaSize.x/20.f, 6*telaSize.y/10.f); jogar->setOriginCenter(); jogar->setScale(0.5, 0.5); layersCena[Top]->insereFilho(jogar); sair = new Button(texturas[SairD], texturas[SairS]); sair->setPosition(0, 300.f); jogar->insereFilho(sair); playMusic(); }
void World::buildScene() { for (std::size_t i = 0; i < LayerCount; i++) { SceneNode::Ptr layer(new SceneNode()); mSceneLayers[i] = layer.get(); mSceneGraph.attachChild(std::move(layer)); } // map sf::Texture& texture = mTextures.get(Textures::Map); sf::IntRect textureRect(mWorldBounds); texture.setRepeated(true); std::unique_ptr<SpriteNode> backgroundSprite(new SpriteNode(texture, textureRect)); backgroundSprite->setPosition(mWorldBounds.left, mWorldBounds.top); mSceneLayers[Background]->attachChild(std::move(backgroundSprite)); // end line sf::Texture& end = mTextures.get(Textures::End); std::unique_ptr<SpriteNode> endSprite(new SpriteNode(end)); endSprite->setPosition(0.f, -76.f); mSceneLayers[Background]->attachChild(std::move(endSprite)); // player aircraft std::unique_ptr<Aircraft> Leader(new Aircraft(Aircraft::Player1, mTextures, mFonts)); mPlayerAircraft = Leader.get(); mPlayerAircraft->setPosition(mSpawnPosition); mPlayerAircraft->setVelocity(0.f, mScrollSpeed); mSceneLayers[Air]->attachChild(std::move(Leader)); // score display std::unique_ptr<TextNode> score(new TextNode(mFonts, "")); mScoreDisplay = score.get(); score->setSize(40); score->setColor(sf::Color::Yellow); score->setFont(mFonts, Fonts::Blade2); score->setString("Score: " + std::to_string(mScore)); score->setPosition(mWorldView.getSize().x - 100.f, mWorldBounds.height - 750.f); mSceneLayers[Air]->attachChild(std::move(score)); }
void World::buildScene() { for (int i = 0; i < LayerCount; i++) { SceneNode::Ptr layer(new SceneNode()); sceneLayers[i] = layer.get(); sceneGraph.attachChild(std::move(layer)); } sf::Texture& texture = data->rscStorage.getTextureRef("land"); sf::IntRect textureRect(worldBounds); texture.setRepeated(true); unique_ptr<SpriteNode> backgroundSprite(new SpriteNode(texture, textureRect)); backgroundSprite->setPosition(worldBounds.left, worldBounds.top); sceneLayers[Background]->attachChild(std::move(backgroundSprite)); unique_ptr<Character> leader(new Character("greenalien", &data->animStorage)); playerCharacter = leader.get(); playerCharacter->setPosition(spawnPosition); playerCharacter->setVelocity(100.f, 0.f); sceneLayers[Surface]->attachChild(std::move(leader)); }
void World::buildScene() { // Initialize the different layers for (std::size_t i = 0; i < LayerCount; ++i) { SceneNode::Ptr layer(new SceneNode()); mSceneLayers[i] = layer.get(); mSceneGraph.attachChild(std::move(layer)); } // Prepare the tiled background sf::Texture& texture = mTextures.get(Textures::Background); sf::IntRect textureRect(mWorldBounds); texture.setRepeated(true); // Add the background sprite to the scene std::unique_ptr<SpriteNode> backgroundSprite(new SpriteNode(texture, textureRect)); backgroundSprite->setPosition(mWorldBounds.left, mWorldBounds.top); mBackgroundSprite = backgroundSprite.get(); mSceneLayers[Background]->attachChild(std::move(backgroundSprite)); // Add player's spaceship std::unique_ptr<Spaceship> leader(new Spaceship(Spaceship::Rocket, mTextures)); mPlayerSpaceship = leader.get(); mPlayerSpaceship->setPosition(mSpawnPosition); mSceneLayers[Space]->attachChild(std::move(leader)); mBattlifieldBounds.setSize(sf::Vector2f(getBattlefieldBounds().width, getBattlefieldBounds().height)); mBattlifieldBounds.setPosition(getBattlefieldBounds().left, getBattlefieldBounds().top); mBattlifieldBounds.setFillColor(sf::Color::Transparent); mBattlifieldBounds.setOutlineThickness(2.f); mBattlifieldBounds.setOutlineColor(sf::Color::Green); initialText(); }
void AFP::MapParser::addBackgroundLayers(std::vector <SceneNode*>& sceneLayers, SceneNode& spriteGraph, const sf::FloatRect worldBounds) { /// Initialize the different tiling backround layers for (int i = 0; i < mMap.GetNumImageLayers(); ++i) { SceneNode::Ptr layer(new SceneNode(Category::None)); sceneLayers.push_back(layer.get()); /// Add background layers to spritegraph spriteGraph.attachChild(std::move(layer)); const Tmx::ImageLayer* imageLayer = mMap.GetImageLayer(i); const Tmx::PropertySet layerProperties = imageLayer->GetProperties(); if (layerProperties.HasProperty("repeat") && layerProperties.GetLiteralProperty("repeat") == "true") { /// Set backround texture to be tiled sf::Texture& texture = mTextures.get(imageLayer->GetName()); sf::IntRect textureRect(worldBounds); texture.setRepeated(true); /// Make the texture as big as the world bounds std::unique_ptr<SpriteNode> backgroundSprite( new SpriteNode(texture, textureRect)); backgroundSprite->setPosition( worldBounds.left, worldBounds.top); sceneLayers.back()->attachChild(std::move(backgroundSprite)); } else if (layerProperties.HasProperty("repeatVertical") && layerProperties.GetLiteralProperty("repeatVertical") == "true") { /// Tile texture vertically sf::Texture& texture = mTextures.get(imageLayer->GetName()); sf::IntRect textureRect(0.f, 0.f, worldBounds.width, texture.getSize().y); texture.setRepeated(true); std::unique_ptr<SpriteNode> backgroundSprite( new SpriteNode(texture, textureRect)); if (!layerProperties.HasProperty("height")) { throw std::runtime_error("World::buildScene(): Missing property" " height from vertical image layer!"); } /// Set tiled image to the correct height. In tiled the height is /// set as the number of pixels from the bottom int height = layerProperties.GetNumericProperty("height"); backgroundSprite->setPosition( worldBounds.left, mMap.GetHeight() * mMap.GetTileHeight() - height - texture.getSize().y); sceneLayers.back()->attachChild(std::move(backgroundSprite)); } } }
int main(int argc, char* args[]) { sf::VideoMode vidMode; vidMode.width = 800; vidMode.height = 600; vidMode.bitsPerPixel = 32; assert(vidMode.isValid()); sf::RenderWindow win; win.create(vidMode, "Let there be Light - Demo"); sf::View view; sf::Vector2u windowSize(win.getSize()); view.setSize(sf::Vector2f(static_cast<float>(windowSize.x), static_cast<float>(windowSize.y))); view.setCenter(view.getSize() / 2.0f); // ---------------------- Background Image --------------------- sf::Texture backgroundImage; if(!backgroundImage.loadFromFile("data/background.png")) std::abort(); // Tiling background backgroundImage.setRepeated(true); sf::Sprite backgroundSprite(backgroundImage); backgroundSprite.setTextureRect(sf::IntRect(0, 0, vidMode.width * 2, vidMode.height * 2)); backgroundSprite.setPosition(-400.0f, -400.0f); // --------------------- Light System Setup --------------------- ltbl::LightSystem ls(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(vidMode.width), static_cast<float>(vidMode.height))), &win, "data/lightFin.png", "data/shaders/lightAttenuationShader.frag"); // Create a light ltbl::Light_Point* testLight = new ltbl::Light_Point(); testLight->m_intensity = 2.0f; testLight->m_center = Vec2f(200.0f, 200.0f); testLight->m_radius = 600.0f; testLight->m_size = 15.0f; testLight->m_spreadAngle = ltbl::pifTimes2; testLight->m_softSpreadAngle = 0.0f; testLight->CalculateAABB(); testLight->m_bleed = 0.4f; testLight->m_linearizeFactor = 0.2f; ls.AddLight(testLight); testLight->SetAlwaysUpdate(true); // Create a light ltbl::Light_Point* testLight2 = new ltbl::Light_Point(); testLight2->m_center = Vec2f(200.0f, 200.0f); testLight2->m_radius = 500.0f; testLight2->m_size = 30.0f; testLight2->m_color.r = 0.5f; testLight2->m_intensity = 1.5f; testLight2->m_spreadAngle = ltbl::pifTimes2; testLight2->m_softSpreadAngle = 0.0f; testLight2->CalculateAABB(); ls.AddLight(testLight2); testLight2->SetAlwaysUpdate(false); // Create an emissive light ltbl::EmissiveLight* emissiveLight = new ltbl::EmissiveLight(); sf::Texture text; if(!text.loadFromFile("data/emissive.png")) std::abort(); emissiveLight->SetTexture(&text); emissiveLight->SetRotation(45.0f); emissiveLight->m_intensity = 1.3f; ls.AddEmissiveLight(emissiveLight); emissiveLight->SetCenter(Vec2f(500.0f, 500.0f)); // Create a hull by loading it from a file ltbl::ConvexHull* testHull = new ltbl::ConvexHull(); if(!testHull->LoadShape("data/testShape.txt")) std::abort(); // Pre-calculate certain aspects testHull->CalculateNormals(); testHull->CalculateAABB(); testHull->SetWorldCenter(Vec2f(300.0f, 300.0f)); testHull->m_renderLightOverHull = true; ls.AddConvexHull(testHull); // ------------------------- Game Loop -------------------------- sf::Event eventStructure; bool quit = false; ls.m_useBloom = true; while(!quit) { while(win.pollEvent(eventStructure)) if(eventStructure.type == sf::Event::Closed) { quit = true; break; } if(sf::Keyboard::isKeyPressed(sf::Keyboard::A)) view.move(sf::Vector2f(-1.0f, 0.0f)); else if(sf::Keyboard::isKeyPressed(sf::Keyboard::D)) view.move(sf::Vector2f(1.0f, 0.0f)); if(sf::Keyboard::isKeyPressed(sf::Keyboard::W)) view.move(sf::Vector2f(0.0f, -1.0f)); else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) view.move(sf::Vector2f(0.0f, 1.0f)); sf::Vector2f mousePos = win.mapPixelToCoords(sf::Mouse::getPosition(win)); //testLight2->IncCenter(ltbl::Vec2f(0.1f, 0.0f)); // Update light testLight->SetCenter(Vec2f(mousePos.x, static_cast<float>(vidMode.height) - mousePos.y)); win.clear(); win.setView(view); ls.SetView(view); // Draw the background win.draw(backgroundSprite); // Calculate the lights ls.RenderLights(); // Draw the lights ls.RenderLightTexture(); //ls.DebugRender(); win.display(); } win.close(); }
/////////////// /////////////// //Main function int main() { //Enable depth test for background and pacman sprites //glEnable( GL_DEPTH_TEST ); // Create the main window sf::RenderWindow App(sf::VideoMode(640, 480), "SFML Pacman", sf::Style::Default, sf::ContextSettings(32)); App.setFramerateLimit(60); //Initialize glew if( glewInit() != GLEW_OK ) return EXIT_FAILURE; //and allocate an array of vertices GLuint data; //Fill vertex buffer with data const GLfloat vertices[] = { -1.0f, 1.0f, -0.9f, 0.9f, -0.9f, 1.f, 0.f, 0.f, 0.f, 0.5f, -0.5f, 0.5f }; //Fill up indices const GLubyte indices[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; //glGenBuffers(1, &data); //Load square verts into the buffer object, GL_ARRAY_BUFFER //glBindBuffer( GL_ARRAY_BUFFER, data ); //glBufferData( GL_ARRAY_BUFFER, 4*3*sizeof( GLfloat ), vertices, GL_STATIC_DRAW ); // Enable Z-buffer read and write //glEnable(GL_DEPTH_TEST); //glDepthMask(GL_TRUE); //glClearDepth(1.f); //Allocate a new dot grid dotarray dots; //Allocate a new Pacman Pacman pac; pac.load(); //Create a graphical text to display sf::Font font; if (!font.loadFromFile("arial.ttf")) return EXIT_FAILURE; sf::Text text; text.setFont(font); //Load the bg sprite sf::Texture backgroundTex; if(!backgroundTex.loadFromFile("resources/background.png")) return EXIT_FAILURE; sf::Sprite backgroundSprite(backgroundTex); // Start the game loop sf::Sprite currentSprite; while (App.isOpen()) { // Process events sf::Event event; while (App.pollEvent(event)) { // Close window: exit if (event.type == sf::Event::Closed) App.close(); if(event.type == sf::Event::KeyPressed) { if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) pac.setOrientation(1); if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) pac.setOrientation(2); if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) pac.setOrientation(3); if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) pac.setOrientation(4); } } //pac.setOrientation( (int)(clock.getElapsedTime().asSeconds()) % 4 + 1); //Get the next animation of pacman, and draw it against the background pac.animate(); pac.move(); const sf::Texture currentTexture = pac.getCurrentTexture(); currentSprite.setTexture(currentTexture); currentSprite.setOrigin(pac.currentX, pac.currentY); App.pushGLStates(); App.draw(backgroundSprite); App.draw(currentSprite); App.popGLStates(); /* //Draw the mouse position char mousestr[20]; float mouseposX = sf::Mouse::getPosition(App).x * 200.f / App.getSize().x - 100.f; sprintf(mousestr, "%10f", mouseposX); text.setString(std::string(mousestr)); App.pushGLStates(); App.draw(text); App.popGLStates(); */ //Clear the depth buffer glClear( GL_DEPTH_BUFFER_BIT ); //Activate the window App.setActive(); //Draw the square //Enable drawing from vertex arrays /************ DRAW SOME DOTS *********** glEnableClientState( GL_VERTEX_ARRAY ); for(int i = 0; i < dots.rows; i++) for(int j = 0; j < dots.cols; j++) { if(dots.hasDot[i][j]) { //DO OPENGL HERE } } glDrawArrays( GL_TRIANGLES, 0, 6 * dots.numDotsRemaining ); glDisableClientState( GL_VERTEX_ARRAY ); /************ DRAW SOME DOTS *************/ // Update the window App.display(); } return EXIT_SUCCESS; }
bool CCControlBase::init() { CCScale9Sprite* backgroundSprite(nullptr); return initWithBackGroundSprite(backgroundSprite); }