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

Pages: [1] 2
1
General discussions / Is the book SFML Game Development still valid?
« on: December 22, 2014, 01:43:14 am »
Now that SFML 2.2 has been released, is this book now out of date and of no use?

2
General discussions / Re: SFML Game Development -- A book on SFML
« on: March 18, 2014, 06:05:59 pm »
I couldn't wait to get this book and bought the kindle edition. It is ok on the kindle, but I'm going to buy the hard copy when I can because I like to make notes. This is a great book that I am enjoying reading!

3
General / Re: How to install sfml 2.1 in debian linux?
« on: March 17, 2014, 10:02:52 pm »
I figured it out -
1. cd into sfml-build
2. make install clean

4
General / Re: How to install sfml 2.1 in debian linux?
« on: March 17, 2014, 08:52:41 pm »
This does not seem to help me unfortunately

5
General / How to install sfml 2.1 in debian linux?
« on: March 17, 2014, 08:18:04 pm »
Hi, I only have sfml 1.6 with my package manager and thought I would try and install 2.1. Unfortunately I'm not clear about how to install 2.1 after having read through the instructions several times.

I downloaded the 2.1 bundle and ran cmake-gui. I followed all of the instructions, getting all the dependencies installed and 'built' sfml in my home directory in a folder named sfml-build. What do I do from here to install sfml into a system wide path? How can I start to use it? With the 1.6 build I simply type "g++ -o someapp someapp.cpp -lsfml-system" and everything works. Ideally I want to set up my system so that 2.1 works in the same way without having to explicitly specify different paths.

If I can't get this working I will just continue with 1.6 Thanks

6
Graphics / Re: Controlling sprite movement speed?
« on: May 13, 2013, 05:35:27 pm »
Lots of people on this forum will echo me in saying that you should have a good grasp of C++ and programming before you attempt to use SFML to make games.
Prepare to be shat upon. :D
Last time I implied he should  maybe learn a little more C++, he got angry and insulted me on a few posts and Laurent eventually deleted the thread. It was almost a year ago.

You have the wrong person. I have not 'got angry' and insulted anyone here in a few posts or more. It confuses me that you are making this claim. I am sure you have your reasons for doing so.

Anyway, i do not need to be 'shat upon' by anyone because I am perfectly capable of reading and learning myself. I may not have '100 forum posts' to my name, but I have solid experience of using c++. There are many forums online and many people who actually like helping others out. I've had help from c++ experts in learning standard c++ and continue to learn. Even the most incredibly experienced programmers do not know and cannot know everything. My point is that if - as you imply - there are people here who go out of their way to post 'put downs' or whatever at others - I don't need to get involved as there are many other options for help open to me. I was simply posting here to learn - not to get into arguments or upset anyone. If people cannot give me the same level of courtesy that I give them I don't have any business engaging in communications of that type.

I should make it clear i was grateful for your help - I was not taking the mic - i just needed to see some example code for the speed control. I was not comfortable simply copying some code and hacking it until it worked. I was actually trying to understand a few whys and hows. My difficulties did not stem from lack of c++ knowledge but because i have not ever used this particular library before. There are some classes and features that are intuitive - the issue that i raised was not and I needed further information / examples. So thanks for your help. 


7
Graphics / Re: Controlling sprite movement speed?
« on: May 13, 2013, 12:00:00 am »
Yes and I am not here to be insulted by you or anyone else. One person kindly took the time to explain something to me I had trouble understanding. You seem to have a chip on your shoulder as I did NOT find your contribution helpful. Don't bother replying to any questions I raise in the future as I intensely dislike people like you who seem to indicate by your language that you are somehow a cut above anyone else.
And finally I don't need you to tell me what I should be doing with my time. I never asked your opinion.

8
Graphics / Re: Controlling sprite movement speed?
« on: May 12, 2013, 09:36:13 pm »
Hi thanks G. This is the effect i wanted.
Now i know how to control the speed - i can easily define where the sprite stops. This was a long journey to get to this. No one can look me in the eye and tell me that this is clearly explained in the tutorial.

9
Graphics / Re: Controlling sprite movement speed?
« on: May 12, 2013, 07:45:08 pm »
But this does not work. What happens now - with one key press, is that the sprite moves only halfway up the window - and it is not moving at a slow rate either.


