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

Pages: 1 ... 6 7 [8] 9 10
106
Texture.update has a (sf::Image& image) overload  but at this point it doesn't matter as Laurent's solution is better resource and performance wise. Perhaps using http://en.cppreference.com/w/cpp/container/array would improve things even more but at this point the difference is minimal and I can't test it now so stick with Laurent's solution.

107
How about using http://sfml-dev.org/documentation/2.1/classsf_1_1Image.php so that you can either pass image as reference or use getPixelStr() which is probably destructed when image is destructed ;)
It could be suboptimal performance wise, though. Maybe someone has a better way to do it.
P.S. the docs says: the returned pointer may become invalid if you modify the image, so you should never store it for too long. If the image is empty, a null pointer is returned

108
Network / Re: a good method for client/server communication
« on: July 17, 2014, 03:59:49 am »
This is not a SFML related question and as such doesn't belong in this category. Even though the SFML devs are knowledgeable and willing to help, you should ask in a forum/site about software design or something like that (or at least move the thread in the appropriate section).

109
Network / Re: Problem with sf::UdpSocket
« on: July 17, 2014, 03:31:43 am »
Socket inherits NonCopyable. That means you can't use the assignment operator and the copy constructor. https://github.com/SFML/SFML/blob/master/include/SFML/System/NonCopyable.hpp

110
General / Re: Includes and using-namespaces trouble
« on: July 16, 2014, 11:46:35 pm »
Add -lsfml-graphics and its dependencies to the compiler's command
P.s. also -lsfml-window -lsfml-system I think

111
General / Re: Tetris clone lag after moving window
« on: July 15, 2014, 03:36:20 am »
Run a profiler and make sure the performance hog is caused by this.

112
General / Re: Tetris clone lag after moving window
« on: July 14, 2014, 10:22:52 pm »
MinimalCodeNotFoundException

113
SFML projects / Re: 'Tiled' Tile-map Loader
« on: July 14, 2014, 09:01:42 pm »
-lzlib?

114
Window / Re: Certain events only working with framelimit on or off
« on: July 13, 2014, 12:59:11 am »
You might want to read the tutorials again before someone without temper starts pulling his own hair off looking at this code.
http://www.sfml-dev.org/tutorials/2.1/window-events.php
  • You should declare sf::event before the pollevent loop.
  • One pollevent loop is all you need
  • You're mixing real time input with input handled by the events, are you sure you want to do that?

115
General / Re: Re: Removing units individually by clicking on them.
« on: July 12, 2014, 01:17:55 pm »
Should be [=] instead of just []. Which means to capture the parameters by copy inside the lambda, instead of not capturing anything (since mousecoords are defined outside).
That's what happens when you write from a tablet on the fly :( mea culpa

116
Cool stuff :)

117
General / Re: Removing units individually by clicking on them.
« on: July 11, 2014, 07:01:59 pm »
This
                if(EnemyIt->getGlobalBounds().contains(mousecoords))
                    {
                    EnemyList.erase(EnemyIt);
                    EnemyIt = EnemyList.begin();
                    }
                }
becomes
EnemyList.remove_if([](sf::Sprite sprite){return sprite.getGlobalBounds().contains(mousecoords); });
 
If it's difficult to understand this, you should stop coding and read a book. It will save you a lot of trial and error ;)

118
General / Re: c++ question, auto x doesn't work.
« on: July 11, 2014, 11:37:45 am »
It's most likely caused by the array being a raw type instead of a stl container like std::array or std::vector which have a iterator. Not 100% sure though. It works anyway
        int cArray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        std::array<int, 9> cppArray;
        std::vector<int> cppVector;
        for (auto x : cArray)
                std::cout << x << std::endl;
        for (auto x : cppArray)
                std::cout << x << std::endl;
        for (auto x : cppVector)
                std::cout << x << std::endl;
 

119
General / Re: How to "blend" two states?
« on: July 11, 2014, 08:55:15 am »
The simplest way is
Entity.move(horizontal speed * deltatime,vertical speed * deltatime);
 
Movement speed equals something like 200 pixels per second so that when multiplied by a number usually around 15 to 30-60 milliseconds you'll have a directly proportional movement. You must use a sf::Clock and call clock.restart().asSeconds() each frame for your deltatime.

120
General / Re: Removing units individually by clicking on them.
« on: July 11, 2014, 07:30:11 am »
If you want to erase any sprite that contains your cursor while right clicking you must cycle through the enemies, possibly using http://en.cppreference.com/w/cpp/language/range-for . You're testing a list iterator when what you probably want to test is a reference to a sprite.
You're asking for the cursor's position many times for no reason, are you sure mousecoords.x and mousecoords.y are not what you need?

Pages: 1 ... 6 7 [8] 9 10
anything