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 - Chay Hawk

Pages: [1] 2
1
SFML projects / Need sfml programmer for word guessing game
« on: April 11, 2017, 06:36:14 am »
I found a C++ project that ?I made 4 years ago and would like to have it in a real window instead of a console window. The code is all written and ready, however I have been trying to clean up the code since it was an atrocious mess and I hit a few snags so you'll have to do a little fixing but the code is all there. If anyone is interested in a really small project just for fun then contact me by email at: thundermountainstudios@yahoo.com or send me a PM.

EDIT: I fixed the code, it now works properly and looks nicer, just need someone to create an SFML interface for it.

About the game:

You can enter your own words and have someone sitting next to you guess them, maybe we could add a simple direct online connect feature? or you can load words from a list and the game will load them all and jumble them up and you have to guess them.

2
General discussions / Looking to Create a Node Based Programming Language
« on: January 02, 2017, 06:49:07 am »
Hi, I am looking to hire someone to make a node based programming language using C++ and SFML that I am naming Circut Board. Currently the only thing I want to know is how much this would cost to make and how long. I would need someone experienced and capable in completing the job. More info below:

Circut Board is a node based programming language very similar to Epic’s Blueprint in Unreal Engine 4, however CB is designed to be used solely to make 2D games and must be more user friendly but still powerful enough to create entire games using only the nodes. This can be achieved by re-creating C++ functions and abilities in the program and creating pre defined actions the user can choose from. We would include as many pre defined actions as possible but the program would allow users to create nodes by using the nodes in the program themselves, this can be done by allowing the user to create a “User Node” and then name it and save it. This will allow for more flexibility, and it will also allow users to share custom nodes with each other so people with better logical programming skills can help out others who do not posess that ability. Full source code access will be allowed as well once the program is fully completed. This will allow more advanced users to modify the program to their liking, however the average user should be able to make a large scale open world 2D game without having to write a single line of code or even think about it. The job is basically just take the C++ language and make it node based while making it more user friendly and using plain english terms while also adding functionality to be able to create games. SFML will be used to create the interface for the program and more so to handle game creation tasks.

If someone could give me some quotes on a price and timeframe I would greatly appreciate it. You can PM me or send me an email at: thundermountainstudios@yahoo.com

Any questions, feel free to ask.

3
ABOUT THE PROJECT

The name of the game is Dr. Dangers Laboratory, it is a 2D platformer level builder game inspired by Mario Maker, Gmod, Scribblenauts and Contraption Maker. The way I designed the game, it will have the fun and creativity of Mario Maker, Scribblenauts and Contraption maker, with the flexibility of Gmod, allowing the player to create pretty much anything they can think of, and design their own levels and prefab items and share them with others.

However I shoudl state that this is not an actual game making program like Game Maker or RPG Maker, its an actual game.

I need a pixel artist though, I would take anyone willing to do it for either royalties, or a beginner just looking for experience.

I need someone who can begin work immediately.


If anyone is interested please contact me at: thundermountainstudios@yahoo.com and we can talk business. You can also PM me if you like.

Thank You, Chay Hawk

4
General / Need serious help with collision
« on: October 26, 2015, 06:53:47 pm »
Ok so i'm trying to do some basic collision, but I can not for the life of me figure it out. I never could when i was doing this a year ago either. I got window bounds collision down, but i cant seem to make good collision with an object. I figured it would be just the same as a window collision but inverted but no. It's really starting to anger me. Someone please help. I've attached the red and blue squares to this post so you can use them to test the code.

I'm having trouble with "Object Collision Version 1"

#include <iostream>
#include <SFML/Graphics.hpp>

using namespace std;

