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.


Topics - buggy123

Pages: [1]
1
Graphics / text wrapping?
« on: December 22, 2009, 05:13:34 am »
How do you get a long string of text to display inside a "box" using the sf::String? I want it to make a new line whenever it runs out of room for the next word so it doesn't go out of the "box"

Is there a simple way to do this?

2
General / [Solved] question
« on: December 16, 2009, 06:11:01 am »
I'm getting this error

error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const sf::Input' (or there is no acceptable conversion)
        C:\Documents and Settings\SFML-1.5\include\SFML/Window/Input.hpp(129): could be 'sf::Input &sf::Input::operator =(const sf::Input &)'
        while trying to match the argument list '(const sf::Input, const sf::Input)'

while trying to run this line

Code: [Select]
Input.user_input = Game.App.GetInput();

Here's my class and constructor

Code: [Select]
class CInput
{
public:

const sf::Input& user_input;


CInput(sf::RenderWindow &app) : user_input(app.GetInput())
{
};
};


what's going wrong here

3
General / framerate
« on: December 05, 2009, 05:32:05 am »
just wondering how SFML calculated frame rate? how does it know when one frame passed?

4
Graphics / 2d animation?
« on: November 29, 2009, 04:10:42 am »
How is 2d animation (playing a sequence of sprites in a set time frame) done is SFML?

5
General / sf::string
« on: November 19, 2009, 07:32:42 am »
I'm trying to make "selectable text" meaning that when the mouse hovers over the words, it gets highlighted and stuff. However, the text is changing in length. How do I do this?

Is a way to figure out how much pixels each letter is or something?

6
General / Why?
« on: August 30, 2009, 11:55:32 pm »
So, I'm trying to draw a menu screen. Here's the header file and the main.cpp:

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


//declarations
#define MENU 1
#define GAME 2
#define END 3

int game_state = MENU;

sf::RenderWindow App(sf::VideoMode::GetMode(1), "SFML Window");

// GRAPHICS

int load_graphics_menu(void)
{

//menu background

sf::Image menu_background;
if (!menu_background.LoadFromFile("data/art/menu/menu_background.bmp"))
{
MessageBox(NULL,
  "Fail to load image from file",
  "Error",
  NULL);

return -1;
} //Load image

sf::Sprite spt_menu_background;
spt_menu_background.SetImage(menu_background);

//menu play button

sf::Image menu_playbutton;
if (!menu_playbutton.LoadFromFile("data/art/menu/menu_playbutton.bmp"))
{
MessageBox(NULL,
  "Fail to load image from file",
  "Error",
  NULL);

return -1;
} //Load image

sf::Sprite spt_menu_playbutton;
spt_menu_playbutton.SetImage(menu_playbutton);
spt_menu_playbutton.SetPosition(475.f, 235.f);

//menu play button highlighted

sf::Image menu_playbutton_hl;
if (!menu_playbutton_hl.LoadFromFile("data/art/menu/menu_playbutton_hl.bmp"))
{
MessageBox(NULL,
  "Fail to load image from file",
  "Error",
  NULL);

return -1;
} //Load image

sf::Sprite spt_menu_playbutton_hl;
spt_menu_playbutton_hl.SetImage(menu_playbutton_hl);
spt_menu_playbutton_hl.SetPosition(475.f, 235.f);

//menu instruction button

sf::Image menu_instructionbutton;
if (!menu_instructionbutton.LoadFromFile("data/art/menu/menu_instructionbutton.bmp"))
{
MessageBox(NULL,
  "Fail to load image from file",
  "Error",
  NULL);

return -1;
} //Load image

sf::Sprite spt_menu_instructionbutton;
spt_menu_instructionbutton.SetImage(menu_instructionbutton);
spt_menu_instructionbutton.SetPosition(426.f, 324.f);

//menu instruction button highlighted

sf::Image menu_instructionbutton_hl;
if (!menu_instructionbutton_hl.LoadFromFile("data/art/menu/menu_instructionbutton_hl.bmp"))
{
MessageBox(NULL,
  "Fail to load image from file",
  "Error",
  NULL);

return -1;
} //Load image

sf::Sprite spt_menu_instructionbutton_hl;
spt_menu_instructionbutton_hl.SetImage(menu_instructionbutton_hl);
spt_menu_instructionbutton_hl.SetPosition(426.f, 324.f);
//menu exit button

sf::Image menu_exitbutton;
if (!menu_exitbutton.LoadFromFile("data/art/menu/menu_exitbutton.bmp"))
{
MessageBox(NULL,
  "Fail to load image from file",
  "Error",
  NULL);

return -1;
} //Load image

sf::Sprite spt_menu_exitbutton;
spt_menu_exitbutton.SetImage(menu_exitbutton);
spt_menu_exitbutton.SetPosition(12.f, 580.f);

//menu exit button highlighted

sf::Image menu_exitbutton_hl;
if (!menu_exitbutton_hl.LoadFromFile("data/art/menu/menu_exitbutton_hl.bmp"))
{
MessageBox(NULL,
  "Fail to load image from file",
  "Error",
  NULL);

return -1;
} //Load image

sf::Sprite spt_menu_exitbutton_hl;
spt_menu_exitbutton_hl.SetImage(menu_exitbutton_hl);
spt_menu_exitbutton_hl.SetPosition(12.f, 580.f);

return 0;
}

//INPUT

int process_input_menu(void)
 
{
sf::Event Event;
    while (App.GetEvent(Event))
    {
        // Window closed
        if (Event.Type == sf::Event::Closed)
            App.Close();

        // Escape key pressed
        if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
            App.Close();
    }
}


main.cpp

Code: [Select]
#include "UltrapingMenu.h"

int main()
{
sf::RenderWindow App(sf::VideoMode::GetMode(1), "SFML Window");

App.Create(sf::VideoMode(1024, 768, 32), "Ultraping", sf::Style::Fullscreen); //Windows creation...somehow, (1) works, (0) doesn't

load_graphics_menu();

while (App.IsOpened() && game_state == MENU)
{
process_input_menu();

App.Clear();

App.Draw(spt_menu_background);
App.Draw(spt_menu_playbutton);
App.Draw(spt_menu_instructionbutton);
App.Draw(spt_menu_exitbutton);

App.Display();
}

    return 0;
}


and here's the errors

Code: [Select]
Compiling...
main.cpp
.\main.cpp(17) : error C2065: 'spt_menu_background' : undeclared identifier
.\main.cpp(18) : error C2065: 'spt_menu_playbutton' : undeclared identifier
.\main.cpp(19) : error C2065: 'spt_menu_instructionbutton' : undeclared identifier
.\main.cpp(20) : error C2065: 'spt_menu_exitbutton' : undeclared identifier


it doesn't make any sense since I obviously declared these in my load_graphics_menu section...why do I keep getting this error?

Also, does anyone have any tips on optimizing my code? It's a bit cumbersome right now and I'm not sure how to do some things. for example, if I wanted to draw a seperate image the the mouse is hovering over the play button, how should I do that? I don't want to use pages of if and thens.

Pages: [1]