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

Author Topic: Why it gives me a bluescreen ?  (Read 1868 times)

0 Members and 1 Guest are viewing this topic.

Ionut

  • Jr. Member
  • **
  • Posts: 59
  • Guess Who's Back ?
    • View Profile
    • Email
Why it gives me a bluescreen ?
« on: April 21, 2017, 07:33:51 am »
Hey ! I have a question, I'm making a Dragon Ball Z SFLM(2.4.2) game and I want to implement :

If the Player pressed "Z", the attack(Projectile) will trigger in the face of the Player(not really in the face, like some distance) and it will continue to go as long as it doesn't hit the wall, if it reaches the wall it will vanish and return to the player coordinates.

Notes : The Projectile(attack) will go ahead the player ( the x coord.).
        The Player will not be able to move while the attack is active.
        The Player must hit "Z" only once and the attack will go to the wall.
        Sorry for my bad english .
        When I keep pressed "Z" too much the windows gives me a blue screen for 1 second and it restarts my laptop, Why ? 
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace sf;
using namespace std;
int main()
{
    int x = 0;
    int MinX = 0;
    int MaxXS = 800 - 39;
    int MaxXR = 800 - 49;
    int MinY = 0;
    int MaxYS = 600 - 49;
    int MaxYR = 600 - 41;
    int y = 0;
    int speed = 5.0;
    bool vSyncEnabled = true;
    RenderWindow window(VideoMode(800,600), "SFML works!");
    window.setFramerateLimit(60);
    window.setVerticalSyncEnabled(vSyncEnabled);
    Texture texturaS;
    if(!texturaS.loadFromFile("Stand.bmp"))
    {
        cout<<"ERROR"<<endl;
    }
    else
    {
        cout<<"TEXTURE LOADED"<<endl;
    }
    Sprite spritS;
    spritS.setTexture(texturaS);
    spritS.setOrigin(Vector2f(0, 0));
    spritS.setPosition(400, 300);
    Vector2f posS = spritS.getPosition();
    Texture texturaR;
    if(texturaR.loadFromFile("Run.bmp"))
    {
        cout<<"ERROR"<<endl;
    }
    else
    {
        cout<<"LOADED"<<endl;
    }
    Sprite spritR;
    spritR.setTexture(texturaR);
    spritR.setOrigin(Vector2f(0, 0));
    spritR.setPosition(400, 300);
    Vector2f pos = spritR.getPosition();
     Texture texturaB;
     if(texturaB.loadFromFile("BigBang.bmp"))
    {
        cout<<"ERROR"<<endl;
    }
    else
    {
        cout<<"LOADED"<<endl;
    }
    Sprite spritB;
    spritB.setTexture(texturaB);
    spritB.setOrigin(Vector2f(0, 0));
    spritB.setPosition(pos.x,pos.y);
    Vector2f posB = spritB.getPosition();
    while (window.isOpen())
    {
        Event event;
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed)
                window.close();
        }
        if(Keyboard::isKeyPressed(Keyboard::Left))
        {
            pos.x -= speed;
            if(pos.x < MinX)
            {
                pos.x += speed;
            }
            cout<<"Pos. of x : "<<pos.x<<endl;
        }
        if(Keyboard::isKeyPressed(Keyboard::Right))
        {
            pos.x += speed;
            if(pos.x > MaxXR)
            {
                pos.x -= speed;
            }
        else if(pos.x > MaxXS)
            {
                pos.x -= speed ;
            }
            cout<<"Pos. of x : "<<pos.x<<endl;
        }
        if(Keyboard::isKeyPressed(Keyboard::Up))
        {
            pos.y -= speed;
            if(pos.y < MinY)
            {
                pos.y += speed;
            }
            cout<<"Pos. of y : "<<pos.y<<endl;
        }
        if(Keyboard::isKeyPressed(Keyboard::Down))
        {
           pos.y += speed;
           if(pos.y > MaxYR)
            {
                pos.y -= speed;
            }
            else if(pos.y > MaxYS)
            {
                pos.y -= speed ;
            }
           cout<<"Pos. of y : "<<pos.y<<endl;
        }
        if(Keyboard::isKeyPressed(Keyboard::Z))
        {
            if(posB.x < 800)
            {
            posB.x += speed;
            }
            if(posB.x >= 800)
            {
                posB.x = pos.x;
                posB.y = pos.y;
            }
            cout<<"Pos. of Z : "<<posB.x<<endl;
        }
        spritS.setPosition(pos.x , pos.y);
        spritR.setPosition(pos.x , pos.y);
        spritB.setPosition(posB.x , posB.y);
        if(Keyboard::isKeyPressed(Keyboard::Down) || Keyboard::isKeyPressed(Keyboard::Up) || Keyboard::isKeyPressed(Keyboard::Left) || Keyboard::isKeyPressed(Keyboard::Right))
        {
        window.clear();
        window.draw(spritR);
        }
        if(!Keyboard::isKeyPressed(Keyboard::Down) && !Keyboard::isKeyPressed(Keyboard::Up) && !Keyboard::isKeyPressed(Keyboard::Left) && !Keyboard::isKeyPressed(Keyboard::Right))
        {
            window.clear();
            window.draw(spritS);
        }
        if(Keyboard::isKeyPressed(Keyboard::Z))
        {
            window.clear();
            window.draw(spritS);
            window.draw(spritB);
        }
        window.display();
    }
    return 0;
}
 
« Last Edit: May 01, 2017, 09:54:08 am by Boanc »
Guess Who's Back ?

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Why it gives me a bluescreen ?
« Reply #1 on: April 21, 2017, 08:40:59 am »
There seems to be something wrong with your system, possibly some driver issue or a hardware problem. Whatever you do with SFML, you can't trigger bluescreens directly. At most your application would be force closed/crash, but that's it.

Ionut

  • Jr. Member
  • **
  • Posts: 59
  • Guess Who's Back ?
    • View Profile
    • Email
Re: Why it gives me a bluescreen ?
« Reply #2 on: April 21, 2017, 03:51:25 pm »
Thanks it works now that I have all my drivers updated, but now I have another question, How to shoot an attack ?
( I want it to move automatically when I press "Z" and in that time the player will be unable to move)
« Last Edit: April 21, 2017, 06:30:44 pm by Boanc »
Guess Who's Back ?

 

anything