I just installed the SFML program on my computer, as i just started c++ programming and was redirected on this forum to use SFML instead of console applications.
The thing is, i'm at the website for the SFML reading up on some tutorials, and imo i cant really see a difference? i cant see that any tutorial is actually learning me to make something more valid that i could just use and learn via the console application? maybe im getting it wrong.
My question in short is = What is the difference on a console application and going the SFML way? im still using codeblocks as before, guess thats needed. so what on earth do i use that SFML for? :)
hope u can understand and hopefully take ur time to reply :)
You use SFML for graphical applications (including games). It also includes audio and network functionality.
However, that should be glaringly obvious, so I'm not sure what you're actually asking.
Right. SFML makes it easy to do things like draw images to the screen, play music, get realtime input from the keyboard, mouse, and gamepad devices, etc, etc. Stuff that is very useful when making games.
None of that can be accomplished with the standard C++ library. All the standard lib allows you to do is print and receive lines of text.
Hi again disch, again you clarified a bit :) so even though my c++ skills is extremely limited, all i know is loops, if /else, variables etc and a few functions, i should be able to make something work with the SFML using the tutorials provided on the website?
thanks for ur input athar :)
Sorry if im asking lots of questions, but i finally pulled myself together to really get into programming so i just wanna make sure i start out right :)
#include <SFML/Graphics.hpp>
int main()
{
// Create the main window
sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");
// Load a sprite to display
sf::Image Image;
if (!Image.LoadFromFile("whatever_image.png")) // <- save an image on your computer
return EXIT_FAILURE;
sf::Sprite Sprite(Image);
// Start the game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
// Clear screen
App.Clear();
// Draw the sprite
App.Draw(Sprite);
// Update the window
App.Display();
}
return EXIT_SUCCESS;
}
step 1: Get this compiling and running so you see the image
step 2: Make the image move around the screen (like have it move left until it hits the left side of the screen, then have it move right until it hits the right side... or just have it move one way and "wrap around" to the other side of the screen)
step 3: Make the image move around according to user input. So like if the user holds the up arrow, have it move up, etc.
If you can get through those 3 steps you can start to see how making a basic game will work.
I have a few minute break, so I'll just cut in here and answer that question.
Another thing that I'd say is required knowledge is how to use classes with member functions. Not how to create classes, - though that's inevitably useful ;] - just how to use them with the dot operator.
That's very quick to learn, though, so you should be fine. :)
Thanks for posting that code. When i try to run and compile it it displays errors saying "undefined reference to imp_blablabla"
As i said my knowledge is extremely basic, and when i read just the first tutorial on that homepage i dont really think im learning something. maybe im in over my head and should go back to my dummies book and console programs untill i get more ground covered on the c++ language?
maybe im in over my head and should go back to my dummies book and console programs untill i get more ground covered on the c++ language?
Getting it set up is definitely the hardest part. Once you get the program running you'll be over the biggest hurdle.
After that, you can play around with it and get the idea a lot faster. If you really do feel like you're in over your head still, then maybe go back to the console for a bit *shrug*
In any case, don't just abandon your book. Still read it and still try to learn the C++ language from it. But when it comes time to test the knowledge the book is teaching you, do it in game form instead of console program form. It's more fun when you apply what you've learned to a game instead of some useless program you'd never use.
Well i set it up enough to use that clock code in the tutorial, but maybe i need to dó some more linking or something in order to get Line of code u wrote disch working?
I ONLY followed that tutorial and didnt enable any further linking, As i wouldnt know what to enable. Just Cant seem to Make it run and compile that program... U sure i dont have to enable any further linking or something other than whats taught ón that tutorial with the clock?
Anywhoo, im writing This from my iPad in bed, so i wong be able to try before tommoroW again. Got a day off from work so ill be using quite a few hours ón hopefully doing some programming progress :) ill write a reply in This thread if i get that Line of code working :) if i dont, well u Will prolly hear from mé again.
Please note that the thoughts and time u put into helping newbies like mé is highly appriciated! I would be forever lost if i had no where go. Guess thats obvious :p
when i run it says "cannot find -l-lsfml-system"? what on earth does that mean? i have linked the SFML/include and SFML/lib in my Global compiler settings, i transfered the system.dll file in the project folder, and under "build options" i have linked -lsfml-system and -lfsml-graphics?