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

Pages: [1] 2 3 4
1
General / wrong mouse coordinates and yes i did search in google
« on: January 29, 2012, 07:54:53 pm »
Quote from: "Laurent"
Code: [Select]
if (position.x < 0)
    position.x = 0;
etc.


thanks that was helpful.

2
General / wrong mouse coordinates and yes i did search in google
« on: January 29, 2012, 07:44:02 pm »
Quote from: "Laurent"
Quote
It should stop at 0, 0.

Why? The mouse is not at (0, 0) when it's in the corner of the screen. The new behaviour is more consistent.

If you don't want negative coordinates, just clamp them.

And please remove your image:
- it is too large, it forces to scroll to reach the forum buttons
- it is too heavy, it takes many seconds to display


sorry about the images.
ok but how do i keep the mouse coordinates between 0,0 and 800,600 which is the window size?

how do i clamp them?

3
General / wrong mouse coordinates and yes i did search in google
« on: January 29, 2012, 07:22:22 pm »
Quote from: "Laurent"
So what's wrong? You get coordinates relative to your window, everything's ok.


in sfml 1.6 when i move the mouse to the top left corner of my window i get 0, 0. Even if i move my mouse out of the window i still get 0,0.
However in sfml 2.0 when i move my mouse to the top left corner of my window i get 0,0 BUT when i keep moving the mouse to the top corner of my screen i get -500, -270. It should stop at 0, 0.

4
General / wrong mouse coordinates and yes i did search in google
« on: January 29, 2012, 06:55:47 pm »
Quote from: "Laurent"
Is (-500, -200) the top-left corner of your window, or the top-left corner of your screen?


top-left corner of my screen.

my screen is 1080, 1920. before when i just do this

Code: [Select]

std::cout<<sf::Mouse::GetPosition().x << " ";
std::cout<<sf::Mouse::GetPosition().y << "\n";


i was getting 0, 0 top corner of my screen and 1920, 1080 bottom right corner of my screen.

after i did this
Code: [Select]

std::cout<<sf::Mouse::GetPosition(Window).x << " ";
std::cout<<sf::Mouse::GetPosition(Window).y << "\n";


i get -500, -270 top corrner of my screen and 1300, 800 bottom right corner of my screen.

My window size is 800, 600. and screen size is 1920, 1080.

5
General / wrong mouse coordinates and yes i did search in google
« on: January 29, 2012, 06:40:24 pm »
Hello guys
First of all I did go and search before i post this topic and i found a lot of posts about this topic but my problem is a bit wired.

My window is 800, 600 and when i print the mouse coordinates i get x from -500 to 1300 and Y from -200 to 800.

how can i make the lowest value for x 0 and biggest 800 and for y 0 and 600?

Code: [Select]
#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>

#include <string>
#include <iostream>

#pragma comment(lib, "sfml-window-d.lib")  
#pragma comment(lib, "sfml-graphics-d.lib")  
#pragma comment(lib, "sfml-system-d.lib")  

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

while(Window.IsOpen())
{

std::cout<<sf::Mouse::GetPosition(Window).x << " ";
std::cout<<sf::Mouse::GetPosition(Window).y << "\n";

Window.Clear();
Window.Display();
}
return 0;
}

6
General / does SFML 1.6 support OpenGL 4.0 context?
« on: January 24, 2012, 12:16:16 pm »
ok thank you very much.
I'm sorry for asking so many newbie question. I just have few more.

ok so why do i need these files and what is the use of them ?

gl.h
glu.h

I opened both gl.h and glu.h and they ware dated for 1995 and 1996 and they are version 4. why are we using old files? and is there newer versions? and what are they used for ?

and what is the use of GLEW library? and do i need it to create OpenGL application?

finally what exactly do i need to do to use the latest version of OpenGL which is 4.2?

all I know is I have to create a Context and set both MajorVersion to 4 and MinorVersion to 2 and use the latest OpenGL functions.

thank you very much you ware very helpful :)

7
General / does SFML 1.6 support OpenGL 4.0 context?
« on: January 24, 2012, 11:20:43 am »
ok i have a OpenGL question.
Now as far as i know functions like glBegin, glEnd, glVertex3f, and glColor3f are not part of OpenGL 4.0. Now if i try to use them with window Context 4.0 they work. Shouldn't function like this give me some kind of error or something because they are not a part of OpenGL 4.0, so why are they working?

Isn't window Context 4.0 means that I'm using OpenGL 4.0 function ?
And how do i differentiate between OpenGL old function and OpenGL new functions ?