void LoadImage(sf::Texture* texture)
{
    texture->loadFromFile("Red_Square.png");
}

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "App");
    window.setFramerateLimit(30);

    //Player
    sf::Texture texture;
    sf::Sprite sprite;

    LoadImage(&texture);

    sprite.setTexture(texture);

    //Calculate sprite origin - Will get the center of the sprite no matter what size it is
    int spriteOriginX = sprite.getGlobalBounds().height / 2;
    int spriteOriginY = sprite.getGlobalBounds().height / 2;

    cout << "Sprite Center: " << spriteOriginX << " " << spriteOriginY << endl; //Debug

    sprite.setOrigin(spriteOriginX, spriteOriginY);


    //Object
    sf::Texture objectTexture;
    sf::Sprite objectSprite;

    if(!objectTexture.loadFromFile("Blue_Square.png"))
    {
        cout << "Error loading blue square" << endl;
    }

    objectSprite.setTexture(objectTexture);

    objectSprite.setPosition(100, 100);

    //Calculate sprite origin - Will get the center of the sprite no matter what size it is
    int objectSpriteOriginX = objectSprite.getGlobalBounds().height / 2;
    int objectSpriteOriginY = objectSprite.getGlobalBounds().height / 2;

    cout << "objectSprit Center: " << objectSpriteOriginX << " " << objectSpriteOriginY << endl; //Debug

    objectSprite.setOrigin(objectSpriteOriginX, objectSpriteOriginY);

    sf::Event event;

    while(window.isOpen())
    {
        while(window.pollEvent(event))
        {
            switch(event.type)
            {
                case sf::Event::Closed:
                    window.close();
                break;

                case sf::Event::Resized:
                    sf::FloatRect viewArea(0, 0, event.size.width, event.size.height);
                    window.setView(sf::View(viewArea));
                break;
            }
        }

        //Movement
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
        {
            sprite.move(0, -3);
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
        {
            sprite.move(-3, 0);
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
        {
            sprite.move(0, 3);
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
        {
            sprite.move(3, 0);
        }

        //Collision Version 2 - Window collision only
        if(sprite.getPosition().y - spriteOriginY <= 0) //W
        {
            sprite.move(0, 3);
        }
        if(sprite.getPosition().x - spriteOriginX <= 0) //A
        {
            sprite.move(3, 0);
        }
        if(sprite.getPosition().y + spriteOriginY >= window.getSize().y) //S
        {
            sprite.move(0, -3);
        }
        if(sprite.getPosition().x + spriteOriginX >= window.getSize().x) //D
        {
            sprite.move(-3, 0);
        }

        //Object Collision Version 1
        if(sprite.getPosition().y >= objectSprite.getPosition().y) //W
        {
            sprite.setPosition(objectSprite.getPosition().y - objectSpriteOriginY, sprite.getPosition().x);
        }
        /*
        if(sprite.getPosition().x == objectSpriteOriginX <= objectSprite.getPosition().x) //A
        {
            sprite.move(3, 0);
        }
        if(sprite.getPosition().y == objectSpriteOriginY >= objectSprite.getPosition().y) //S
        {
            sprite.move(0, -3);
        }
        if(sprite.getPosition().x == objectSpriteOriginX >= objectSprite.getPosition().x) //D
        {
            sprite.move(-3, 0);
        }
*/


        window.clear(sf::Color::White);
        window.draw(sprite);
        window.draw(objectSprite);
        window.display();
    }

    return 0;
}
 


5
General / Sprite stretches with window
« on: October 19, 2015, 04:25:28 pm »
I got SFML Working and I loaded a sprite into it and it stretches with my window, i'm not sure why, the tutorial section didnt really say anything about it. I tried a few things on there that might have worked but still nothing.

Also in the console i get this message:
"OpenGL extension SGIS_texture_edge_clamp unavailable
Artifacts may occur along texture edges
Ensure that hardware acceleration is enabled if available"

Im not sure if that has anything to do with it or not, but the last time i used SFML i never got that message in console so maybe it does but I don't know what it means, or what the program needs.


#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML works!");

    sf::Texture RedSquareTexture;
    if(!RedSquareTexture.loadFromFile("Red_Square.png")) //32x32 red square
    {
        std::cout << "Error" << std::endl;
    }

    sf::Sprite RedSquareSprite;
    RedSquareSprite.setTexture(RedSquareTexture);

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

        window.clear(sf::Color::White);
        window.draw(RedSquareSprite);
        window.display();
    }

    return 0;
}
 


