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

Pages: [1]
1
Graphics / I have absolutely no idea why this isn't working
« on: September 06, 2011, 06:08:18 pm »
Thanks everyone, I got it to work...but I'm sure I'll be posting in this forum a lot over the course of this project ^_^

2
Graphics / I have absolutely no idea why this isn't working
« on: September 06, 2011, 05:45:37 am »
I have this code:

Code: [Select]
#include <SFML/Graphics.hpp>

int main(){
    sf::RenderWindow App(sf::VideoMode(1024, 768), "Game");
App.UseVerticalSync(true);
   
    //Loads the game font and images
    sf::Font GameFont;
    if (!GameFont.LoadFromFile("calist.ttf")) {
        return EXIT_FAILURE;
    }
    sf::Image TextBoxImage;
    sf::Sprite TextBox;
    if (!TextBoxImage.LoadFromFile("Blue.png")) {
        return EXIT_FAILURE;
    }
    TextBox.SetImage(TextBoxImage);
    TextBox.SetColor(sf::Color(0, 0, 255, 155));
    TextBox.SetPosition(0, 490.f);
    TextBox.Scale(1.6f, 1.6f);
    const sf::Input& Input = App.GetInput();
    bool DrawText = false;
    bool Next = Input.IsKeyDown(sf::Key::Return);
   
    //Loads the game Text
    sf::String dia1a ("That piece of trash over there is Joey.", GameFont);
   
    //Game Loop
    while (App.IsOpened())
    {
        App.Clear();
        App.Draw(TextBox);
        App.Display();
    //Dialogue for level 1
sf::Event Dialogue1;
        while (App.GetEvent(Dialogue1)) {
            if (Next = true){
                DrawText = true;
            }
            if ((DrawText = true)) {
                App.Draw(dia1a);
                App.Display();
        }
    }
    //Close Game    
        sf::Event GameClose;
        while (App.GetEvent(GameClose)) {
            if (GameClose.Type == sf::Event::Closed)
                App.Close();
            }
        }
    return EXIT_SUCCESS;
}


Which is supposed to display a line of text when I hit enter. The text should also stay on the screen because of DrawText. However, whenever I hit any key, or move the mouse at all, the text flickers for a while and then stops whenever I stop doing what I'm doing. If someone could please help me that would be much appreciated.

3
Graphics / Two questions.
« on: September 05, 2011, 09:00:44 pm »
I have this now, but whenever I run it the game crashes.

Code: [Select]
#include <SFML/Graphics.hpp>

int main(){
    sf::RenderWindow App(sf::VideoMode(1024, 768), "Game");

    //Loads the game font and images
    sf::Font GameFont;
    if (!GameFont.LoadFromFile("calist.ttf")) {
        return EXIT_FAILURE;
    }
    sf::Image TextBoxImage;
    sf::Sprite TextBox;
    if (!TextBoxImage.LoadFromFile("Blue.png")) {
        return EXIT_FAILURE;
    }
    TextBox.SetImage(TextBoxImage);
    TextBox.SetColor(sf::Color(0, 0, 255, 155));
    TextBox.SetPosition(0, 490.f);
    TextBox.Scale(1.6f, 1.6f);
   
    //Loads the game Text
    sf::String dia1a ("That piece of trash over there is Joey.", GameFont);
   
    //Game Loop
    while (App.IsOpened())
    {
        App.Clear();
        App.Draw(TextBox);
bool DrawText;
    //Dialogue for level 1
        if (DrawText) {
            App.Draw(dia1a);
App.Display();
}
        sf::Event Dialogue1;
        while (App.GetEvent(Dialogue1)) {
            if ((Dialogue1.Type == sf::Event::KeyPressed) && (Dialogue1.Key.Code == sf::Key::Escape)) {
                DrawText = true;
            }
        }
    //Close Game    
        sf::Event GameClose;
        while (App.GetEvent(GameClose)) {
            if (GameClose.Type == sf::Event::Closed)
                App.Close();
            }
        }
    return EXIT_SUCCESS;
}

4
Graphics / Two questions.
« on: September 05, 2011, 08:21:51 pm »
I'm trying to make a game in C++ similar to a visual novel, but I seem to be having a lot of trouble (this is my first game). I'm trying to make it so that whenever you hit enter a new sentence pops up. But whenever I hit enter, both pieces of text just flicker in front of each other. I also have a blue box that loads at the bottom of the screen. I've changed the text multiple times, and deleted the other string, but now the text won't load at all.

My other problem is that I think that if I keep developing the way I am, the whole game might just in the main.cpp file. I can't figure out a way to have the same objects over multiple files and because of that, all the text has to be written in the main file, so it can be displayed with App.Draw()

Code: [Select]
#include <SFML/Graphics.hpp>

int main(){
    sf::RenderWindow App(sf::VideoMode(1024, 768), "Game");

    //Loads the game font and images
    sf::Font GameFont;
    if (!GameFont.LoadFromFile("calist.ttf")) {
        return EXIT_FAILURE;
    }
    sf::Image TextBoxImage;
    sf::Sprite TextBox;
    if (!TextBoxImage.LoadFromFile("Blue.png")) {
        return EXIT_FAILURE;
    }
    TextBox.SetImage(TextBoxImage);
    TextBox.SetColor(sf::Color(0, 0, 255, 155));
    TextBox.SetPosition(0, 490.f);
    TextBox.Scale(1.6f, 1.6f);
   
    //Loads the game Text
    sf::String dia1a ("That piece of trash over there is Joey.", GameFont);
   
    //Game Loop
    while (App.IsOpened())
    {
        App.Clear();
        App.Draw(TextBox);
        App.Display();
    //Dialogue for level 1
        sf::Event Dialogue1;
        while (App.GetEvent(Dialogue1)) {
            if ((Dialogue1.Type == sf::Event::KeyPressed) && (Dialogue1.Key.Code == sf::Key::Escape)) {
                App.Draw(dia1a);
            }
        }
       
    //Close Game    
        sf::Event GameClose;
        while (App.GetEvent(GameClose)) {
            if (GameClose.Type == sf::Event::Closed)
                App.Close();
            }
        }
    return EXIT_SUCCESS;
}


If anyone knows any solutions to displaying new text when the enter key is pressed, or using objects over multiple header files, please let me know. ^_^

Pages: [1]