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

Pages: [1] 2
1
See the previous article (that's also linked from the one we pointed you at): http://gafferongames.com/game-physics/integration-basics/
oh, thanks, that answered many of my questions :)

2
thanks guys, btw, what is
integrate( state, t, deltaTime );
in that code ?

3
Graphics / strange and sharp object movement, due to SetFramerateLimit
« on: March 04, 2015, 06:08:41 pm »
Hello guys, I have a problem, as I know, SetFramerateLimit calls Sleep() to keep game framerate probably constant, but here's the problem, when I use
int main() {
RenderWindow Window(VideoMode(1024,768), "Window");
Window.setFramerateLimit(60);

RectangleShape rs;
rs.setSize(Vector2f(50,50));
rs.setPosition(0,0);

while(Window.isOpen()) {
rs.move(5,0);
Window.draw(rs);
Window.display();
Window.clear();
}
return 0;
}
 

that rectangle is moving very sharply every random frame and it can also move a bit back, or a bit forward, I don't know how to fix this :c

4
Graphics / Re: Loading a file from a folder in the current directory.
« on: February 15, 2015, 09:28:56 pm »
Note that '/' works as a path seperator on both Windows and Unix and does not need to be escaped as "\\"...

works too, but there's no sense in this, because this code is windows-only, he'll need to search another piece of code for another OS  :)
btw, that's strange, but on Visual Studio 12 thing like "./myImg.png" doesn't work, just tested this

5
Graphics / Re: Loading a file from a folder in the current directory.
« on: February 15, 2015, 09:23:39 pm »
On windows, you can use this

#include <windows.h>

string getPath() {
    char buffer[MAX_PATH];
    GetModuleFileName( NULL, buffer, MAX_PATH );
    string::size_type pos = string( buffer ).find_last_of( "\\/" );
    return string( buffer ).substr( 0, pos);
}
 

then write

Image img;
img.loadFromFile(getPath() + "\\myImg.png");
 

6
Graphics / Re: How to draw a button2 by clicking on button1?
« on: February 15, 2015, 09:18:12 pm »
I think, you should replace
leftclick = true;
to
leftclick = !leftclick;
or
leftclick ^= true;

and move these variables from the cycle, because it's recursive, leftclick and rect1clicked will be false each frame, move them to the beginning of the main()
like :
 
int main() {
  bool leftclick = false;
  bool rect1clicked = false;

   sf::RenderWindow mMainWindow(sf::VideoMode(400, 400), "Window");
   mMainWindow.setFramerateLimit(40);

//all other code
 

7
General / Re: CPU core loaded to 100% when sfml app is launched
« on: February 08, 2015, 08:45:14 pm »
thanks for help, it now uses 1 - 2% of cpu :3

8
General / CPU core loaded to 100% when sfml app is launched
« on: February 08, 2015, 08:21:46 pm »
hello there guys, I have a problem, when I'm compiling that "test" code for sfml, I see that one of my core immediately become loaded from 1 - 3% to 80 - 100% and that's kinda strange, isn't that too much for an sfml or maybe that's my hardware issue ? Haven't tested this on other computers, here are screenshots :


9
General / Re: AW: NetBeans problem
« on: January 11, 2015, 04:25:25 pm »
What MinGW file did you download and install?
What exact SFML package did you download?

this is MinGW file which I downloaded and installedhttp://www.mingw.org/
and this is the SFML package which I downloaded

10
General / NetBeans problem
« on: January 11, 2015, 04:06:12 am »
Hello guys, I have a problem with setting up SFML and NetBeans with minGW compiler. Looks like I connected all correctly, I'm using SFML 2.2 build for MinGW - 32bit





I'm trying to compile this simple code :
#include <SFML/Graphics.hpp>
 
int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);
 
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
 
        window.clear();
        window.draw(shape);
        window.display();
    }
 
    return 0;
}

and I get this error
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Release.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/d/NetBeansProj/SFML_ENGINE'
"/C/MinGW/msys/1.0/bin/make.exe"  -f nbproject/Makefile-Release.mk dist/Release/MinGW-Windows/sfml_engine.exe
make.exe[2]: Entering directory `/d/NetBeansProj/SFML_ENGINE'
mkdir -p build/Release/MinGW-Windows
rm -f "build/Release/MinGW-Windows/main.o.d"
g++    -c -O2 -DSFML_STATIC -I../../SFML-2.2/include -std=c++11 -MMD -MP -MF "build/Release/MinGW-Windows/main.o.d" -o build/Release/MinGW-Windows/main.o main.cpp
In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\cmath:44:0,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\random:38,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algo.h:65,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\algorithm:62,
                 from ../../SFML-2.2/include/SFML/System/Utf.hpp:32,
                 from ../../SFML-2.2/include/SFML/System/String.hpp:32,
                 from ../../SFML-2.2/include/SFML/System.hpp:39,
                 from ../../SFML-2.2/include/SFML/Window.hpp:32,
                 from ../../SFML-2.2/include/SFML/Graphics.hpp:32,
                 from main.cpp:1:
c:\mingw\include\math.h: In function 'float hypotf(float, float)':
c:\mingw\include\math.h:635:30: error: '_hypot' was not declared in this scope
 { return (float)(_hypot (x, y)); }
                              ^
make.exe[2]: *** [build/Release/MinGW-Windows/main.o] Error 1
make.exe[2]: Leaving directory `/d/NetBeansProj/SFML_ENGINE'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/d/NetBeansProj/SFML_ENGINE'
make.exe": *** [.build-impl] Error 2
 