Code: [Select]

#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>
#include <SFML\OpenGL.hpp>
#include <iostream>

int main()
{
sf::Window Window(sf::VideoMode(800, 600, 32), "Game", sf::Style::Close, sf::ContextSettings(24, 8, 16, 4, 0));

glClearDepth(1.f);
glClearColor(0.f, 0.f, 0.f, 0.f);

// Enable Z-buffer read and write
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);

// Setup a perspective projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.f, 1.f, 1.f, 500.f);

std::cout<<Window.GetSettings().MajorVersion;
std::cout<<Window.GetSettings().MinorVersion;

while(Window.IsOpen())
{
sf::Event Event;
while (Window.PollEvent(Event))
{
if (Event.Type == sf::Event::Closed)
Window.Close();

if (Event.Type == sf::Event::Resized)
glViewport(0, 0, Event.Size.Width, Event.Size.Height);
}

Window.SetActive();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.f, 0.f, -200.f);

glBegin(GL_QUADS);

glVertex3f(-50.f, -50.f, -50.f);
glVertex3f(-50.f,  50.f, -50.f);
glVertex3f( 50.f,  50.f, -50.f);
glVertex3f( 50.f, -50.f, -50.f);

glVertex3f(-50.f, -50.f, 50.f);
glVertex3f(-50.f,  50.f, 50.f);
glVertex3f( 50.f,  50.f, 50.f);
glVertex3f( 50.f, -50.f, 50.f);

glVertex3f(-50.f, -50.f, -50.f);
glVertex3f(-50.f,  50.f, -50.f);
glVertex3f(-50.f,  50.f,  50.f);
glVertex3f(-50.f, -50.f,  50.f);

glVertex3f(50.f, -50.f, -50.f);
glVertex3f(50.f,  50.f, -50.f);
glVertex3f(50.f,  50.f,  50.f);
glVertex3f(50.f, -50.f,  50.f);

glVertex3f(-50.f, -50.f,  50.f);
glVertex3f(-50.f, -50.f, -50.f);
glVertex3f( 50.f, -50.f, -50.f);
glVertex3f( 50.f, -50.f,  50.f);

glVertex3f(-50.f, 50.f,  50.f);
glVertex3f(-50.f, 50.f, -50.f);
glVertex3f( 50.f, 50.f, -50.f);
glVertex3f( 50.f, 50.f,  50.f);

glEnd();
Window.Display();
}
return 0;
}

8
General / does SFML 1.6 support OpenGL 4.0 context?
« on: January 23, 2012, 08:41:33 pm »
Hello guys
I was just wondering does SFML support window mode for OpenGL 4.0 context?
I heard that SFML uses OpenGL 1.1 context. I'm just starting to learn OpenGL and I was wondering can use both OpenGL 4.0 and SFML 1.6 without any problem?

9
Graphics / Buttons moving with view
« on: January 05, 2012, 02:30:32 pm »
Quote from: "julen26"
Draw the button on the default view:
Code: [Select]

...
set your view
draw player
reset default view //  window.SetView(window.GetDefaultView())  //
draw button
...


thank you very much that works :)

10
Graphics / Buttons moving with view
« on: January 05, 2012, 10:46:28 am »
Hello guys
I have a sprite called button and my player sprite.
now i have a problem where the button sprite is moving with the screen. How can i only move the screen without moving the button sprite?

11
General / typewriter effect like RPG games
« on: December 14, 2011, 05:14:04 pm »
Quote from: "julen26"
You could use a Clock to control the time between characters, and use a variable to get a substring of the string.

You shouldn't use sleep functions, because they would pause the game every iteration.

Code: [Select]
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <sstream>

int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

    // Create a graphical text to display
    sf::Font font;
    if (!font.LoadFromFile("arial.ttf"))
        return EXIT_FAILURE;
    sf::Text text("", font, 50);

    sf::Clock timer;
    unsigned int character = 0;
    std::string str = "This is an example of typewriter \neffect, it uses one clock to control \nthe time. Check out the code, it's \neasy to understand!";

    // Start the game loop
    while (window.IsOpened())
    {
        // Process events
        sf::Event event;
        while (window.PollEvent(event))
        {
            // Close window : exit
            if (event.Type == sf::Event::Closed || (event.Type == sf::Event::KeyPressed && event.Key.Code == sf::Keyboard::Escape))
            window.Close();
        }

        if (timer.GetElapsedTime() > 50 && character < dialog.size())
        {
            timer.Reset();
            character++;
            text.SetString( sf::String( str.substr(0, character) ) );
        }

        // Clear screen
        window.Clear();

        // Draw the string
        window.Draw(text);

        // Update the window
        window.Display();
    }

    return EXIT_SUCCESS;
}


