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

Pages: [1]
1
Window / Odd trouble drawing text
« on: December 13, 2011, 12:33:53 am »
Alrighty, so I can get my "tart new journey" and "[C]ontinue your journey" messages to appear in the first function of my source just fine:
This works perfectly...
Code: [Select]
int main(/*commandline arguments go here*/){
  Game.Display();
  Game.Clear();
  Game.EnableKeyRepeat(false);
  if(!Image[0].LoadFromFile("gfx/frame.png")){
    std::cout<<"Failed to load image!"<<std::endl;
  }
  //Set the image as a sprite...
  Sprite[0].SetImage(Image[0]);
  mtFont.LoadFromFile("gfx/FreeMono.ttf",12);
  menu_text1.SetText("[S]tart new journey");
  menu_text2.SetText("[C]ontinue your journey");
  menu_text1.SetFont(mtFont);
  menu_text2.SetFont(mtFont);
  menu_text1.SetSize(16);
  menu_text2.SetSize(16);
  menu_text1.Move(412,280);
  menu_text2.Move(412,294);
  Game.Clear();
  Game.Draw(Sprite[0]);
  Game.Draw(menu_text1);
  Game.Draw(menu_text2);
  Game.Display();

...yet when my second function (character naming and general 'newgame' stuff) begins, it fails to print the name-request, even though it still responds to events with...:
Code: [Select]
int game_start(){
  Game.Display();
  if(!Image[0].LoadFromFile("gfx/frame.png")){
    std::cout<<"Failed to load image!"<<std::endl;
  }
  //Set the image as a sprite...
  Sprite[0].SetImage(Image[0]);
  mtFont.LoadFromFile("gfx/FreeMono.ttf",12);
  menu_text1.SetText("By what name shalt");
  menu_text2.SetText("thee be known?");
  menu_text1.SetFont(mtFont);
  menu_text2.SetFont(mtFont);
  menu_text1.SetSize(16);
  menu_text2.SetSize(16);
  menu_text1.Move(412,280);
  menu_text2.Move(412,294);
  Game.Clear();
  Game.Draw(Sprite[0]);
  Game.Draw(menu_text1);
  Game.Draw(menu_text2);
  Game.Display();

...and yes, the second function is called.  All I get in return is the blank 'frame' image also used in the first function.  What am I doing wrong?  I feel like a complete fool.  @_@;

EDIT:  Alrighty, so...  I changed MenuText1 and MenuText2 into a single array known as menu_text.  Setting the code to display this array has kept what already worked working, but curiously, the second function was only willing to display
  • and [1] in the first function, then [3] and [4] in the second.  It does, at least, display now, which is a vast improvement, but I'm thinking I may need to (somehow) clear the memory from menu_text
  • through [2] which were used by the first function (since I added an option to view credits, I had to use [2] as well, if you were confused).  Apparently, I can't reuse those menu_texts just yet... @_@;  I'm sure I'll find a fix for that soon enough!  :)

2
General / Undefined references (rendering a window)
« on: September 16, 2011, 03:32:01 am »
Thanks a ton!  I got it to compile in terminal (I really should try and set up the linkers in codeblocks, though, just for convenience's sake)  Next, I need to figure out how to disable window-resizing...  *gets back to searching*

I think I can handle things fine from here.  ^_^

3
General / Undefined references (rendering a window)
« on: September 16, 2011, 03:00:41 am »
Hi, I've just recently chosen to try out SFML with C++ and followed a video tutorial on Youtube to try and render a window (practice for a project I'm planning) and got the following errors:

Code: [Select]

/home/username/Documents/cppStuff/Window/SFML_Window.o||In function `main':|
SFML_Window.cpp|| undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
SFML_Window.cpp|| undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, sf::WindowSettings const&)'|
SFML_Window.cpp|| undefined reference to `sf::Window::Close()'|
SFML_Window.cpp|| undefined reference to `sf::Window::GetEvent(sf::Event&)'|
SFML_Window.cpp|| undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
SFML_Window.cpp|| undefined reference to `sf::RenderTarget::Clear(sf::Color const&)'|
SFML_Window.cpp|| undefined reference to `sf::Window::Display()'|
SFML_Window.cpp|| undefined reference to `sf::Window::IsOpened() const'|
SFML_Window.cpp|| undefined reference to `sf::RenderWindow::~RenderWindow()'|
SFML_Window.cpp|| undefined reference to `sf::RenderWindow::~RenderWindow()'|
SFML_Window.cpp|| undefined reference to `sf::RenderWindow::~RenderWindow()'|
||=== Build finished: 11 errors, 0 warnings ===|


I'm running Ubuntu 11.04 and have been using Gedit or Code::Blocks (depending on how much 'interface' I feel like tolerating).  Here is the code from the tutorial, which I used:

Code: [Select]

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

int main()
{
    sf::RenderWindow Game(sf::VideoMode(640, 480, 32), "SFML Test");

    sf::Event Event;

    while(Game.IsOpened())
    {
        while(Game.GetEvent(Event))
        {
            if(Event.Type == sf::Event::Closed)
                Game.Close();
        }

        Game.Clear();
        Game.Display();
    }
   
    return EXIT_SUCCESS;
}


I have no idea why these errors are happening (yes, I've installed sfml, and these errors happened in Code::Blocks, if I haven't already said so),
so I'm hoping someone here can tolerate the length of the post and lend a hand.  Any help is appreciated, this kind of thing is ridiculously annoying.  @_@;  Thanks![/code]

Pages: [1]
anything