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

Pages: [1]
1
Graphics / Re: Shooting Bullets System
« on: May 12, 2015, 08:02:17 pm »
That's My Code ..
#include <SFML/Graphics.hpp>

int main(){
///Window Parameters///////////////////////////////////////////////
    sf::ContextSettings settings;
    settings.antialiasingLevel = 13;
    sf::RenderWindow window(sf::VideoMode(800, 600), "AlaEddine", sf::Style::Default, settings);

    bool x;
    bool y;
///Loading PLAYER.PNG////////////////////////////
    sf::Texture pTexture;
    sf::Sprite player;
    if(pTexture.loadFromFile("player.png"))
        player.setPosition(x,y);
///loading bullet.png ////////////////////////////
    sf::Texture bTexture;
    sf::Sprite bullet;
    if(bTexture.loadFromFile("bullet.png"))
    ///Texturing Player.png/////
    player.setTexture(pTexture);
    ///Texturing Bullet.png/////
    bullet.setTexture(bTexture);
    bullet.setScale(-10000,-10000);

    while(window.isOpen())
    {

        sf::Event Event;
        while(window.pollEvent(Event))
        {

            ///Exit When Escape Pressed////////////////////////////////////////////////
        if(Event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
            {
                window.close();
            }
        }
        /// //MOVING PLAYER//////////////////////////////
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Z))
        {
            player.move(0,-1.5);
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)){
            player.move(0,1.5);
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Q)){
            player.move(-1.5,0);
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::D)){
            player.move(1.5,0);
        }
        ///ROTATION////////////////////////////////////////////
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left)){
            player.rotate(2);
                     }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right)){
            player.rotate(-2);
                   }

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space)){

        bullet.setPosition(player.getPosition());
        bullet.setScale(1,1);
                    }
        window.draw(bullet);
        window.display();
        window.clear(sf::Color::Cyan);
        ///Showing Player To Screen
        window.draw(player);


    }
}

2
Graphics / Shooting Bullets System
« on: May 12, 2015, 07:52:42 pm »
Hey Guys i'm a  :-[ Beginner  :-[ in SFML , i'm making a top-down shooter game , i programmed the player and it is moving , but i don't know how to make it shoots bullets with the space key ! HELP ME !
(sorry for my crap English  ::) )
 

Pages: [1]
anything