It's very easy to understand.

Cheers.


thank you very much that was very very helpful :D
I just modified the code to work with sfml 1.6 because I'm still using the 1.6 xD. Here is the code modified for 1.6 for anyone else who want to use it.

Code: [Select]

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

int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

sf::String text;

    sf::Clock timer;
    unsigned int character = 0;
    std::string str = "This is an example of typewriter \n effect, it uses one clock to control \n the time. Check out the code, it's \n easy to understand!";

//text.SetText(str);
text.SetSize(20);

    // Start the game loop
    while (window.IsOpened())
    {
window.SetFramerateLimit(60);

        sf::Event Event;
while (window.GetEvent(Event))
        {
            // Close window : exit
if (Event.Type == sf::Event::Closed || (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Escape))
window.Close();
        }

if (timer.GetElapsedTime() > 0.1 && character < str.length())
        {
            timer.Reset();
            character++;
text.SetText( str.substr(0, character) ) ;
        }

        window.Clear();
        window.Draw(text);
        window.Display();
    }

    return 0;
}



again thank you very much.

12
General / typewriter effect like RPG games
« on: December 14, 2011, 01:21:32 pm »
Hello
I want to make a typewriter effect where text get displayed letter by letter like in RPG games.

I did some coding and got it to work in windows console but i can't figure out how to do it in SFML.

here is an example on how i want this.
http://www.youtube.com/watch?v=CrvTQDsMOn0

here is the code working
Code: [Select]

#include <iostream>
#include <string>
#include <windows.h>

using namespace std;

int main() {

string Text = "This Text should be display letter by letter like a typewriter :D\n if this works I would be freak'n happy xD";

for (int x = 0; x < Text.length(); x++) {
          cout << Text[x];
          Sleep(100);
     }

     system("pause");
     return 0;
}

13
General / Dynamic library for commercial project ?
« on: December 09, 2011, 12:37:01 pm »
Quote from: "Laurent"
Quote
I just want to know what do i have to do to not get sued by SFML group or by other library like OpenAL, GLEW, freetype etc...

Basically, nothing (except maybe mentionning all the libraries used and their license).

SFML ensures that its dependencies are compatible with its own license. And the SFML license is really simple, there's nothing more than what's written; so there's no dynamic link constraint.

There's nothing hidden. Using SFML is free of constraints, everything is made so that users don't have to worry about license issues.


thank you very much. that was a relief.

14
General / Dynamic library for commercial project ?
« on: December 09, 2011, 12:25:58 pm »
Hello
Right now i have linked my project with static library, and I'm planing on selling my game. So my question is, do i need to change my project linking to dynamic and use dll files for a commercial project?

also I read the SFML License and it says that i can use the library for commercial project and all i have to do is just to acknowledgment that i used sfml in my game. well what about the other library's that's sfml is using? do i need to do anything about it?

I just want to know what do i have to do to not get sued by SFML group or by other library like OpenAL, GLEW, freetype etc...

15
Graphics / animation drop frame rate from 60 to 10fps?
« on: November 02, 2011, 08:32:42 am »
Quote from: "Haikarainen"
std::cout is a heavy operation(belive it or not) and you should never use it every frame. Delete all std::cout lines and give us your framerate!

Edit; Also, why are you doing this:

Code: [Select]
     float time1 = clock.GetElapsedTime();
      float time2 = clock.GetElapsedTime();
      float time3 = clock.GetElapsedTime();
      float time4 = clock.GetElapsedTime();
      float time5 = clock.GetElapsedTime();

instead of just
Code: [Select]
     float time = clock.GetElapsedTime();
and
Code: [Select]
     if(time >= 1.0)
?


Wow never thought that std::cout is a heavy operation.
i deleted std::cout and my frame rate went back to 60FPS.
the resone i did this
Code: [Select]
     float time1 = clock.GetElapsedTime();
      float time2 = clock.GetElapsedTime();
      float time3 = clock.GetElapsedTime();
      float time4 = clock.GetElapsedTime();
      float time5 = clock.GetElapsedTime();

hmm... to think of it again i really don't need all of this :D, i don't know what i was thinking LOL :D.
it was 3am in the morning and i was really tired, so that's why i did this i guess xD.

thanks

Pages: [1] 2 3 4