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

Pages: [1]
1
You have an extra closing bracket at the end, that might be the problem.

2
Graphics / Problem with creating a font/text[SOLVED]
« on: November 30, 2014, 09:52:47 am »
I've been trying to create a sf::Font and sf::Text but when I do it keeps giving an error that "fent/toxt does not name a type".
Help would be greatly appreciated:
struct VelText
{
    sf::Font fent;
    fent.loadFromFile("cour.ttf");

    sf::Text toxt;
    toxt.setFont(fent);
    toxt.setColor(sf::Color::Red);
    toxt.setPosition(0,500);

    void updateText(int nVelFact)
    {
        stringstream ss;
        ss << nVelFact;
        std::string strVelFact = ss.str();

        toxt.setString(strVelFact);
    }
};
 

FIXED:
Made the fent.loadFromFile etc. part of a create() function which solved the problem

3
Graphics / Re: Help with input and sprites
« on: April 24, 2014, 09:51:00 am »
Oh, I understand, thanks so much! :)

4
Graphics / Help with input and sprites
« on: April 24, 2014, 09:13:51 am »
I've recently picked up SFML and I'm trying to make a simple tic tac toe game, but I cannot figure out how to take input from the keyboard, and draw a sprite that stays there even after the key isn't pressed.
I know its probably very simple, but I cannot figure out how to do it at all. At the moment, the cross is only drawn when the key is down, and gets removed once it is not pressed.
Some help please!
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
    sf::RenderWindow window (sf::VideoMode(600,600), "TIC TAC TOE");

    sf::Texture Grid_Texture;
    sf::Texture Cross_Texture;

    Grid_Texture.loadFromFile("Grid.png");
    Cross_Texture.loadFromFile("Cross.png");

    sf::Sprite Grid;
    sf::Sprite Cross;

    Grid.setTexture(Grid_Texture);
    Cross.setTexture(Cross_Texture);

    Cross.setPosition(-200,-200);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear(sf::Color::Black);
        window.draw(Grid);
        window.display();

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad7))
        {
            Cross.setPosition(0,0);
            window.draw(Grid);
            window.draw(Cross);
            window.display();
        }
    }
}

5
Graphics / Re: Pictures do not display, help please.
« on: May 27, 2012, 09:49:17 am »
Thanks so much!!

6
Graphics / Re: Pictures do not display, help please.
« on: May 25, 2012, 11:14:45 am »
I don't know how to do that.(i'm new to coding)

7
Graphics / Re: Pictures do not display, help please.
« on: May 25, 2012, 11:07:59 am »
What do I put in them?

8
Graphics / Pictures do not display, help please.
« on: May 25, 2012, 10:53:43 am »
When I run this program, the render window opens, but no images display and it lags.
It's basically an animation which moves on keypress, any help is appreciated.

#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>

using namespace std;


int main()
{
   sf::Sprite Sprite;
   sf::Image person[3];
   sf::RenderWindow App(sf::VideoMode(800, 600, 32),"Test");
   int whichimage = 0;
   sf:: Clock timer;
   sf:: Event Event;

   sf:: Sprite Sprite2;
   sf:: Sprite Sprite3;
   sf:: Image background;
   sf:: Image ground;


   if(!person[0].LoadFromFile("person1.jpg")) {};
   if(!person[1].LoadFromFile("person2.jpg")) {};
   if(!person[2].LoadFromFile("person3.jpg")) {};
   if(!background.LoadFromFile("background.jpg")) {};
   if(!ground.LoadFromFile("ground.jpg")) {};

   person[0].CreateMaskFromColor((sf::Color::White),0);
   person[1].CreateMaskFromColor((sf::Color::White),0);
   person[2].CreateMaskFromColor((sf::Color::White),0);

   Sprite.SetImage(person[0]);


   Sprite.SetPosition(50.f, 255.f);
   Sprite2.SetImage(background);
   Sprite3.SetImage(ground);
   Sprite3.SetPosition(0.f, 548.f);

   App.SetFramerateLimit(10);

    while (App.IsOpened())
   {
       App.Clear(sf::Color::White);

        if (App.GetInput().IsKeyDown(sf::Key::Right))
        {
         Sprite.SetX(Sprite.GetPosition().x+10);


         if(Sprite.GetPosition().x > 700)
{
    Sprite.SetX(Sprite.GetPosition().x - 10);
}

         if(Sprite.GetPosition().y > 400)
{
    Sprite.SetX(Sprite.GetPosition().y - 10);//ground
}



if (timer.GetElapsedTime() >= 1.f)
      {

go:

Sprite.SetImage(person[+1]);

         if (++whichimage > 2)
         {
            whichimage = 0;
         }
         Sprite.SetImage(person[whichimage]);
         timer.Reset();
      }else{goto go;}

      }



        if (App.GetInput().IsKeyDown(sf::Key::Left))
        {
         Sprite.SetX(Sprite.GetPosition().x-10);


if(Sprite.GetPosition().x < -10)
{
    Sprite.SetX(Sprite.GetPosition().x+10);
}

         if(Sprite.GetPosition().y > 400)
{
    Sprite.SetX(Sprite.GetPosition().y - 10);
}






if (timer.GetElapsedTime() >= 1.f)
      {

go2:

Sprite.SetImage(person[+1]);

         if (++whichimage > 2)
         {
            whichimage = 0;
         }
         Sprite.SetImage(person[whichimage]);
         timer.Reset();
      }else{goto go2;}

      }




   }



   if(App.GetEvent(Event))
   {
       if (Event.Type == sf::Event::Closed)
           App.Close();
   }

   App.Draw(Sprite);
   App.Draw(Sprite2);
   App.Draw(Sprite3);

   App.Display();






    return 0;


}







 

Pages: [1]
anything