Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Carlos Augusto Br Cpp

Pages: [1]
1
Graphics / [SOLVED] Making Scrolling Backgrounds
« on: November 23, 2016, 03:24:10 am »
Hey guys... hope that you are fine... I am having one problem... I have got it to make scrolling objects... I have made an paddle and when it reach the end of the window it generate in the other side of screen... it works fine... but the problem is that I want to make scrolling backgrounds... I more or less know that I have to repeat the texture but I dont know how... I will post here the code of how I made the scrolling paddle:

#include <SFML/Graphics.hpp>

int main(int argc, char* argv[])
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Scrolling Test");
    window.setVerticalSyncEnabled(true);


    sf::RectangleShape shape(sf::Vector2f(200,30));
    shape.setPosition(200, 400);
    shape.setFillColor(sf::Color::Blue);

    sf::Clock clock;

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                window.close();
            }
        }

        if ((shape.getPosition().x + shape.getSize().x) < 0)
        {
            shape.setPosition((window.getSize().x), (shape.getPosition().y));
        }

        float deltaTime = clock.restart().asSeconds();

        shape.move(-deltaTime * 500, 0);

        window.clear();
        window.draw(shape);
        window.display();
    }
}
 

but the real questions is: How I can apply this to an scrolling background? and how I correctly repeat an texture?

p.s: Sorry about bad English  :-\

2
Graphics / Maximum size of an texture
« on: September 07, 2016, 01:53:51 am »
Hey guys..I have a problem... I am studying SFML and trying to mix some things and I have picked an image for my background that his size is 2048x2048...I declare all things...a chainsaw sprite that will rotate while the window is open and the background sprite....everything seems to be fine..but when I try to execute only the chainsaw appears rotating...and in console show a message like this: Failed to create texture, its internal size too high (2048x2048, maximum is 1024x1024)

and here is my code:

/*****************************************************
* HEADERS
******************************************************/

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>

// Main function of C++ programs
int main(int argc,char* argv[])
{
    /***********************************************************
    * WINDOW
    ************************************************************/


    // Set up the main window and enable framerate limit to 60
    sf::RenderWindow window(sf::VideoMode(800,600), "SFML Test");
    window.setFramerateLimit(60);

    // Set an view and his properties
    sf::View view;
    view.reset(sf::FloatRect(50, 50, 1024, 768));

    /***********************************************************
    * GRAPHICS
    ************************************************************/

    // Texture for the background
    sf::Texture main_BG;
    main_BG.loadFromFile("Resources/BG01.png");

    // Texture for the chainsaw sprite
    sf::Texture chainsaw_texture;
    chainsaw_texture.loadFromFile("Resources/Chainsaw.png");

    // Properties of the BackGround (sprite)
    sf::Sprite background;
    background.setTexture(main_BG);
    background.setPosition(0,0);
    background.setColor(sf::Color::Blue);

    // Properties of the chainsaw sprite
    sf::Sprite chainsaw;
    chainsaw.setTexture(chainsaw_texture);
    chainsaw.setPosition(400,300);
    chainsaw.setOrigin(117,115);

    /*************************************************************
    * Main Loop
    **************************************************************/

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                window.close();
            }
        }

        /**********************************************************
        * KEYBOARD OR JOYSTICK INPUT
        ***********************************************************/

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
        {
            view.move(-5,0);
        }

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
        {
            view.move(5,0);
        }

        // Set what view we'll use
        window.setView(view);

        // Clear the window
        window.clear(sf::Color::White);

        // Do the draw call's
        window.draw(background);
        window.draw(chainsaw);

        // Rotate the chainsaw sprite while the window is open
        chainsaw.rotate(5);

        // Update the screen
        window.display();

    }
}

 

So...the really question is...Have I an option to solve this or the only option is to use a background texture at internal size of 1024x1024??

3
Hey guys...this question is bothering me quite some time...so the question is..what (or how) I can do to become a member of SFML Team in the future? If some one of the team can answer or if Laurent Gomila want to answer...I'll be grateful...sorry for the bad English...

4
General discussions / Mixing graphics libraries on C++
« on: June 29, 2016, 10:51:42 pm »
Hey dudes I need some help in one question...sorry if this is a bit off-toppic but my question is...

Can I mix two graphics library on a C++ project or an game?
for example:
let's suppose that I'll make some game, and I planned to use both SFML and SDL to treat about graphics. ..or maybe use SFML for Graphics and SDL for Audio....Can I do this?

5
General / [SOLVED] I need help about one subject of C++
« on: May 27, 2016, 04:16:07 pm »
Hey guys...good afternoon for all..I'm are having a question that I already have ask and search on the internet but it's not very clear on my mind..what subject of C++ programming treats about data hiding or resource hiding??? to be more exact I'll be give an example...suppose that I'm programming an game...and my all resources are in a folder called "Resources" but I dont want to let the resources stay un-secury because one person can take that resource and use for himself....and what I want is to put theses files in an data archive for example: all .png files for graphics go on an file called Graphics_Data.dat or something like that...sorry If I not explain very well but I hope you guys helps me...thanks!

Pages: [1]