SFML community forums

General => SFML projects => Topic started by: Pacman on November 26, 2014, 12:43:42 am

Title: **Looking for developers help** take a look at this
Post by: Pacman on November 26, 2014, 12:43:42 am
Hey i am doing a space shooting game.
So far i am proud of progress
I have an issue that every time i press space to a  shoot a bullet the first bullet that is fired disappears .
I am using a vector of the bullet to create and move the bullets
Why does this happen and how can i fix it ;

here is my main function
int main()
{
int i=0;
Ship shipObject;
Bullet bullletObject;
vector <Bullet> bulletArsenal;


    ///Creates the Window
    myGameGUI.create(sf::VideoMode(1000,680), "WorkingGameProject");
    sf::Style::Default;

    Background();///Creates the background

    ///calls function ship class and creates the ship
    shipObject.createShip(shipTexture, shipImage);


    while(myGameGUI.isOpen())
    {
     while(myGameGUI.pollEvent(action))
        {
        closeFunction();
        }
///Calls function from ship class and Moves the ship
shipObject.moveShip(action, shipImage,myGameGUI);

if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space)){
        bulletArsenal.push_back(bullletObject);/// adds a new object to the vector
        bulletArsenal[i].createBullet(bulletTexture,bulletImage,shipImage);/// creates a bullet of a specific object
        }

        bulletArsenal[i].moveBullet(bulletImage); ///move the bullet of a specific object

        myGameGUI.clear();///clears screen
        myGameGUI.draw(backgroundImage);///draws the background
        shipObject.drawShip(myGameGUI,shipImage);///draws the ship
        bulletArsenal[i].drawBullet(myGameGUI,bulletImage);///draws the bullet of a specific object
        myGameGUI.display();
        i++;
 
Title: Re: **Looking for developers help** take a look at this
Post by: Ixrec on November 26, 2014, 01:15:16 am
It probably has something to do with the fact that you're only moving and drawing one of the bullets in your vector each frame.  Is that deliberate?  Do you know how to iterate over STL containers?


P.S. Those are very redundant comments.  Your variable names are good enough that the meaning of the code  is already obvious without them (as it should be).
Title: Re: **Looking for developers help** take a look at this
Post by: Pacman on November 26, 2014, 01:43:05 am
It probably has something to do with the fact that you're only moving and drawing one of the bullets in your vector each frame.  Is that deliberate?  Do you know how to iterate over STL containers?

Will iterating the Vector allow more than one bullet to appear on the screen ?
Title: Re: **Looking for developers help** take a look at this
Post by: Ixrec on November 26, 2014, 01:49:30 am
Whenever you want to do something with all the objects in a container, you want to iterate over that container.  Do you know what "iterating over a container" actually means?  It feels like you might be lacking a fundamental understanding of C++, which is necessary to use a library like SFML effectively.
Title: Re: **Looking for developers help** take a look at this
Post by: Pacman on November 26, 2014, 03:14:09 am
Whenever you want to do something with all the objects in a container, you want to iterate over that container.  Do you know what "iterating over a container" actually means?  It feels like you might be lacking a fundamental understanding of C++, which is necessary to use a library like SFML effectively.

Just answer the question ...Yes or No or give me some valuable help
I see trying and have me like a clown ..doe never try that
Title: Re: **Looking for developers help** take a look at this
Post by: Gambit on November 26, 2014, 03:34:31 am
Dont be rude. Iterating over anything doesnt magically make things appear on the screen, so the answer is no. Iterating will give you a way to access each item in the vector/list/array/whatever.
Title: Re: **Looking for developers help** take a look at this
Post by: achpile on November 27, 2014, 06:20:43 pm
 :o
Knuth would turn over his grave =.=
Title: Re: **Looking for developers help** take a look at this
Post by: Hapax on November 28, 2014, 01:15:06 am
http://en.sfml-dev.org/forums/index.php?topic=16770
http://en.sfml-dev.org/forums/index.php?topic=16781
http://en.sfml-dev.org/forums/index.php?topic=16835
http://en.sfml-dev.org/forums/index.php?topic=16866

It looks like you want the SFML community to write every other line of your game for you.
Title: Re: **Looking for developers help** take a look at this
Post by: StormWingDelta on November 28, 2014, 05:28:40 pm
I might help but you are going to have to show some attempt at working on your project on your own first and show me what direction your are going with it. Got a huge Card game I'm working on though so won't be much help. 



The key to building a team on this forum is to show you are trying to complete a good chunk of your project first, provide a GDD (Game Design Document) or Program Design Document of some kind so we know what you are up to and if it is even worth trying to help, also no one here is going to code this for you without you also helping with the coding as well or some other part you are good at.

There are other ways but basically asking a group to code for you and griping about us not wanting to help never ends well.
Title: Re: **Looking for developers help** take a look at this
Post by: Hapax on November 28, 2014, 07:44:30 pm
Got a huge Card game I'm working on
Card game?
*cough* Spinning Card (http://en.sfml-dev.org/forums/index.php?topic=16388.0) *cough*
Hope it's of some use to you  :P
Title: Re: **Looking for developers help** take a look at this
Post by: StormWingDelta on November 28, 2014, 08:57:44 pm
Got a huge Card game I'm working on
Card game?
*cough* Spinning Card (http://en.sfml-dev.org/forums/index.php?topic=16388.0) *cough*
Hope it's of some use to you  :P

lol might be useful later but I'll need to get things working normally before adding some flare in. :)
Title: Re: **Looking for developers help** take a look at this
Post by: Pacman on November 30, 2014, 02:09:47 am
 


also no one here is going to code this for you without you also helping with the coding as well or some other part you are good at.

There are other ways but basically asking a group to code for you and griping about us not wanting to help never ends well.


I didnt ask anybody to write code for me and i dont need anybody to write code for me... The Partner made a comment and made it seem that i wasn't good enough for SFML so i stood for my right
Title: Re: **Looking for developers help** take a look at this
Post by: Pacman on November 30, 2014, 02:12:52 am


It looks like you want the SFML community to write every other line of your game for you.

BE CAREFUL WHAT YOU SAY !

i made great progress on my game i did it on my own with the help of research, i didnt get any valuable response to help me with my game in any of the post i made... and why you looking at my profile so closely. stop lurking boy.
AND
I didnt ask anybody to write code for me and i dont need anybody to write code for me... The Partner made a comment and made it seem that i wasn't good enough for SFML so i stood for my right
Title: Re: **Looking for developers help** take a look at this
Post by: Pacman on November 30, 2014, 02:21:17 am
:o
Knuth would turn over his grave =.=


Why would knuth turn over in his grave  ???
Title: Re: **Looking for developers help** take a look at this
Post by: Hapax on November 30, 2014, 04:45:51 am
BE CAREFUL WHAT YOU SAY !
...
why you looking at my profile so closely.
Why are you threatening me? I'm pretty sure I don't deserve to be bullied for pointing out that what you have done.

I didn't look closely at your profile. I simply remember you posting the same (almost) question a number of times and wondered if you had actually posted anything else. Alas, you had not.

If you think my sentence was incorrect, wouldn't the correct thing to do be just prove that it was incorrect and why?

You are looking for "help". I, for one, will no longer consider contributing to your help.
Title: Re: **Looking for developers help** take a look at this
Post by: Gambit on November 30, 2014, 04:55:38 am
Your rudeness will get you nowhere, especially here. While most of the people here have no problem helping people, being rude and threatening members for no reason will get you no help at all. Im with Hapax on this.