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 - metulburr

Pages: 1 2 3 [4]
46
General / better tutorial for SFML?
« on: August 29, 2011, 12:00:25 am »
one example is this code. i tried putting a simple png image to turn with WASD movements, and i wanted it to turn the direction that the user chose (but only once). my original image is suppose to be a top-down view of a guy(thus the reason for turning) but the ship game me a point to see where its heading is easier.

1)line 37, i tried putting an if() to only allow it to do it only once based on its direction
Code: [Select]
#include <SFML/Graphics.hpp>


int main()
{
    // Create the main rendering window
    sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Pac-Man");

    // Load the sprite image from a file
    sf::Image Image;
    if (!Image.LoadFromFile("ship.png"))
        return EXIT_FAILURE;

    // Create the sprite
    sf::Sprite ship(Image);

    // Change its properties
    ship.SetColor(sf::Color(0, 255, 255, 128));
    ship.SetPosition(200.f, 100.f);
    ship.SetScale(0.f, 0.f);
    ship.Rotate(0.f);


    // Start game loop
    while (window.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (window.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                window.Close();

            if(Event.Type == sf::Event::KeyPressed)
            {
                if(!(ship.Rotate(270.f)))
                {
                    switch(Event.Key.Code)
                    {
                    case sf::Key::A:
                        ship.Rotate(270.f);
                        break;
                    }
                }
            }

            if(Event.Type == sf::Event::KeyPressed)
            {
                switch(Event.Key.Code)
                {
                case sf::Key::W:
                    ship.Rotate(0.f);
                    break;
                }
            }

            if(Event.Type == sf::Event::KeyPressed)
            {
                switch(Event.Key.Code)
                {
                case sf::Key::D:
                    ship.Rotate(90.f);
                    break;
                }
            }

            if(Event.Type == sf::Event::KeyPressed)
            {
                switch(Event.Key.Code)
                {
                case sf::Key::S:
                    ship.Rotate(180.f);
                    break;
                }
            }
        }

        // Get elapsed time
        float ElapsedTime = window.GetFrameTime();

        // Move the sprite
        if (window.GetInput().IsKeyDown(sf::Key::A))
        {

            ship.Move(-200 * ElapsedTime, 0);
        }



        if (window.GetInput().IsKeyDown(sf::Key::D))  ship.Move( 200 * ElapsedTime, 0);
        if (window.GetInput().IsKeyDown(sf::Key::W))  ship.Move(0, -200 * ElapsedTime);
        if (window.GetInput().IsKeyDown(sf::Key::S))  ship.Move(0,  200 * ElapsedTime);

        // Rotate the sprite
        if (window.GetInput().IsKeyDown(sf::Key::Add))      ship.Rotate(- 200 * ElapsedTime);
        if (window.GetInput().IsKeyDown(sf::Key::Subtract)) ship.Rotate(+ 200 * ElapsedTime);

        // Clear screen
        window.Clear();

        // Display sprite in our window
        window.Draw(ship);

        // Display window contents on screen
        window.Display();
    }

    return EXIT_SUCCESS;
}


EDIT 1: i posted this code thinking this forum had number lines for codes line 37 is if(!(ship.Rotate(270.f)))...i already know that this is invalid

47
General / better tutorial for SFML?
« on: August 28, 2011, 11:51:32 pm »
i am ok at running the console apps and can figure out why things are there and what they are for, but using SFML i cant seem to follow what is going on(therefore unable to use it without copying and pasting peoples responses for my program)

1) At what point should i depart from console programs (becuz they are kind of boring), i can make small (very small) text games, somewhat know how to use classes, loops, etc.

2) SFML seems to have trouble explaining things well when going from console to SFML.

3) i read through the tutorials on this site, and they are not very (console to SFML) friendly. I have to keep posting questions on Cplusplus forums due to most answers on the beginners forum are regarding console apps.

4) is there a tutorial for beginners starting SFML directly from console learning??? if so please reply

5) what exactly can u use SFML for?  2D games, GUI programs(i guess meaning like a windows app) ( like menu selection for the game?). if you wanted to make 3D games, why could you not use SFML and just use their libraries for menus and make your own classes for the 3D?

Thanks in Advance,
metulburr

48
General / installing question
« on: August 24, 2011, 10:06:48 am »
thank you

i do have usr/include/SFML and inside the files   but when i try to link it via code blocks im stuck  when i click add libraries within i go to usr/include/SFML and click on the window file for example and (my first instinct would be an OK or ADD button) but it just shows open (and when i open it under that i dont see anything and it doesnt do anything) and at that point im lost???

49
General / installing question
« on: August 24, 2011, 09:05:36 am »
i am not really great at working with the terminal in linux, but anyways i downloaded SFML 1.6 for linux
http://www.sfml-dev.org/tutorials/1.6/start-linux.php

http://www.sfml-dev.org/tutorials/1.6/start-linux.php

under installing SFML is says "Once you have downloaded and extracted the files to your hard drive, you must install the SFML headers and library files to the appropriate location. To do so, you just have to go to the SFML-x.y directory and type "sudo make install".

id dont know what it means by going to the SFML-x.y directory?
then i did this

[/code]metulburr@metulburrPC ~/SFML-1.6 $ sudo make install
[sudo] password for metulburr:
make[1]: Entering directory `/home/metulburr/SFML-1.6/src/SFML'
make[2]: Entering directory `/home/metulburr/SFML-1.6/src/SFML/System'
make[2]: Leaving directory `/home/metulburr/SFML-1.6/src/SFML/System'
make[2]: Entering directory `/home/metulburr/SFML-1.6/src/SFML/Window'
make[2]: Leaving directory `/home/metulburr/SFML-1.6/src/SFML/Window'
make[2]: Entering directory `/home/metulburr/SFML-1.6/src/SFML/Network'
make[2]: Leaving directory `/home/metulburr/SFML-1.6/src/SFML/Network'
make[2]: Entering directory `/home/metulburr/SFML-1.6/src/SFML/Graphics'
make[2]: Leaving directory `/home/metulburr/SFML-1.6/src/SFML/Graphics'
make[2]: Entering directory `/home/metulburr/SFML-1.6/src/SFML/Audio'
make[2]: Leaving directory `/home/metulburr/SFML-1.6/src/SFML/Audio'
make[1]: Leaving directory `/home/metulburr/SFML-1.6/src/SFML'[code]

did i do this right? could someone  walk me through this process?

Pages: 1 2 3 [4]
anything