SFML community forums
General => General discussions => Topic started by: TheEnigmist 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
-
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 ;)
-
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:
#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();
}
}
-
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.
-
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:
// Destroy the device
if (audioDevice)
alcCloseDevice(audioDevice);
I don't know what can i do to fix.
The sc is:
#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?
-
Well, everything is in task #30, there's nothing else I can say ;)
-
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 ;)
-
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 :(