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.


Topics - Pacman

Pages: [1]
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 / 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;
}

 


3
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++;
 

4
General / Shooting projectiles Straight **Advice needed***
« on: November 23, 2014, 01:21:26 am »
Hey SFML coders !
How do i get a sprite to be fired as projectile and move straight ahead .

Please explain Precise and simple ... your knowledge will be appreciated
Here is the code i have.

 
/////////////////////////////
   ///Create the bullet
////////////////////////////
void Bullet::createBullet(sf::Texture &bulletTexture, sf::Sprite &bulletImage, sf::Sprite &shipImage)
{
  if(!bulletTexture.loadFromFile("Images/missile.png"))///creates the bullet
        cout << "ERROR:bullet could not load" << endl;

    bulletImage.setTexture(bulletTexture);///
    sf::Vector2f shipLocation = shipImage.getPosition(); ///Gets the location of the ship

    float locationX = shipLocation.x - 83;///sets the X location of the ship places the bullet of  it
    float locationY= shipLocation.y +4 ;///sets the Y loction of the ship

    bulletImage.setPosition(locationX, locationY);
}
 

////////////////////////
///Move the bullet
////////////////////////
void Bullet::moveBullet(sf::Sprite &bulletImage, sf::Sprite &shipImage)
{
    float moveX = shipImage.getPosition().x;
    bulletImage.move(-3,0);
}

 


5
SFML projects / How to make a space ship shoot bullets ??
« on: November 15, 2014, 05:49:19 am »
I am new to SFML. I just started a space game project.
I have made good progress.
I would like help as to how do i make my ship shoot bullets using STL containers.
I have no idea how i should start.


if you wouldnt mind maybe you could be my mentor, we could talk on keep in touch on facebook.  i am from the caribbean .
I would appreciate the help.

void bullets()
{


}

6
SFML projects / Space shooting Game
« on: November 12, 2014, 10:07:59 pm »
I am new to sfml and i am doing a space shooting game that should have  :
- a space ship that shoots bullets
- asteroids that move towards the ship

i have the ship and it is moving perfectly .
I am trying to create the bullets and make the ship fire the bullets.
I have no idea how to start to create the bullets or make the ship fire 

Can some please guide me as to how to do this ?
Or direct me to an example of code
PLEASE BE SPECIFIC !!

Pages: [1]