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

Pages: 1 ... 8 9 [10] 11 12
136
Window / Output Flashes When I Type
« on: August 15, 2010, 05:30:45 pm »
Okay cool. thanks.

137
Window / Output Flashes When I Type
« on: August 15, 2010, 04:42:36 pm »
Maybe I do.... or some coffee... Haha.

I fixed it by taking out the thing that set it to nothing. :)
Is that not suggested?

I will be using return. I'm actually attempting to put the if statement in as we post. Trying to figure out what I'm gonna set my state to. Erm...

138
Window / Output Flashes When I Type
« on: August 15, 2010, 04:24:33 pm »
Quote
I don't want to discourage you, but are you actually trying to solve any of these problems yourself? Programming is all about problem solving.


All those posts I've made, I've been working on all of those problems since about noon yesterday. It is now 9:35 in the morning and I haven't slept at all. So, my answer to your question is definitely yes. :)

Some of the posts were just questions and not even code help.

139
Window / Output Flashes When I Type
« on: August 15, 2010, 03:22:37 pm »
Whenever I type in a number for the input in my program, it flashes onto the screen whenever I hit a number (I've not allowed it to take anything but numbers).
I'm not sure what's wrong.
Code: [Select]
   sf::Font TypeKnight;
    if (!TypeKnight.LoadFromFile("Knights Templar.ttf"))
    {
        return EXIT_FAILURE;
    }
    std::string XCoord;
    std::string YCoord;
    sf::String Coord;
    Coord.SetFont(TypeKnight);
    Coord.Move(175,10);


            // Press A : Add coords
            if (myState == State0 && (Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::A))
            {
                std::cout << "ONE" << std::endl;
                myState = State1;
            }
            if (myState == State1 && (Event.Type == sf::Event::TextEntered))
            {
                std::cout << "TWO" << std::endl;

                if (counter < 5) {
                    // Handle ASCII characters only
                    if (Event.Text.Unicode > 47 && Event.Text.Unicode < 58)
                    {
                        std::cout << "THREE" << std::endl;
                        XCoord += static_cast<int>(Event.Text.Unicode);
                        Coord.SetText(XCoord);
                    }
                    ++counter;
                }
            }
            else {
                Coord.SetText("");
            }

    App.Draw(Coord);

    App.Display();

140
Window / Getting Integer Input
« on: August 15, 2010, 02:55:15 pm »
UGH! I won't stay on the screen. The number that is. It just flashes whenever I type.

141
Window / Getting Integer Input
« on: August 15, 2010, 02:41:01 pm »
Sweet! A For Loop sounds very nice right now. ;) Thanks again!

142
Window / Getting Integer Input
« on: August 15, 2010, 02:33:26 pm »
IT WORKS!!!!! YEAH!!!! YOU'RE AWESOME!!!!!!! HAHAHA
Now, I need to make it accept up to four digits in the number and submit the number when the user hits ENTER.

143
Window / Getting Integer Input
« on: August 15, 2010, 02:27:53 pm »
Sure.