#include<SFML/Graphics.hpp>
#include<SFML/System.hpp>
int main()
{
sf::RenderWindow mywindow(sf::VideoMode(800, 600, 32), "missile testing");
 mywindow.setVerticalSyncEnabled(true);
// create sprite
sf::Texture missilepic;
missilepic.loadFromFile("/home/game/images/missile.png");
sf::Sprite missile;
missile.setTexture(missilepic);
missile.setPosition(400,500);
//size of sprite
missile.setScale(0.01f,0.02f);
 sf::Vector2f position(400,500);
 
sf::Time elapsed;
 sf::Clock clock;

        bool running = true;
        while(mywindow.isOpen())
        {
      elapsed = clock.getElapsedTime();
                sf::Event event;
        while (mywindow.pollEvent(event))
          {
                if((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
                mywindow.close();
         
                if((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::LShift))
                  {
                    // fire 1 missile          
                        missile.move(0, -200 * elapsed.asSeconds() );
                        clock.restart();
                  }
          }

        mywindow.clear();
        mywindow.draw(missile);
        mywindow.display();
} // while window is open
 return EXIT_SUCCESS;
}//main

 
Why is it moving halfway up only? I removed the loop that was there before. Now, the time setting does not seem to have had any effect other than to stop the sprite halfway.
Please can someone post some code so that i can see what the syntax should look like?

10
Graphics / Re: Controlling sprite movement speed?
« on: May 12, 2013, 06:12:50 pm »
Hey, can someone please help me with this?
So far, I have had answers that have told me that my code to capture the event of a key press was incorrect. I have fixed that now, but the other problem i had - and the main problem - was concerning the movement speed of a sprite. I have asked if someone could kindly post the single line of code that shows the correct syntax to achieve what i want, but I have only been given vague answers that have not really helped.

I need to make a sprite move over a defined number of pixels, in 2 seconds

I understand that speed is calculated by distance / time. I really don't need to know the speed - I just need to see the sprite move along for 2 seconds. As you can see I have not provided 'clock' or 'time' with any values as they are not being used.

[while(mywindow.isOpen())
        {
          sf::Clock clock;
          sf::Time dt;
                       
        sf::Event event;
        while (mywindow.pollEvent(event))
          {
                if((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
                mywindow.close();
         
                if((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::LShift))
                  {
                    // fire 1 missile!
                    while(position.y >= 0)
                      {
                        missile.move(0, -1);
                        --position.y;
                       
                      }                  
                  }
         
}
 
This test works to move my sprite the distance I want, but obviously there are no speed or time considerations.

The documentation says about member function move( ):
void    move (float offsetX, float offsetY)
        Move the object by a given offset.
 


In the test code above the offset is -1 on each iteration. What I am asking for is the code that simply makes my sprite move over the distance stated in 2 seconds.

11
Graphics / Re: Controlling sprite movement speed?
« on: May 11, 2013, 12:48:46 am »
Hi - my question is mainly about the movement speed of the sprite.

speed = distance/ time
The distance is 400 pixels. I do not know what / how to adjust time to make it a reasonable speed.

- can you shed any light on that?

12
Graphics / [SOLVED] Controlling sprite movement speed?
« on: May 10, 2013, 06:21:36 pm »
I am having problems learning to move a missile up the y axis.
Now to move a sprite representing a space ship I used this:
int keycode(0);
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
          keycode = 1;
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
          keycode = 2; 

        switch(keycode)
          {
          case 1:// move left
            {
            position = ship.getPosition();
            if(position.x <= 0.0)
              ship.setPosition(0.0,500);
            else
              ship.move(-0.130 * elapsed.asMilliseconds(),0);
            break;
            }
          case 2: // move right
          {
            position = ship.getPosition();
            if(position.x >= 700.0)
              ship.setPosition(800-shipsize.width,500);
            else
            ship.move(0.130 * elapsed.asMilliseconds(),0);
            break;
          }
         
          }
 
By trial & error I got it moving at the type of speed I wanted. The trouble is that I now want to give my ship a function to fire a missile. So say the window i use is 800x600 and the ship moves along the x axis only, but is set at position 500 on the y axis. - The y axis position of my ship does not change. A missile will always start at position 500 on the y axis and go up towards the top of the window. (Note that the xy axis in sfml is flipped so 0,0 is the top left corner of window.)

I have been trying to build a test program that moves a missile up the y axis once the left-shift button is pressed. It should work without a ship.
This code does make missile move - but it does not do what I want it to. Note that once i have working code i will turn this into a class & remove magic numbers etc. For simplicity, i'm not worried about doing that at the moment :

// an implementation of a missile.
#include <iostream>
#include<SFML/Graphics.hpp>
#include<SFML/System.hpp>
int main()
{
sf::RenderWindow mywindow(sf::VideoMode(800, 600, 32), "missile testing");
 mywindow.setVerticalSyncEnabled(true);
// create sprite
sf::Texture missilepic;
missilepic.loadFromFile("/home/game/images/missile.png");
sf::Sprite missile;
missile.setTexture(missilepic);
missile.setPosition(400,500);

 sf::Time elapsed;
 sf::Clock clock;

        bool running = true;
        while(mywindow.isOpen())
        {
           elapsed = clock.getElapsedTime();
          clock.restart();
               
        sf::Event event;
        while (mywindow.pollEvent(event))
          {
                if((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
                mywindow.close();
          }    
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::LShift))
          { // code to move missile
           
                missile.move(0, -2 * elapsed.asSeconds());    
             
          }

        mywindow.clear();
                mywindow.draw(missile);
 mywindow.display();
}
 return EXIT_SUCCESS;
}//main

 
problem 1. Unless I keep the l-shift key pressed, the missile will only move a short distance. I need it to move from it's origin on y-axis at 500 right up to 0 - with 1 key press. I think a loop will be needed but with what parameters?

problem 2. Adjusting speed. at first i experimented with the code that i used to move the ship left/right. But this does not work for the missile as that code depends on the left or right key remaining pressed. If i use the same settings, the missile moves too fast. So how can i make it move at a slower rate? What is the code to use?

I asked for help on another forum, but the answer i had was wrong as the person thought that the missile movement code was part of the event - polling code - it isn't as it appears outside of that loop. Anyway, i am mixed up about this as i cannot see how to move the missile up the y axis at a controlled speed (that can be changed easily).

13
Window / Re: Can someone clearly explain the coordinate system.
« on: April 30, 2013, 03:02:01 pm »
I think you miss the intermediate layer between the 2D world and the window: the view (sf::View) -- as pointed out by eXpl0it3r.

Global coordinates of sprites and other entites are mapped to your window's pixels by the current view. It's the view that defines the area which is visible in the window. So, to center a sprite (1.) or make it collide with the boundaries of the visible area (2.), you have to use the view's rectangle to do all your calculations. You should never use the window for that.

Quote
I call shameless copy!
Mine is better ah ah 8)

Thank you Sir - I could not figure this out. I did not mean any disrespect at all to your tutorials as i know it could not have been possible for you to explain every feature in tiny detail. I am looking forward to the book for that. Your answer, coupled with the references other people have provided should be enough for me to get an understanding now. Thanks.

14
Window / Re: Can someone clearly explain the coordinate system.
« on: April 30, 2013, 02:55:23 pm »
You sometimes have to be a bit more patient, then again it has somehow slipped by me... ;)

It seems you're still using SFML 1.6. SFML 2.0 just got released, so you should definitely switch.
The best explanation I can give you for now is written down in my sf::View tutorial, though it's not 100% uptodate with the 2.0 release, but everything up to one function is still accurate. :)

Yes, sorry i was getting a bit frustrated yesterday.
I know about 2.0, but stuck to 1.6 simply as I had printed off all of the tutorials some months ago. Also, I have been experimenting with some of the features and felt that if i went over to the upgrade it would set me back some. I know you are right though when you say i should switch - i'm just a bit lazy  :(

Edit:
I just build SFML 2.0 using cmake-gui - It was a very simple process that took 5 mins!  :-[
I am going to take your sound advice and use it from now on. 

15
Window / Re: Can someone clearly explain the coordinate system.
« on: April 29, 2013, 09:32:31 pm »
isnt nobody going to answer this?

Pages: [1] 2
anything