Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SFML 2.1 and C++] 2D Shooter - Pew (Open Source)  (Read 62755 times)

0 Members and 1 Guest are viewing this topic.

santiaboy

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: [SFML 2.1 and C++] 2D Shooter - Pew (Open Source)
« Reply #75 on: September 13, 2015, 12:25:54 am »
Hey man, if you are erasing, don't increment the variable. The "erase" erases the one pointing and then it goes to the next one.

Example:
You want to erase top 11 and 12. So you have 1,2,...,10,11,12.
You are pointing at top 11. Erase it and then you have 1,2,...,10,12 are pointing at 12. If you increment it, you will go past it.

    //erase all entries that are not in the top ten
    //but only if there are more than ten!
    if (m_numInput.size() > 10){
        for (auto it = m_numInput.begin() + 10; it != m_numInput.end();){
            it = m_numInput.erase(it);
            //it++; Don't increment it!
        }
    }
 

Besides that, I think you are trying to resize the vector. Simply use resize! It also works with lists.

So the final extract will be
    if (m_numInput.size() > 10){
        m_numInput.resize(10);
    }
 

nebula

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Email
Re: [SFML 2.1 and C++] 2D Shooter - Pew (Open Source)
« Reply #76 on: September 13, 2015, 02:12:00 pm »
Quote
    if (m_numInput.size() > 10){
        m_numInput.resize(10);
    }
@santiaboy - U sir deserve a cookie :D Thank you.

__________________________________________

Edit: Uploaded the changes to github and the new release is at the main post
« Last Edit: September 13, 2015, 02:23:37 pm by nebula »

santiaboy

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: [SFML 2.1 and C++] 2D Shooter - Pew (Open Source)
« Reply #77 on: September 13, 2015, 06:01:49 pm »
Thanks, but re-reading the thread Alex said it first :P

You could still simply replace this
if (m_numInput.size() > 10){
        for (auto it = m_numInput.begin() + 10; it != m_numInput.end(); it++){
            it = m_numInput.erase(it);
        }
    }
 

with this

 m_numInput.resize(10);

looks cleaner  :P


The "erase" bit is important, though. C++ sometimes doesn't do what you expect it to do. Erase always throws me off.

nebula

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Email
Re: [SFML 2.1 and C++] 2D Shooter - Pew (Open Source)
« Reply #78 on: September 13, 2015, 07:33:56 pm »
Quote
Thanks, but re-reading the thread Alex said it first :P
Damn - you are right :D Should listen to ppl.

nebula

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Email
Re: [SFML 2.1 and C++] 2D Shooter - Pew (Open Source)
« Reply #79 on: September 13, 2015, 07:35:53 pm »
Hello Guys,

today i have managed to get full support for the mouse in menu-related GameStates.
In Addition every menu-related GameState now has a transition.

New Release  and GitHub updated

nebula

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Email
Re: [SFML 2.1 and C++] 2D Shooter - Pew (Open Source)
« Reply #80 on: September 13, 2015, 10:18:12 pm »
Hey,

Added a SplashScreen to give Credits:







Everything updated bla bla -> as usual :'D

nebula

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Email
Re: [SFML 2.1 and C++] 2D Shooter - Pew (Open Source)
« Reply #81 on: September 14, 2015, 07:03:38 pm »
Heeeeellloooooo :D

+Core enemies now have a death animation. It is not much, but gives the whole thing a bit more life :P
+New weapon textures-> so that they look round, was too lazy to give them direction
+Fixed that music was played in the splashscreen

I will record a new video for the mainpage, because the look of the game changed quite a bit ;-)

Everything updated

nebula

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Email
Re: [SFML 2.1 and C++] 2D Shooter - Pew (Open Source)
« Reply #82 on: September 14, 2015, 08:12:58 pm »
So, there is the video:


http://youtu.be/Lz6h8L5a3ls

Also avaliable on the main post

SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Re: [SFML 2.1 and C++] 2D Shooter - Pew (Open Source)
« Reply #83 on: October 01, 2015, 04:08:14 pm »
You got me with "Einschetell√ľngen"
This looks funny as hell, will try it out :D