BUILD FAILED (exit value 2, total time: 1s)

tried reinstalling minGW twice and tried googling, but no result, that's why I'm here

11
Graphics / Re: Problem with collision on Resizing
« on: December 23, 2014, 12:06:38 pm »
Sounds like you're not converting the co-ordinates from actual pixel co-ordinates (the mouse position) to the world co-ordinates (the positions of the graphics in the view).
This should solve your problem:
http://www.sfml-dev.org/tutorials/2.2/graphics-view.php#coordinates-conversions
Thanks dude, I'll give you a cookie, works now :D

12
Graphics / Re: Problem with collision on Resizing
« on: December 23, 2014, 01:03:52 am »
GUI.cpp code
Vector2f GUI::mousePosition(RenderWindow& _window){
        Vector2f pos(Mouse::getPosition(_window));
        return pos;
}

void GUI::CreateButton(Vector2f position, Vector2f size, String text, Texture buttonIMG[3])
{
                buttonSettings rect; // creating button

                rect.buttonIMG = buttonIMG[0];
                rect.buttonGUIDANCE = buttonIMG[1];
                rect.buttonCLICK = buttonIMG[2];

                rect.btns.setSize(size);
                rect.btnText.setFont(font);
                rect.btnText.setCharacterSize(16);
                rect.btnText.setColor(Color(200,200,200));
                rect.btnText.setString(text);
                rect.btnText.setPosition(rect.btns.getPosition().x + (rect.btns.getSize().x/2 - rect.btns.getSize().x/5) , rect.btns.getPosition().y + (rect.btns.getSize().y/3)); // setting text in the middle
                buttons.push_back(rect);
}
 
int GUI::OnButtonClick(RenderWindow& _window) {
        for(btnID = 0; btnID != buttons.size(); btnID++) {
                        FloatRect bounds(buttons[btnID].btns.getGlobalBounds());

                if(bounds.contains(mousePosition(_window)) && event.type == Event::MouseButtonPressed) {
                        if(event.mouseButton.button == Mouse::Left) {
                                                        buttons[btnID].btns.setTexture(&buttons[btnID].buttonCLICK); // on button click
                                return btnID;
                        }
                }
                                if(bounds.contains(mousePosition(_window))) { // on button guidance
                                        buttons[btnID].btns.setTexture(&buttons[btnID].buttonGUIDANCE);
                                }
                                else {
                                  buttons[btnID].btns.setTexture(&buttons[btnID].buttonIMG); // button idle
                                }

        }
}

GUI.h
typedef struct buttonSettings {
        Text btnText;
                RectangleShape btns;
                Vector2f size;
                Texture buttonIMG, buttonGUIDANCE, buttonCLICK;
        };

vector<buttonSettings> buttons;
 

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

using namespace std;
using namespace sf;

Texture img[3];

string getPath()
{
  char result[ MAX_PATH ];
  return string( result, GetCurrentDirectory(100, result));
}

int main() {
        RenderWindow window(VideoMode(1024,768), "game"); // window initialisation
        window.clear();

        for(unsigned short i = 0; i<3; i++) {
                img[i].loadFromFile(getPath() + "\\GUI\\BUTTON\\BUTTON_" + to_string(i) + ".png");
        }

        gui.CreateButton(Vector2f(window.getSize().x/2, window.getSize().y/18), Vector2f(200, 70), "", img); // creating button
         window.display();

 while(window.isOpen()) {
while(window.pollEvent(Event event) {
gui.OnButtonClick(window);
}
}
}

here, all working code, but textures changes, not color and I'm resizing window manually, so all the elements are scaling

13
Graphics / Problem with collision on Resizing
« on: December 23, 2014, 12:35:18 am »
Hello guys, I have a problem, I draw some squares in my window and they change their color, when I guide my cursor over them, but when I change manually the screen size, their collision is still on the last point, where it was, when those buttons haven't been resized, so, when I guide my cursor over them, there's nothing, but when I guide my cursor on that last place, squares change their color, any ideas what can I do ?

14
Graphics / Re: GUI drawing
« on: December 11, 2014, 02:54:06 am »
It sounds like you're asking for a "scene graph."  It's out of scope for SFML, but a common element of games and game engines so once you know that phrase it's easy to google a lot of detailed help on implementing them.  I believe there's one in the SFML Game Development book too.

If you were asking for GUI elements, what Jesper said.
If I understanded correctly, I should create a Parent-child system and make GUI as a child and view as a root ?

15
Graphics / GUI drawing
« on: December 11, 2014, 12:44:10 am »
hello guys, I have a question, how can I do something like glue GUI element to a current RenderWindow or current view ? I want that GUI to be a child of a view and I don't know how to do that, maybe you can guide me to the right path ?

Pages: [1] 2