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

Pages: [1]
1
Graphics / How incorporate more tiles instead of just one?
« on: June 29, 2014, 09:37:10 am »
How would I add more than one tile to this vertex map? Haven't been able to find a solution, and my ideas that I have tried are very slim on working.

I want to be able to use more than on tile (like look at an array and replace the numbers with a tile???)

Any clues/help to get me started?
class MapLoader : public TileLoader
{
public:
    MapLoader(void)
    {
        m_mapdata.MapX = 100;
        m_mapdata.MapY = 100;
        m_mapdata.TextureName = "0.gif";
    }
    virtual void AppendTile(int gx, int gy, sf::VertexArray& garr)
    {
        sf::Vertex ver;
        ver.position = sf::Vector2f(gx*16.f, gy*16.f);
        ver.texCoords = sf::Vector2f(0.f, 0.f);
        garr.append(ver);

        ver.position = sf::Vector2f(gx*16.f + 16.f, gy*16.f);
        ver.texCoords = sf::Vector2f(16.f, 0.f);
        garr.append(ver);

        ver.position = sf::Vector2f(gx*16.f + 16.f, gy*16.f + 16.f);
        ver.texCoords = sf::Vector2f(16.f, 16.f);
        garr.append(ver);

        ver.position = sf::Vector2f(gx*16.f, gy*16.f + 16.f);
        ver.texCoords = sf::Vector2f(0.f, 16.f);
        garr.append(ver);
    }
};

2
How would you go about showing what tile your on with a VertexArray Tilemap that is based mostly on the example?

Really simple answer, but I'm just lost at where to start with it.

Cheers

http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php

3
Hey,

I've been stuck on this for a few hours now, and I'm lost. I have a if statement that lets me move my sprite, but for it to control the player, I need it to change the sprite texture according to what key is pressed,

I have this for my if statement to change the texture :

if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A)){ p_sprite.move(4,0); p_sprite.setTexture(tp_left);}

I have the textures setup in the header file as
sf::Texture tp_left;tp_left.loadFromFile('left.jpg');

Im drawing the sprite, the player loads fine and I can move correctly, just the changing of textures of the player on certain keys is confusing me.

Thanks :)

4
Graphics / No Errors, but Sprite wont draw?
« on: May 15, 2014, 02:36:42 am »
Hi, I've been having troubles drawing my sprite, in my Player class where I'm loading the images, I get no errors when loading the images for the texture, but when I goto run the application, the sprite isn't showing, I have other objects being drawn as well, I have the player being drawn last after everything else, but still down do anything?

Any Ideas?

Drawing the Characters Sprite (This is being called after a statement returns true)
void Lester::PlayerSetup()
{
    Player player = *new Player();
    sf::Sprite p_sprite(player.p_sprite);
    p_sprite.setPosition(200, 200);
    p_sprite.setTexture(player.tp_sprite);

    window->draw(p_sprite);
}
 
Player Declarations for sprite image loading
void Player::texture()
{
    //tp_down_sprite->loadFromFile("data/assets/player/down_char.png");
    //tp_left_sprite->loadFromFile("data/assets/player/left_char.png");
    //tp_right_sprite->loadFromFile("data/assets/player/right_char.png");
    //tp_up_sprite->loadFromFile("data/assets/player/up_char.png");

    if (!tp_sprite.loadFromFile("data/assets/player/up_char.png")){ std::cout << "Unable to load Player Sprites! Please report this Error!"; }
    else{ std::cout << "Player Sprite was Loaded Correctly"; }
    p_sprite.setTexture(tp_sprite);
}

Cheers.

5
Network / Load Sprite texture from Website
« on: April 18, 2014, 08:39:11 am »
Hi,

What would be the easiest way to convert what I have here, to display my sprites textures instead of using .loadFromFile?

    sf::Http::Request request("image.png", sf::Http::Request::Post);

    sf::Http http("http://mysite.com/");
    sf::Http::Response response = http.sendRequest(request);

    // check the status
    if (response.getStatus() == sf::Http::Response::Ok)
    {
        // check the contents of the response
        std::cout << response.getBody() << std::endl;
    }
    else
    {
        std::cout << "request failed" << std::endl;
    }
 

This just shows the image.png contents in the console, I want to be able to draw a sprite from fetching the image from the website, is it possible to do this?

Cheers.

6
Window / [Solved] Unresolved External on changing Window Size
« on: April 13, 2014, 01:54:47 pm »
Hello, I have just ran into an error when trying to resize my screen via a function,

error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::setSize(class sf::Vector2<unsigned int> const &)" (__imp_?setSize@Window@sf@@QAEXABV?$Vector2@I@2@@Z) referenced in function "public: void __thiscall Lester::GameScreen(void)" (?GameScreen@Lester@@QAEXXZ)
 

This is the function resizing:

void Lester::GameScreen()
{
   window.clear();
   window.setTitle("Lester V0.1");
   window.setSize(sf::Vector2u(960, 550));
   Screen();
}
 

Any ideas?

Cheers

7
General / [SOLVED][TGUI] Label Widget isn't displaying on Compile?
« on: April 13, 2014, 04:34:25 am »
Hi there, I have successfully installed TGUI (An SFML GUI Library), and I have gotten the library working correctly to the point where it shows the text boxes and buttons, but It does not show my Labels for Username and Password.

This is what it looks like:


and this is the code I am using to create the GUI:
#include <TGUI/TGUI.hpp>

void loadWidgets(tgui::Gui& gui)
{
        // Create the background image
        tgui::Picture::Ptr picture(gui);

        // Create the username label
        tgui::Label::Ptr labelUsername(gui);
        labelUsername->load("data/TGUI/widgets/White.conf");
        labelUsername->setText("Username:");
        labelUsername->setPosition(70,60);

        // Create the password label
        tgui::Label::Ptr labelPassword(gui);
        labelPassword->setText("Password:");
        labelPassword->setPosition(70,100);

        // Create the username edit box
        tgui::EditBox::Ptr editBoxUsername(gui, "Username");
        editBoxUsername->load("data/TGUI/widgets/White.conf");
        editBoxUsername->setSize(170,27);
        editBoxUsername->setPosition(140,58);

        // Create the password edit box (we will copy the previously created edit box)
        tgui::EditBox::Ptr editBoxPassword = gui.copy(editBoxUsername, "Password");
        editBoxPassword->setPosition(140, 100);
        editBoxPassword->setPasswordCharacter('*');

        // Create the login button
        tgui::Button::Ptr button(gui);
        button->load("data/TGUI/widgets/White.conf");
        button->setSize(80, 22);
        button->setPosition(140,140);
        button->setText("Login");
        button->bindCallback(tgui::Button::LeftMouseClicked);
        button->setCallbackId(1);

        // Create the register button
        tgui::Button::Ptr regbutton = gui.copy(button, "Register");
        regbutton->setPosition(230, 140);
        regbutton->bindCallback(tgui::Button::LeftMouseClicked);
        regbutton->setCallbackId(1);
}

int main()
{
        // Create the window
        sf::RenderWindow window(sf::VideoMode(422, 250), "TGUI window");
        tgui::Gui gui(window);

        // Load the widgets
        loadWidgets(gui);

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

                        // Pass the event to all the widgets
                        gui.handleEvent(event);
                }

                // The callback loop
                tgui::Callback callback;
                while (gui.pollCallback(callback))
                {
                        // Make sure tha callback comes from the button
                        if (callback.id == 1)
                        {
                                // Get the username and password
                                tgui::EditBox::Ptr editBoxUsername = gui.get("Username");
                                tgui::EditBox::Ptr editBoxPassword = gui.get("Password");

                                sf::String username = editBoxUsername->getText();
                                sf::String password = editBoxPassword->getText();

                                // Continue here by checking if the username and password are correct ...
                        }
                }

                window.clear(sf::Color::White);

                // Draw all created widgets
                gui.draw();

                window.display();
        }

        return EXIT_SUCCESS;
}
 

If somebody would be able to find out what I've missed out on, that would be great.

Cheers

8
Network / [Solved] Opening Website File to show in Window
« on: April 11, 2014, 11:49:16 am »
Hi, would it be possible to open a website page or a file and show the contents of the site in the window? I have had a look at searching and found nothing on this topic, so I'm unsure if anybody has tried this yet.

If there is a way, what would be the best solution to achieve it?

Cheers

9
General / How to find the Static DLL's?
« on: April 09, 2014, 11:35:04 am »
Hi all,

Does anybody know where I can find the Static DLLS for SFML 2.1? I have done searching on the forums and cant really find anything about where they are found.

Can anybody tell me where/how to get them?

Cheers

10
Graphics / VertexArray displaying Dominant color, not the actual image
« on: April 06, 2014, 11:34:34 am »
Hi, I've recently learn't how to use VertexArray's as I read that it was much faster than loading each image individually.

I have my code for the VertexArray working, just when I goto load the image to display as a the 'tile' it shows the most dominant color used in the image, which is green, not the image.

Can you explain why it's doing this?

sf::Texture t_grass;//Called when program is initialized

        while (window.isOpen()){
                sf::Event event;
                while (window.pollEvent(event)){
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
                t_grass.loadFromFile("images/grass.png");//Loads the image
                window.clear();

                sf::VertexArray lines(sf::Quads, 4);
                lines[0].position = sf::Vector2f(0, 0);
                lines[1].position = sf::Vector2f(0, 50);
                lines[2].position = sf::Vector2f(50, 50);
                lines[3].position = sf::Vector2f(50, 0);
                window.draw(lines, &t_grass);
                window.display();
        }
 

The image loads fine, so I'm lost with all of it.
Cheers

Pages: [1]