6
General / Getting Errors when installing
« on: October 18, 2015, 11:17:34 pm »
I havent had this installed in a year and i forgot completley how to install it, and have spent the greater part of 25 minutes trying.

I have Code Blocks 13.12 MinGW
Windows 10

I downloaded SFML from here: http://www.nightlybuilds.ch/project/show/1/SFML/
Since they are already pre-compiled. I downloaded this version:

Windows   32 bit   MinGW-Builds (492r2) x32   2015-05-19 80214d1cb916ae5f49c63ade4c167369faab9b9e

and put it in my C Drive, it's not in any system folders, i click on my C drive and its right there. I went to compiler>compiler settings, then under the compiler tab i directed it to the include folder, and under the linker tab i directed it to the lib folder. Under Linker Settings I have these in this order

sfml-graphics-s
sfml-window-s
sfml-audio-s
sfml-system-s
freetype
jpeg
openal32
opengl32

and under #defines i put SFML_STATIC

I used the sample code in the code blocks setup tutorial and i get these two errors:

||=== Build: Debug in Pointers (compiler: GNU GCC Compiler) ===|
C:\SFML\lib\libsfml-graphics-s.a(CircleShape.cpp.obj):CircleShape.cpp|| undefined reference to `_Unwind_Resume'|
C:\SFML\lib\libsfml-graphics-s.a(CircleShape.cpp.obj):CircleShape.cpp:(.eh_frame+0x63)||undefined reference to `__gxx_personality_v0'|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

7
General / Get keyboard button?
« on: October 04, 2014, 08:17:27 pm »
I was wondering if there was a way to get whatever key was pressed without having to program them all into my program. I'm making a keylogger for personal use and I would like to know if there is an easier solution to this or do I have to program in all of the keys myself.

8
General / Collision help please
« on: September 27, 2014, 09:09:14 pm »
I am seriously struggling with collision, I have been reading articles and looking at examples but I just cannot seem to figure it out at all, I have been trying to figure out some collision for over a month or more, can someone please help me?

I deleted all my collision code that I had, which wasnt very much but still. It was too embarrassing to post.

/*
//
*/


#include <SFML/Graphics.hpp>
#include <SFGUI/SFGUI.hpp>

#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

enum Direction{Down, Left, Right, Up};

class Game
{
    public:
        void Program();
        void CreateCharacters();
        void LoadCharacters();
        void CropSprite();
        void UserInput();
        void Collision();

    private:
        vector<sf::Vector2f> player_pos;
        vector<sf::Sprite> load_sprites;
        vector<sf::Texture> load_textures;

        sf::Sprite sprite;
        sf::Texture texture;

        sf::Vector2i source;

        sf::RectangleShape rect;
};
/*
class GUI : public Game
{
    public:
        void CreateMenu();
        void CloseMenu();
        void MenuButtons();

    private:
        sfg::SFGUI sfgui;
        sfg::Desktop dtop;
        sfg::Window::Ptr menu_window;

        sfg::Button::Ptr menu_exit;

        sfg::Box::Ptr box_HOR;
        sfg::Box::Ptr box_VER;
};

void GUI::CreateMenu()
{
    box_HOR = sfg::Box::Create(sfg::Box::Orientation::HORIZONTAL);
    box_HOR->Pack(menu_exit, false, true);
}

void GUI::MenuButtons()
{
    menu_exit = sfg::Button::Create("Exit");
}
*/

//Set characters to a sprite.
void Game::CreateCharacters()
{
    sprite.setTexture(texture);

    CropSprite();
}

//This will be a vector later and it will load all
//characters individually.
void Game::LoadCharacters()
{
    if(!texture.loadFromFile("Resources/Characters/Player.png"))
    {
        cout << "Error loading texture" << endl;
    }

    CreateCharacters();
}

//We dont want our character to be the entire sprite sheet
//so we crop out the character and its position that we want.
void Game::CropSprite()
{
    sprite.setTextureRect(sf::IntRect(source.x * 32, source.y * 32, 32, 32));
}

