Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Build SFML 2.0  (Read 3490 times)

0 Members and 1 Guest are viewing this topic.

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Build SFML 2.0
« on: May 10, 2011, 08:44:59 pm »
I'm new on C++ world.
I want to build SFML 2.0 fot Visual Studio 2010 x86.
I downloaded Cmake, but i'm not able to make a folder with file like SFML 1.6 that you can download from the site.
So my question is:
Can you help me to buil everything from sfml 2.0 with cmake?
(everithing= include/lib/dll/examples ecc)
I don't understand how do it from the tutorial :( i'm really noob :( help me :D

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Build SFML 2.0
« Reply #1 on: May 10, 2011, 10:14:58 pm »
When you are completely new to C++, it is not a good idea to start with a framework like SFML. Even if SFML is rather easy to learn, it requires a lot of basic knowledge (like control structures, functions, types, variables, expressions). Don't make the mistake of underestimating C++ basics, it will always influence your code in a bad way if you don't learn them correctly ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Build SFML 2.0
« Reply #2 on: May 10, 2011, 10:38:24 pm »
Sorry sorry i've solved all my problem while i was writing xD... i've linked all extlibs in my little project and all went good now...
The problem was that i wasn't ble to load a sound from a file...
Btw i know C++ basic ;)
if you want to check if i'm getting good, this is the stupid program:
Code: [Select]

#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
int main()
{


//Creazione Finestra Applicazione
sf::RenderWindow Game(sf::VideoMode::GetDesktopMode(),"Game",sf::Style::Fullscreen);

//Creazione Rettangolo
sf::Shape box(sf::Shape::Rectangle(0, 0, 50, 50, sf::Color(127, 0, 0)));

//Posizionamento di 'box'
box.SetPosition(100, 100);

sf::SoundBuffer Buffer;
if (!Buffer.LoadFromFile("guitar_1.ogg"))
return EXIT_FAILURE;

// Create a sound instance and play it
sf::Sound Sound(Buffer);
Sound.Play();


//Buffer Immagine
sf::Image Image;
if (!Image.LoadFromFile("image.png"))
{
return EXIT_FAILURE;
}

//Set Image Mask
Image.CreateMaskFromColor(sf::Color(0, 255, 0, 255));

//Creazione Sprite
sf::Sprite Sprite;

//Set Sprite Image
Sprite.SetImage(Image);

//Set Sprite Position
Sprite.SetPosition(400,400);

//Game Loop
while (Game.IsOpened())
{

//Pulizia finestra
Game.Clear(sf::Color(1,158,241));

//Creazione Eventi
sf::Event Event;

//Eventi
while (Game.PollEvent(Event))
{
//Uscita dal gioco
if (Event.Type == sf::Event::Closed)
{
Game.Close();
}

//ESC per chiudere l'applicazione!
if (Game.GetInput().IsKeyDown(sf::Key::Escape))
{
Game.Close();
}


if (Game.GetInput().IsMouseButtonDown(sf::Mouse::Left))
{
if (Game.GetInput().IsKeyDown(sf::Key::A))
{
box.Move(-3,0);
}
else if (Game.GetInput().IsKeyDown(sf::Key::D))
{
box.Move(1,0);
}
}
else if (Game.GetInput().IsMouseButtonDown(sf::Mouse::Right))
{
if (Game.GetInput().IsKeyDown(sf::Key::A))
{
Sprite.Move(-1,0);
}
else if (Game.GetInput().IsKeyDown(sf::Key::D))
{
Sprite.Move(1,0);
}
}
}

//Movimenti
box.Move(0.1,0);

//Inserimento 'box'
Game.Draw(box);

//Inserimento 'sprite'
Game.Draw(Sprite);

//Mostrare la finestra
Game.Display();
}
}

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Build SFML 2.0
« Reply #3 on: May 10, 2011, 10:50:11 pm »
Ah okay, it sounded like you've never done anything with C++ :)