Code: [Select]
int main()
{
    //sf::Thread PrintFile(&PrintFile);
    //PrintFile.Launch();

    //ifstream inFile; // Declare inFile
    //ofstream outFile; // Declare outFile

    bool PressA = false;
    std::string XCoord;
    sf::String text;

    sf::RenderWindow App(sf::VideoMode::GetMode(0), "Laz's Interactive Map :: The Wrath... :: PvP Created");
    App.ShowMouseCursor(true);
    bool windowed = true;
    sf::VideoMode DesktopMode = sf::VideoMode::GetDesktopMode();

    sf::Font TypeKnight;
    if (!TypeKnight.LoadFromFile("Knights Templar.ttf"))
    {
        return EXIT_FAILURE;
    }
    sf::String TopLeft("Text Input: ________________");
    TopLeft.SetFont(TypeKnight);
    TopLeft.Move(10,10);
    TopLeft.SetColor(sf::Color::White);

    sf::String Main("Press F12 to toggle the help menu");
    Main.SetFont(TypeKnight);
    Main.Move(10.f, 600.f);
    Main.SetColor(sf::Color::White);

    bool help = false;
    sf::String Help("Type A to add a coordinate\n\nType R to remove a coordinate\n\nType F to find a coordinate\n\nPress F1 to toggle FullScreen mode\n\nPress ESC to exit the program\n\nPress F12 to toggle the help menu");
    Help.SetFont(TypeKnight);
    Help.Move(10.f,300.f);

    sf::String CopyRight("CopyRight 2010 Tyler Petresky :: All program code is subject to CopyRight Laws");
    CopyRight.SetFont(TypeKnight);
    CopyRight.SetColor(sf::Color::White);
    CopyRight.Move(1300.f, 125.f);
    CopyRight.Scale(0.5f, 0.5f);
    CopyRight.Rotate(-90);

    // Creates the PE map :: 7000x3000
    sf::Shape MapPh;
    MapPh.AddPoint(0,0,sf::Color(0,100,0));
    MapPh.AddPoint(7000,0,sf::Color(0,100,0));
    //MapPh.AddPoint(3500,1500,sf::Color(0,125,0));
    MapPh.AddPoint(7000,3000,sf::Color(0,100,0));
    MapPh.AddPoint(0,3000,sf::Color(0,100,0));
    MapPh.EnableFill(true);
    MapPh.EnableOutline(false);
    MapPh.SetOutlineWidth(10);

    sf::Shape PhMid = sf::Shape::Line(3000, 0, 3000, 3000, 20, sf::Color::Black);
    sf::Shape DrMid = sf::Shape::Line(4000, 0, 4000, 3000, 20, sf::Color::Black);

    sf::Vector2f Center(3500, 1500);
    sf::Vector2f HalfSize(1750, 750);
    sf::View View(Center, HalfSize);
    View.Zoom(0.35f);

    // Main loop
    while (App.IsOpened())
    {
        /*int AdjWid;
        int AdjHei;
        int newWidth;
        int newHeight;
        int origWidth = App.GetWidth();
        int origHeight = App.GetHeight();*/
        // Event loop
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            /*if (Event.Type == sf::Event::Resized) {
                newWidth = App.GetWidth();
                newHeight = App.GetHeight();
                AdjWid = newWidth - origWidth;
                AdjHei = newHeight - origHeight;



            }*/

            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

            // Press escape : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();

            // Press F1 : Switch video mode
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::F1)) {
                if (windowed == true) {
                    App.Create(DesktopMode, "Laz's Interactive Map :: The Wrath... :: PvP Created", sf::Style::Fullscreen);
                    windowed = false;
                }
                else {
                    App.Create(sf::VideoMode::GetMode(0), "Laz's Interactive Map :: The Wrath... :: PvP Created");
                    windowed = true;
                }
            }

            // Press F12 : Toggle help menu
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::F12)) {
                if (help == false) {
                    help = true;
                }
                else {
                    help = false;
                }
            }

            enum State { State0, State1, State2, State3 };
            State myState = State0;


            // Press A : Add coords
            if (myState == State0 && (Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::A))
            {
                std::cout << "ONE" << std::endl;
                PressA = true;
                myState = State1;
            }
            if (myState == State1 && (Event.Type == sf::Event::TextEntered))
            {
                std::cout << "TWO" << std::endl;
                // Handle ASCII characters only
                if (Event.Text.Unicode > 47 && Event.Text.Unicode < 58)
                {
                    std::cout << "THREE" << std::endl;
                    XCoord += static_cast<int>(Event.Text.Unicode);
                    text.SetText(XCoord);
                    myState = State2;
                }
                else {
                    text.SetText("");
                }
            }
        }



        float ElapsedTime = App.GetFrameTime();

        // Move the map around the screen
        float Offset = 2000.f * App.GetFrameTime();
        if (App.GetInput().IsKeyDown(sf::Key::Up))    View.Move( 0,      -Offset);
        if (App.GetInput().IsKeyDown(sf::Key::Down))  View.Move( 0,      Offset);
        if (App.GetInput().IsKeyDown(sf::Key::Left))  View.Move(-Offset,  0);
        if (App.GetInput().IsKeyDown(sf::Key::Right)) View.Move(Offset,  0);

        // Zoom and unzoom using + and - keys
        if (App.GetInput().IsKeyDown(sf::Key::Add))      View.Zoom(1.005f);
        if (App.GetInput().IsKeyDown(sf::Key::Subtract)) View.Zoom(0.994f);

        App.SetView(View);

            App.Clear();

            App.Draw(MapPh);
            App.Draw(PhMid);
            App.Draw(DrMid);

        // Reset to the default view to draw the interface
        App.SetView(App.GetDefaultView());

            App.Draw(TopLeft);

            if (help == true)
                App.Draw(Help);
            else
                App.Draw(Main);

            if (PressA == true)
                App.Draw(text);

            App.Draw(CopyRight);

            App.Display();
    }



    return 0;
}