void Game::UserInput()
{
    CropSprite();
    Collision();

    GUI gui;

    if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
    {
        source.y = Up;
        sprite.move(0, -1.3);
    }
    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
    {
        source.y = Left;
        sprite.move(-1.3, 0);
    }
    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
    {
        source.y = Down;
        sprite.move(0, 1.3);
    }
    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
    {
        source.y = Right;
        sprite.move(1.3, 0);
    }
    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
    {
        //gui.menu_exit;
    }
}

void Game::Collision()
{
   
}

void Game::Program()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "App");
    window.setFramerateLimit(60);

    window.resetGLStates();

    rect.setSize(sf::Vector2f(32, 32));
    rect.setFillColor(sf::Color::Blue);
    rect.setPosition(80, 80);


    LoadCharacters();

    while(window.isOpen())
    {
        sf::Event event;
        while(window.pollEvent(event))
        {
            switch(event.type)
            {
                case sf::Event::Closed:
                    window.close();
                break;

                case sf::Event::Resized:
                    sf::FloatRect viewArea(0, 0, event.size.width, event.size.height);
                    window.setView(sf::View(viewArea));
            }
        }
        window.clear(sf::Color::White);

        UserInput();

        window.draw(rect);
        window.draw(sprite);
        window.display();
    }
}

int main()
{
    Game game;
    game.Program();

    return 0;
}
 

9
Graphics / Sprite wont face different direction
« on: September 26, 2014, 11:46:49 pm »
My character won't face a different direction when i hit one of the WASD keys, it will face another direction when i change the direction in  Crop player though, but it wont do anything else. the code compiles and I'm able to move the character around the screen but it just wont change the direction its facing.


/*
//
*/


#include <SFML/Graphics.hpp>
#include <SFGUI/SFGUI.hpp>

#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;


class Game
{
    public:
        void Program();
        void CreateCharacters();
        void LoadCharacters();
        void CropSprite();
        void UserInput();
        void Collision();

    private:
        vector<sf::Vector2f> player_pos;
        vector<sf::Sprite> load_sprites;
        vector<sf::Texture> load_textures;

        sf::Sprite sprite;
        sf::Texture texture;

        sf::Vector2i source;

        enum Direction{Down, Left, Right, Up};
};

class GUI : public Game
{
    public:
        void CreateMenu();
        void CloseMenu();
        void MenuButtons();

    private:
        sfg::SFGUI sfgui;
        sfg::Desktop dtop;
        sfg::Window::Ptr menu_window;

        sfg::Button::Ptr menu_exit;

        sfg::Box::Ptr box_HOR;
        sfg::Box::Ptr box_VER;
};

void GUI::CreateMenu()
{
    box_HOR = sfg::Box::Create(sfg::Box::Orientation::HORIZONTAL);
    box_HOR->Pack(menu_exit, false, true);
}

void GUI::MenuButtons()
{
    menu_exit = sfg::Button::Create("Exit");
}

//Set characters to a sprite.
void Game::CreateCharacters()
{
    sprite.setTexture(texture);

    CropSprite();
}

//This will be a vector later and it will load all
//characters individually.
void Game::LoadCharacters()
{
    if(!texture.loadFromFile("Resources/Characters/Player.png"))
    {
        cout << "Error loading texture" << endl;
    }

    CreateCharacters();
}

//We dont want our character to be the entire sprite sheet
//so we crop out the character and its position that we want.
void Game::CropSprite()
{
    source.x = 1;
    source.y = Left;

    sprite.setTextureRect(sf::IntRect(source.x * 32, source.y * 32, 32, 32));
}

void Game::UserInput()
{
    if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
    {
        source.y = Up;
        sprite.move(0, -1.3);
    }
    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
    {
        source.y = Left;
        sprite.move(-1.3, 0);
    }
    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
    {
        source.y = Down;
        sprite.move(0, 1.3);
    }
    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
    {
        source.y = Right;
        sprite.move(1.3, 0);
    }
    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
    {
        //menu_exit
    }
}

void Game::Collision()
{

}

