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

Pages: [1] 2
1
General / **whats the problem?** Program.exe has stop working
« on: December 06, 2014, 06:20:11 pm »
Hey everyone.

My program crashes because of the these 3 lines of code.

1. (*it)->createBullet(bulletTexture,bulletImage,shipImage);/// creates a bullet of a specific object
2. (*it)->moveBullet(bulletImage); ///move the bullet of a specific object
3.  (*it)->drawBullet(myGameGUI,bulletImage);///draws the bullet of a specific object
 

i am using vector to store objects of class and iterating over the vector to use the objects to call specific functions from the class.
What is the problem? why does it keep crashing?

Here is the main function



int main()
{
int i=0;

Ship shipObject;
Bullet bulletObject;
vector <Bullet*> bulletArsenal;
vector<Bullet*>::iterator it = bulletArsenal.begin();



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

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

    while(myGameGUI.isOpen())
    {
     while(myGameGUI.pollEvent(action))
        {
        closeFunction();
        }
        bool fire =false;

shipObject.moveShip(action, shipImage,myGameGUI);///Calls function from ship class and Moves the ship

if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space)){
        bulletArsenal.push_back(&bulletObject);/// adds a new object to the vector
 (*it)->createBullet(bulletTexture,bulletImage,shipImage);/// creates a bullet of a specific object *********
        fire=true;
        }
(*it)->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
        (*it)->drawBullet(myGameGUI,bulletImage);///draws the bullet of a specific object  **************
        myGameGUI.display();

        if(fire==true)
        ++it;
    }
return 0;
}

 

2
Graphics / Re: Help with Projectiles
« on: December 04, 2014, 12:37:11 am »
Don't open new threads on the same topic. If you keep doing this, your threads will simply get deleted.

Ok thanks exploter .Laurent messaged me and made everything clear

3
Graphics / Re: Help with Projectiles
« on: December 03, 2014, 09:47:33 pm »
Whenever you want to do something with all the objects in a container, you want to iterate over that container.

Hey G
I am iterating over the container with the while loop, using int i as the index number... Take a look at it .
Is that not how its done ?

4
Graphics / Re: Help with Projectiles
« on: December 03, 2014, 09:43:44 pm »
 
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.

Ok thanks G. i know that i am not a strong coder. Just learning as i go along  :)

5
Graphics / Re: Help with Projectiles
« on: December 03, 2014, 08:50:30 pm »

Draw all the bullets at their respective positions each frame.

I am not to sure how to do it .
Jesper can you please show me an example of that?

6
Graphics / Re: Help with Projectiles
« on: December 03, 2014, 08:12:07 pm »


He also posted about 5 other topics with the same title and description but they seem to have been removed as I cant find them and my post history does not show them despite me posting in them.

Yes Gambit i did make some post to i could increase the number of eyes that saw it. Thanks for responding to my other posts.
What did suggest on the other posts?

7
Graphics / Re: Help with Projectiles
« on: December 03, 2014, 08:09:24 pm »
It might have something to do with the fact that you're only drawing one of the bullets every frame.

Ok thanks Ixrec for pointing out the problem, how should fix this problem ?

8
Graphics / Re: Help with Projectiles
« on: December 03, 2014, 04:40:01 am »
What is i?

i is the index for the vector .
Why do you think the the bullet keeps reappearing and multiple bullets wont appear on the screen?

9
Graphics / Help with Projectiles
« on: December 03, 2014, 02:23:07 am »
Hey everyone. I am doing a space game
Here is the code of the main function.
When i press space only one bullet is fired and it keeps reappearing when i press space.
can anyone tell me why does this happen.

i want as many bullets that i fire to appear on the screen. please help 

int main()
{
int i=0;

Ship shipObject;
Bullet bullletObject;
vector <Bullet> bulletArsenal;


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

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

    while(myGameGUI.isOpen())
    {
     while(myGameGUI.pollEvent(action))
        {
        closeFunction();
        }
        bool fire =false;

shipObject.moveShip(action, shipImage,myGameGUI);///Calls function from ship class and Moves the ship

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
        fire=true;
        }

        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();

        if(fire==true)
        i++;
    }
return 0;
}

 


10
SFML projects / Re: **Looking for developers help** take a look at this
« on: November 30, 2014, 02:21:17 am »
:o
Knuth would turn over his grave =.=


Why would knuth turn over in his grave  ???

11
SFML projects / Re: **Looking for developers help** take a look at this
« 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

12
SFML projects / Re: **Looking for developers help** take a look at this
« 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

13
SFML projects / Re: **Looking for developers help** take a look at this
« 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

14
SFML projects / Re: **Looking for developers help** take a look at this
« 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 ?

15
SFML projects / **Looking for developers help** take a look at this
« 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++;
 

Pages: [1] 2
anything