144
Window / Getting Integer Input
« on: August 15, 2010, 02:24:31 pm »
Yes. I have it where it says "ONE" for the first if statement, "TWO" for the second one and "THREE" for the third one.

It never makes it past "ONE"

145
Window / Getting Integer Input
« on: August 15, 2010, 02:19:17 pm »
I did. In my EDIT on the last post I said:

Quote
EDIT: I added a cout statement into the if statement with static_cast and found out that the code never even enters that one. Why not?


So, now I'm stuck...

146
Window / Getting Integer Input
« on: August 15, 2010, 02:11:21 pm »
I do have a Draw and Display. I just didnt paste em.

Code: [Select]
bool PressA = false;
std::string XCoord;
sf::String text;


if (myState == s0 && (Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::A))
            {
                PressA = true;
                myState = s1;
            }
            if (myState == s1 && Event.Type == sf::Event::TextEntered)
            {
                // Handle ASCII characters only
                if (Event.Text.Unicode > 47 && Event.Text.Unicode < 58)
                {
                    XCoord += static_cast<int>(Event.Text.Unicode);
                    text.SetText(XCoord);
                    myState = s2;
                }
                else {
                    text.SetText("");
                }
            }


if (PressA == true)
   App.Draw(text);

App.Display();


EDIT: I added a cout statement into the if statement with static_cast and found out that the code never even enters that one. Why not?

147
Window / Getting Integer Input
« on: August 15, 2010, 02:05:51 pm »
Okay! Here's what I got. Only problem is. Nothing is displaying on the screen still.

Code: [Select]
           // Press A : Add coords
            if (myState == s0 && (Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::A))
            {
                PressA = true;
                myState = s1;
            }
            if (myState == s1 && Event.Type == sf::Event::TextEntered)
            {
                // Handle ASCII characters only
                if (Event.Text.Unicode > 47 && Event.Text.Unicode < 58)
                {
                    XCoord += static_cast<int>(Event.Text.Unicode);
                    text.SetText(XCoord);
                    myState = s2;
                }
                else {
                    text.SetText("");
                }
            }

148
Window / Getting Integer Input
« on: August 15, 2010, 01:58:49 pm »
OH!!! Hold on a second. :D

149
Window / Getting Integer Input
« on: August 15, 2010, 01:51:50 pm »
Well, I know how to write it, but I don't know how I would utilize it.

150
Window / Getting Integer Input
« on: August 15, 2010, 01:47:10 pm »
Okay. so I should leave the order alone?

How would I use enum for this? I can't see any good use for it...

Pages: 1 ... 8 9 [10] 11 12
anything