void Game::Program()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "App");
    window.setFramerateLimit(60);

    window.resetGLStates();


    LoadCharacters();

    while(window.isOpen())
    {
        sf::Event event;
        while(window.pollEvent(event))
        {
            switch(event.type)
            {
                case sf::Event::Closed:
                    window.close();
                break;
            }
        }
        window.clear(sf::Color::White);

        UserInput();

        window.draw(sprite);
        window.display();
    }
}

int main()
{
    Game game;
    game.Program();

    return 0;
}
 

10
General / Cant get SFML working
« on: September 20, 2014, 07:55:50 am »
I had to restart my computer completley and I cant seem to get SFML working again. Last time I built it with Cmake but i dont want to do that this time, I am using a pre compiled binary, I am using SFGUI-TDM-481r3-32.7z

from

http://nightlybuilds.ch/

I am using code blocks:

codeblocks-13.12mingw-setup-TDM-GCC-481.exe

I set up SFML exactly as its shown in the tutorial on the site here. except i put -s on the end of all my libraries. I get these errors in code blocks

Also I should mention i am using the code example from the tutorials.

||=== Build: Debug in SFML Test (compiler: GNU GCC Compiler) ===|
C:\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `glReadPixels@28'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glClearColor@16'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glMatrixMode@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glPopMatrix@0'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glMatrixMode@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glPopMatrix@0'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glMatrixMode@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glPopMatrix@0'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glPopClientAttrib@0'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glViewport@16'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glMatrixMode@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glLoadMatrixf@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glMatrixMode@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `__GLEW_EXT_blend_func_separate'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `__glewBlendFuncSeparateEXT'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `__GLEW_EXT_blend_equation_separate'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `__glewBlendEquationSeparateEXT'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glBlendFunc@8'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `__GLEW_EXT_blend_equation_separate'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `__glewBlendEquation'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glBlendFunc@8'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `__GLEW_ARB_multitexture'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glDisable@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glDisable@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glDisable@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glDisable@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glEnable@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glEnable@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glMatrixMode@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glEnableClientState@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glEnableClientState@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glEnableClientState@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glLoadMatrixf@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `__glewClientActiveTextureARB'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `__glewActiveTextureARB'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glPushClientAttrib@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glPushAttrib@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glMatrixMode@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glPushMatrix@0'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glMatrixMode@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glPushMatrix@0'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glMatrixMode@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glPushMatrix@0'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glVertexPointer@16'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glColorPointer@16'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glTexCoordPointer@16'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glDrawArrays@12'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glLoadMatrixf@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glLoadMatrixf@4'|
C:\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `glClear@4'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

11
Graphics / Tile Editor is off center?
« on: August 30, 2014, 12:16:53 am »
Ok so in my tile editor it never draws the bottom right square. why is that?

#include <SFML/Graphics.hpp>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Tile Editor");
    sf::Event event;
    sf::Mouse mouse;
    sf::Clock clock;
    sf::Time time;
    sf::View scrollScreen;
    sf::View zoomScreen;
    vector<vector<sf::Sprite> > Grid;
    int GridSizeX = 50; //Anything higher than 200x200 tiles is bad
    int GridSizeY = 50;
    window.setFramerateLimit(60);

    scrollScreen.reset(sf::FloatRect(0, 0, window.getSize().x, window.getSize().y));

    sf::Texture blankGridTexture;
    sf::Sprite blankGridSprite;
    if(!blankGridTexture.loadFromFile("Resources/Tiles/Grid.png"))
    {

    }
    blankGridSprite.setTexture(blankGridTexture);
    blankGridSprite.setOrigin(0, 0);


    //Input grid into vector
    Grid.resize(GridSizeY);
    for(int x = 0; x < GridSizeX; x++)//Column
    {
        for(int y = 0; y < GridSizeY; y++)//Row
        {
            Grid[y].push_back(blankGridSprite);
            blankGridSprite.setPosition(x * 32, y * 32);
        }
    }

    while(window.isOpen())
    {
        while(window.pollEvent(event))
        {
            switch(event.type)
            {
                case sf::Event::Closed:
                {
                    window.close();
                }break;
                case sf::Event::Resized:
                {
                    sf::FloatRect viewArea(0, 0, event.size.width, event.size.height);
                    window.setView(sf::View(viewArea));
                    scrollScreen.reset(sf::FloatRect(0, 0, window.getSize().x, window.getSize().y));
                    zoomScreen.reset(sf::FloatRect(0, 0, window.getSize().x, window.getSize().y));
                }break;
            }
        }
    window.clear(sf::Color::White);

    time = clock.getElapsedTime();

    scrollScreen.setViewport(sf::FloatRect(0, 0, 1.0f, 1.0f));

    sf::Vector2i pixel_pos = sf::Mouse::getPosition(window);
    sf::Vector2f coord_pos = window.mapPixelToCoords(pixel_pos, scrollScreen);

    cout << "Row: " << rint(coord_pos.x / 32) << ",";
    cout << "Column: " << rint(coord_pos.y / 32) << endl;


    sf::Image mask;
    mask.loadFromFile("Resources/Tiles/EditSquare.png");
    mask.createMaskFromColor(sf::Color(200, 191, 231));

    sf::Texture editSquareTexture;
    sf::Sprite editSquareSprite;
    editSquareTexture.loadFromImage(mask);
    editSquareSprite.setTexture(editSquareTexture);
    editSquareSprite.setOrigin(16, 16);

    //Set position of edit square to the mouse
    editSquareSprite.setPosition(rint(coord_pos.x / 32) * 32 + 16, rint(coord_pos.y / 32) * 32 + 16);

    //Load Grass
    sf::Texture tileTexture;
    sf::Sprite tileSprite;
    if(!tileTexture.loadFromFile("Resources/Tiles/Grass.png"))
    {
        cout << "Couldnt load resources" << endl;
    }
    tileSprite.setTexture(tileTexture);
    tileSprite.setOrigin(16, 16);

    if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
    {
        scrollScreen.move(-10, 0);
    }
    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
    {
        scrollScreen.move(10, 0);
    }
    if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
    {
        scrollScreen.move(0, -10);
    }
    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
    {
        scrollScreen.move(0, 10);
    }

    //Draw map
    for(int x = 0; x < Grid.size(); x++)
    {
        for(int y = 0; y < Grid[x].size(); y++)
        {
            window.draw(Grid[x][y]);
        }
    }

    int indexX = rint(coord_pos.x / 32);
    int indexY = rint(coord_pos.y / 32 + 1);

    if(sf::Mouse::isButtonPressed(sf::Mouse::Left))
    {
        if(indexY <= Grid.size())
        {
            Grid[indexY][indexX].setTexture(tileTexture);
        }
        else
        {
            cout << "Out of bounds" << endl;
        }
    }
    if(sf::Mouse::isButtonPressed(sf::Mouse::Right))
    {
        if(indexY <= Grid.size())
        {
            Grid[indexY][indexX].setTexture(blankGridTexture);
        }
        else
        {
            cout << "Out of bounds" << endl;
        }
    }

    window.draw(editSquareSprite);
    window.setView(scrollScreen);
    clock.restart();
    window.display();
    }

    return 0;
}
 

12
Graphics / Does SFML delete sprites that are drawn over?
« on: August 26, 2014, 07:01:40 am »
Ok so I have a tile editor and I made it so that  you can move the camera with WASD and i noticed that it moves around at a good speed but the more i draw the slower the camera speed gets, it is instantly noticeable the second i start drawing. Im thinking either the tiles im drawing over are either stacking on top of each other or the list that is storing the tiles is getting full really fast and causing problems. I dont feel like spending an hour and a half re formatting code so i'll just put it in google drive. When you draw on the map, just keep drawing, and moving and you'll see it slow down. It's a code blocks project but if you have another IDE you can just take the files out.

https://drive.google.com/file/d/0B2dzHO9C0wPsZHN0S0dkbldVTlU/edit?usp=sharing

13
Graphics / Help using mouse to draw onto grid and collision help
« on: August 22, 2014, 05:03:30 am »
I have been trying to do this for 2 days now and I just cant seem to get it to work. I know how it should be done in my head, I just have a very hard time translating that to code. I need the mouse to get the current sprite it's over and then set the texture to a different one, but I cannot figure out how to do it, I looked all through the documentation, the forums here, google I just cant find anything that helps me. The code below is taken from my game project, but I made it so that it will work correctly if you just copy and paste it into your IDE


#include <SFML/Graphics.hpp>
#include <iostream>
#include <fstream>

using std::cout;
using std::endl;

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");

    sf::Mouse mouse;
    while(window.isOpen())
    {
        window.clear(sf::Color::White);
        sf::Event event;
        while(window.pollEvent(event))
        {
            switch(event.type)
            {
                case sf::Event::Closed:
                {
                    window.close();
                }break;
                case sf::Event::Resized:
                {
                    sf::FloatRect visibleArea(0, 0, event.size.width, event.size.height);
                    window.setView(sf::View(visibleArea));
                }break;
            }
        }

        //Set Tiles to Grid Test
        sf::Texture setGridTexture;
        sf::Sprite setGridSprite;
        setGridSprite.setTexture(setGridTexture);
        setGridSprite.setColor(sf::Color::Black);

        sf::Vector2i Grid(15,15);

        sf::Texture tempGridTexture;
        sf::Sprite tempGridSprite;
        tempGridSprite.setTexture(tempGridTexture);
        tempGridSprite.setColor(sf::Color::Green);

        sf::Vector2i setTilesOnGridX(mouse.getPosition(window).x, Grid.x);
        sf::Vector2i setTilesOnGridY(mouse.getPosition(window).y, Grid.y);

        //Draw Grid
        for(int i = 0; i < Grid.x; i++)
        {
            for(int j = 0; j < Grid.y; j++)
            {
                tempGridSprite.setPosition(j * 32, i * 32);
                tempGridSprite.setTextureRect(sf::IntRect(Grid.x * 32, Grid.y * 32, 32, 32));
                window.draw(tempGridSprite);
            }
        }

        //Place Tiles
        if(sf::Mouse::isButtonPressed(sf::Mouse::Left))
        {
            cout << "Clicked" << endl;
            window.draw(setGridSprite);
            setGridSprite.setPosition(setTilesOnGridX.x * 32, setTilesOnGridY.y * 32);
            setGridSprite.setTextureRect(sf::IntRect(Grid.x * 32, Grid.y * 32, 32, 32));
            }
            else
            {
                cout << "Let go" << endl;
            }

        //End set tiles to Grid Test.
        window.display();
    }
}
 



Also I cannot figure out collision either. I looked at the documents about the intersecting function, but that did nothing. Here is the code for the current collision I have.

#include <iostream>
#include <math.h>
#include <vector>
#include <SFML/Graphics.hpp>

using namespace std;

int main()
{
    sf::Vector2f position;
    sf::Vector2f velocity;
    float maxspeed = 4.0f;
    float accel = 4.5f;
    float decel = 0.01f;
    bool vSyncEnabled = true;
    sf::FloatRect bottom, left, right, top;

    sf::Vector2f dsize;
    sf::Color color;
    sf::RectangleShape rect;


    //Setup Window and Framerate
    sf::RenderWindow window(sf::VideoMode(800, 600), "Bounding Box (Collision)");
    window.setFramerateLimit(60);
    window.setVerticalSyncEnabled(vSyncEnabled);

    //Load Texture
    sf::Texture character;
    if(!character.loadFromFile("Resources/Textures/triangle.png"))
    {
        cout << "Error loading resource 'triangle.png'" << endl;
    }
    else
    {
        cout << "triangle.png texture loaded" << endl;
    }

    //Set Sprite for Character Object
    sf::Sprite characterSprite;
    characterSprite.setTexture(character);
    //characterSprite.setOrigin(sf::Vector2f(0, 0));dsa
    characterSprite.setPosition(400, 300);

    //Load Red Block Texture
    sf::Texture redBlock;
    if(!redBlock.loadFromFile("Resources/Textures/RedBlock.png"))
    {
        cout << "Error loading 'RedBlock.png" << endl;
    }
    else
    {
        cout << "RedBlock.png texture loaded" << endl;
    }

    //Set Sprite for Red Block Object
    sf::Sprite redBlockSprite;
    redBlockSprite.setTexture(redBlock);
    redBlockSprite.setOrigin(sf::Vector2f(0, 0));
    redBlockSprite.setPosition(200, 200);

    sf::Vector2f RBSposition;

    while(window.isOpen())
    {

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

        while(window.pollEvent(event))
        {
            switch(event.type)
            {
                case sf::Event::Closed:
                {
                    window.close();
                }
                break;
                //Dont stretch the window contents when its resized
                case sf::Event::Resized:
                {
                    sf::FloatRect visibleArea(0, 0, event.size.width, event.size.height);
                    window.setView(sf::View(visibleArea));
                }
                break;
            }
        }

        rect.setPosition(position);
        rect.setSize(dsize);
        rect.setFillColor(color);

        //WASD Movement
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
        {
            velocity.x -= accel;
        }
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
        {
            velocity.x += accel;
        }
        else
        {
            velocity.x *= decel;
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
        {
            velocity.y -= accel;
        }
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
        {
            velocity.y += accel;
        }
        else
        {
            velocity.y *= decel;
        }

        //Make sure the sprite isn't going too fast
        if(velocity.x < -maxspeed) velocity.x = -maxspeed;
        if(velocity.x >  maxspeed) velocity.x =  maxspeed;
        if(velocity.y < -maxspeed) velocity.y = -maxspeed;
        if(velocity.y >  maxspeed) velocity.y =  maxspeed;

        //Update sprite position and move sprite
        position += velocity;

        //Get the window's size
        sf::Vector2u currWSize = window.getSize();

        if(position.x <= 0)
        {
            position.x = 0;
        }
        if(position.y <= 0)
        {
            position.y = 0;
        }
        if(position.x >= currWSize.x - characterSprite.getGlobalBounds().width)
        {
            position.x = currWSize.x - characterSprite.getGlobalBounds().width;
        }
        if(position.y >= currWSize.y - characterSprite.getGlobalBounds().height)
        {
            position.y = currWSize.y - characterSprite.getGlobalBounds().height;
        }


        float x, y, BoundsX, BoundsY;
        float CharX, CharY, CharBoundsY, CharBoundsX;

        x = redBlockSprite.getPosition().x;
        y = redBlockSprite.getPosition().y;

        BoundsX = redBlockSprite.getGlobalBounds().width;
        BoundsY = redBlockSprite.getGlobalBounds().height;

        CharX = characterSprite.getPosition().x;
        CharY = characterSprite.getPosition().y;


    //Collision
    if(characterSprite.getGlobalBounds().intersects(redBlockSprite.getGlobalBounds()))
    {
         //If player hits right side of block, go right
        if(CharX <= x)
        {
            position.x = x - BoundsX;
        }
        else if(CharX >= x)
        {
            position.x = x + BoundsX;
        }
        else if(CharY <= y)
        {
            position.x = y - BoundsY;
        }
        else if(CharY >= y)
        {
            position.x = y + BoundsY;
        }
    }

        sf::FloatRect rectToMove(position, {characterSprite.getGlobalBounds().width, characterSprite.getGlobalBounds().height});


        characterSprite.setPosition(position);
        velocity *= decel;
        window.draw(characterSprite);
        window.draw(redBlockSprite);

        window.display();
    }

    return 0;
}
 

If I can at least get these 2 things figured out, then I can finally get somewhere with my project.

14
General / Using an int in sf::Vector2i
« on: August 21, 2014, 06:07:29 am »
I have been looking all over for a way to use an int in vector 2i, how do i convert the int or use it in there? I couldnt find anything in the documentation or a google search so what do i do?

15
Graphics / Is there a way to take a capture of the map width and height?
« on: August 20, 2014, 03:17:46 pm »
Ok so what I want to do is save an image of the entire map to a file. The problem im having is it only saves what is shown in the window, I want it to save the entire height and width of the map not the window. I'm a bit unsure on how to go about doing this though, if it's even possible.

Pages: [1] 2