The code looks good so far. Next time, please describe the problem more precisely than "I don't understand the tutorial", then we can also give you concrete advice.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Build SFML 2.0
« Reply #4 on: May 10, 2011, 11:53:19 pm »
Ok... i write again here for a problem.
The program run well, but the debug mode show me a problem with AudioDevice. I got exactly this:
https://github.com/SFML/SFML/issues/30

The debugger of VS2010 send me here:
Code: [Select]
 
    // Destroy the device
    if (audioDevice)
        alcCloseDevice(audioDevice);


I don't know what can i do to fix.
The sc is:
Code: [Select]

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

using namespace std;

int main()
{


//Creazione Finestra Applicazione
sf::RenderWindow Game(sf::VideoMode::GetDesktopMode(),"Game",sf::Style::Fullscreen);

Game.SetFramerateLimit(60);

//Creazione Rettangolo
sf::Shape box(sf::Shape::Rectangle(0, 0, 50, 50, sf::Color(127, 0, 0)));

//Posizionamento di 'box'
box.SetPosition(100, 100);

sf::SoundBuffer Buffer;
if (!Buffer.LoadFromFile("guitar_1.ogg"))
return EXIT_FAILURE;

//Buffer Immagine
sf::Image Image;
if (!Image.LoadFromFile("image.png"))
{
return EXIT_FAILURE;
}

// Create a sound instance and play it
sf::Sound Sound(Buffer);
Sound.Play();


//Set Image Mask
Image.CreateMaskFromColor(sf::Color(0, 255, 0, 255));

//Creazione Sprite
sf::Sprite Sprite;

//Set Sprite Image
Sprite.SetImage(Image);

//Set Sprite Position
Sprite.SetPosition(400,400);

//Game Loop
while (Game.IsOpened())
{

//Pulizia finestra
Game.Clear(sf::Color(1,158,241));

//Creazione Eventi
sf::Event Event;

//Eventi
while (Game.PollEvent(Event))
{
//Uscita dal gioco
if (Event.Type == sf::Event::Closed)
{
Game.Close();
}

//ESC per chiudere l'applicazione!
if (Game.GetInput().IsKeyDown(sf::Key::Escape))
{

Sound.Stop();
Game.Close();
}


if (Game.GetInput().IsMouseButtonDown(sf::Mouse::Left))
{
if (Game.GetInput().IsKeyDown(sf::Key::A))
{
box.Move(-1,0);
}
else if (Game.GetInput().IsKeyDown(sf::Key::D))
{
box.Move(1,0);
}
}
else if (Game.GetInput().IsMouseButtonDown(sf::Mouse::Right))
{
if (Game.GetInput().IsKeyDown(sf::Key::A))
{
Sprite.Move(-1,0);
}
else if (Game.GetInput().IsKeyDown(sf::Key::D))
{
Sprite.Move(1,0);
}
}
}

//Movimenti
box.Move(1,0);

//Inserimento 'box'
Game.Draw(box);

//Inserimento 'sprite'
Game.Draw(Sprite);

//Mostrare la finestra
Game.Display();
}

system("pause");
return EXIT_SUCCESS;
}


The error appear after system("pause").
What is this?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Build SFML 2.0
« Reply #5 on: May 11, 2011, 07:44:35 am »
Well, everything is in task #30, there's nothing else I can say ;)
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Build SFML 2.0
« Reply #6 on: May 11, 2011, 07:48:44 am »
And please, next time don't mix unrelated problems in the same thread, and avoid duplicating your posts. A forum works best if a discussion is in its own thread in the right category ;)
Laurent Gomila - SFML developer

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Build SFML 2.0
« Reply #7 on: May 11, 2011, 01:34:09 pm »
Quote from: "Laurent"
And please, next time don't mix unrelated problems in the same thread, and avoid duplicating your posts. A forum works best if a discussion is in its own thread in the right category ;)

Yes i'm sorry :(