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 - K.F

Pages: [1]
1
General discussions / SFML Background and Splash Screens
« on: October 07, 2016, 10:37:37 pm »
Here is a background and a couple of splash screens that I made for sfml:









Keep in mind that youtube compresses the video even at 1080p, if someone needs a lossless version, tell me.

And, please make your splash screens skippable, nothing makes me hate a company more than staring at its unskippable splash screen for the tenth time  :P

2
General / Problem When a Window is Very Small
« on: February 13, 2016, 10:39:13 pm »
Hi, I'm using a 64 by 32 pixels window, and this happens :

64 by 32:


The magenta is the "window.clear" color, red is an sf::image with the same width and height as the window, so it should cover the whole window, but it doesn't. I though I was doing something wrong, until I decided to see what happens if I increase the window and image sizes, and it works then as intended - they are still equal - :

640 by 320:


The problem occurs when the width is 115 or less, not sure if it is an sfml bug, or if I'm missing something.  Here's the code:

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

int main()
{
        const int h = 32;
        const int w = 64;

        sf::RenderWindow window(sf::VideoMode(w, h), "Chip_8");
        sf::Image  image;
        image.create(w, h, sf::Color::Red);
        sf::Texture timage;
        timage.loadFromImage(image);
        sf::Sprite simage(timage);
        window.setSize( sf::Vector2u(600, 300));

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

                window.clear(sf::Color::Magenta);
                timage.update(image);
                window.draw(simage);
                window.display();
        }


        return 0;
}

3
Hi.

 Is there a way to let the user make any number of shapes or sprites without me initializing them first?

 For example, I am making 2D billiard game as exercise using SFML 2.0 and want the player to create the balls by clicking on the place where he wants the ball to be, I want a way for a ball sprite to be created and named "ball_01,ball_02" every time he clicks without me making them one by one.

 Other related question is how do I enter these sprites in a loop or if statement?

 For example, I want a loop or function for these sprites to check for collision with every other sprite without writing different if statements for each sprite?

4
General / Strange behavior
« on: June 21, 2012, 04:16:33 pm »
Strange behavior

I'm starting a simple projectile calculator and made this test for vertical falling object, I used one of the tutorials as starting point. The object will bounce on impact with the ground and there is a damping so it won't keep bouncing, but the problem is that if you shake the window of the program with your mouse, the object will bounce higher even though the code has nothing to do with that.

Try it, compile this code and run it then shake the window or even just move it and the box will fly out of it. Can anyone tell me what is happening here?



#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;



int main()
{


    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Projectile_Test");

    sf::Clock Clock;

    sf::Shape Polygon;
           Polygon.AddPoint(200, 200,  sf::Color(255, 0, 0),     sf::Color(0, 128, 128));
           Polygon.AddPoint(300, 200,   sf::Color(255, 85, 85),   sf::Color(0, 128, 128));
           Polygon.AddPoint(300, 300,  sf::Color(255, 170, 170), sf::Color(0, 128, 128));
           Polygon.AddPoint(200, 300,  sf::Color(255, 170, 170), sf::Color(0, 128, 128));

           Polygon.SetCenter(250,250);
           Polygon.Move(250,250);

    while (App.IsOpened())
    {

        sf::Event Event;
        while (App.GetEvent(Event))
        {

            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        float t = Clock.GetElapsedTime();

        float ElapsedTime = App.GetFrameTime();


        // Move the sprite
        if (App.GetInput().IsKeyDown(sf::Key::Left))  Polygon.Move(-1 , 0);
        if (App.GetInput().IsKeyDown(sf::Key::Right)) Polygon.Move( 300 * ElapsedTime, 0);
        if (App.GetInput().IsKeyDown(sf::Key::Up))    Polygon.Move(0, -300 * ElapsedTime);
        if (App.GetInput().IsKeyDown(sf::Key::Down))  Polygon.Move(0,  300 * ElapsedTime);

        // Rotate the sprite
        if (App.GetInput().IsKeyDown(sf::Key::Add))      Polygon.Rotate(- 100 * ElapsedTime);
        if (App.GetInput().IsKeyDown(sf::Key::Subtract)) Polygon.Rotate(+ 100 * ElapsedTime);


        // Gravitational acceleration value

        float acc=0.5*t;

        // Gravity
        Polygon.Move(0,  acc);



        cout<<t<<'\n';
        float y2 = Polygon.GetPosition().y;

        if (y2 > 550)
        {


                float s= acc ;
                Clock.Reset();

                t = Clock.GetElapsedTime();
                float acc=0.5*t;





                float m =5;

                while(m>0)

                {
                        t = Clock.GetElapsedTime();
                        acc=0.5*t;
                        Polygon.Move(0,  acc);
                        Polygon.Move(0,  -s/1.1);


                        //Polygon.Move(0,  -s/1000);
                        cout<<"loop"<<'\n';
                        cout << "distance="<< y2 <<'\n';
                        cout << "time="<< acc <<'\n';
                        cout << "s="<< s <<'\n';
                        m = s- acc;
                        App.Clear();

                        App.Draw(sf::Shape::Rectangle(200, 350, 600, 400, sf::Color::Green));


                // Display window contents on screen

                        App.Draw(Polygon);

                        App.Display();

                }

                Clock.Reset();
        }



        cout << y2 <<'\n';


        // Clear screen
        App.Clear();

        App.Draw(sf::Shape::Rectangle(200, 350, 600, 400, sf::Color::Green));


        // Display window contents on screen

        App.Draw(Polygon);

        App.Display();




    }

    return EXIT_SUCCESS;
}
 

Pages: [1]
anything