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.


Messages - Programmy

Pages: 1 [2]
16
hello, Im having trouble implementing asSeconds(), asMicroseconds() and asMilliseconds()
Im tinkering with a particular code in the book SFML Game development with examples
but my compiler doesn't recognize the three functions, ive tried changing the preprocessors
to <SFML/System.hpp> then tried <SFML/System/Time.hpp> no luck,
i'm getting the error sf::RenderWindow has no member asSeconds
#include <SFML/Graphics.hpp>
#include <SFML/System/Time.hpp>
#include <iostream>

void main(int argc, char** argv[]) {

        sf::RenderWindow window(sf::VideoMode(640, 480),"Bouncing mushroom.");
        sf::Texture texture;
        sf::RenderWindow time;
        sf::Clock clock;


        sf::Time time = clock.getElapsedTime();
        float seconds = time.asSeconds();
        sf::Int32 milliseconds = time.asMilliseconds();
        sf::Int64 microseconds = time.asMicroseconds();

       

        time = clock.restart();
       
        texture.loadFromFile("c:/Users/jason/source/repos/SFML2/Eagle.png");
       
        sf::Sprite mushroom(texture);
        sf::Vector2u size = texture.getSize();
         
       

        mushroom.setOrigin(size.x / 2, size.y / 2);
        sf::Vector2f increment(0.4f, 0.4f);
       
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                       
                        if (event.type == sf::Event::Closed)
                        {
                                window.close();

                        }
                }
                if ((mushroom.getPosition().x + (size.x / 2) >
                        window.getSize().x && increment.x > 0) ||
                        (mushroom.getPosition().x - (size.x / 2) < 0 &&
                                increment.x < 0))
                {
                        // Reverse the direction on X axis.
                        increment.x = -increment.x;
                }
                if ((mushroom.getPosition().y + (size.y / 2) >
                        window.getSize().y && increment.y > 0) ||
                        (mushroom.getPosition().y - (size.y / 2) < 0 &&
                                increment.y < 0))
       
                {// Reverse the direction on Y axis.
                        increment.y = -increment.y;
                }

               
                mushroom.setPosition(mushroom.getPosition() + increment);
                window.clear(sf::Color(16, 16, 16, 255)); // Dark gray.
                window.draw(mushroom); // Drawing our sprite.
                window.display();
        }
       
}


       
       
       
       

       

 

17
topic is as it says,

18
General / Re: cannot find -ljpeg error
« on: June 10, 2018, 03:52:48 pm »
how do I make it compile  then?

19
General / cannot find -ljpeg error
« on: June 10, 2018, 08:12:03 am »
I installed SFML, but it shows this error when I compile it with the opening a window code. need help pls

Pages: 1 [2]
anything