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

Author Topic: General SFML help?  (Read 5462 times)

0 Members and 1 Guest are viewing this topic.

Eamonn

  • Newbie
  • *
  • Posts: 7
  • I love programming :)
    • View Profile
    • Email
General SFML help?
« on: July 14, 2013, 10:25:47 pm »
Ok, so the C++ language for me isn't my favourite, but I want to use it. Why? To prove to myself that I use it. I like making games in Java, yet I use Lua from time to time. SFML seems like the way to go for game development in C++. I want to make a 2D side-scroller game, but there are loads of things I don't understand about SFML, I don't understand how I'm going to learn it, I feel I should brush up on my C++ a little, I don't know what topics I need to know and don't need to know, etc etc.

Like I said, I want to make a 2D side-scroller. Before making a side scroller, I want to port my Lua game Mr. BallGuy into C++/SFML. It was my first game.

I don't know how I'm going to go about learning SFML. CodingMadeEasy's tutorials were great.. up until it came to loading an image. Then Xcode refused to load an image. It kept saying it couldn't find it, when I directly specified the path(img/characterSprite.png). Is it looking in some other folder by default? I have the img folder in the same folder as the main.cpp file. I'll have the project at the bottom of the thread.

So that's one of my problems. My second one is how will I make the sidescroller? I've never made one before. How will I handle collisions and stuff?

Having Mr. BallGuy as my highest level of game that I can achieve, should I still use SFML?

SFML is great on it's own, and I plan on using the Thor library for spritesheet animation.

I also plan on using the SFGUI library in some upcoming projects(like the platformer).

On the subject of making a platformer/side-scroller, could I load in a Tiled map? How does that work? Is there a guide on it?

The only things I don't really understand in C++ are:

• Polymorphism(only understand virtual functions)
• String Methods(I haven't memorised them)

Is Polymorphism important in game development? Could I maybe find a quick simple guide to it if it is?

I'm coming from LibGDX(which I hate because of the fonts), so do I need to use .fnt font files or can I use .ttf fonts just fine?

In games, you'd want achievements. Who wouldn't want achievements, am I right? So, is there an achievement extension for SFML, or would I have to write one myself?

Again, I'm not the strongest game developer, but we all have to start somewhere, right?? Right...?? I mean, Notch didn't just start Minecraft when he was still a beginner in Java. He had to build up his knowledge, then he made minecraft... maybe...  :-[

If you can't tell, I look up to Minecraft as a game I want to make a similar version of. Not for release, but just to see what I'm capable of.

Download Project: https://www.dropbox.com/s/a1deq81z91dn7mr/Tutorial.zip
Stuff.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: General SFML help?
« Reply #1 on: July 14, 2013, 10:37:41 pm »
Believe me you don't actually know much about C++. It sounds hard, but once you see the true power and with that its complexity, you'll notice that there's much more to it. Maybe it's not C++ itself as a programming language but rather the general ideas behind it.

So from ehat you've written you simply need more experience, you need to start thinking in "logical programming terms". That way you can start to understand what you actually need, what functionalities a certain library can provide and what should be left for you to write, to actually get "your" game.

Since I believe more in reading books than watching some videos filled with misinformation, I suggest to take a look at some good C++ books and afterwards it'd be worth reading the first and only book on SFML.

Of course you can just jump into programming, but this might be rather demotivating and you'll learn alot of wrong things before finding the "good ways". ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Eamonn

  • Newbie
  • *
  • Posts: 7
  • I love programming :)
    • View Profile
    • Email
Re: General SFML help?
« Reply #2 on: July 14, 2013, 10:44:53 pm »
Thanks for the advice! I finished watching TheNewBoston and CodingMadeEasy's videos, and thats all the C++ I know. My friend bought a few C++ books, and I read a few of them. They covered all the same stuff those videos did. I can't remember the names of them, but one was called "C++ from Scratch". Also, I don't want to sound rude, but I never claimed I knew a lot of C++. I said I didn't really like it, and I never really use it. It's not a simplistic language like a lot of the other languages I've used(Python, Ruby, Lua, Java, C, etc). Also, what do you mean "Filled with misinformation"? Do you think video tutorials are wrong?
Stuff.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: General SFML help?
« Reply #3 on: July 14, 2013, 10:56:55 pm »
Do not watch Youtube videos. The ones from CodingMadeEasy contain sometimes really questionable and ancient C++ style; if you are a newcomer to the language, they will do more harm than good. The problem is, most Youtube tutorials concerning programming are written by people with a lot of time, but not necessarily with a lot of experience. Many think they do something good for the community (and their intent is very noble!), but as hard as it sounds, in the end people get used to a lot of bad habits that are difficult to get rid of.

In C++, the only option is really to take a good book (a lot of literature is not recommended, either) and to invest the time to read it thoroughly. As you have recognized, C++ is very complex -- even when you're an expert in other languages, it will be difficult to learn it.

But if you are not interested in C++, it is probably not worth the effort to learn it. It will take months until you know the basics, and then you still have to learn all the idioms, best practices and different paradigms to be able to program efficiently. Only do it if you really feel motivated, otherwise you can use an SFML binding for a different language.
« Last Edit: July 14, 2013, 10:59:21 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: General SFML help?
« Reply #4 on: July 14, 2013, 11:01:44 pm »
I recommend C++ Primer 4th Edition if no one has suggested it already. But also like to note there are several good bindings to SFML in the languages you feel comfortable. For instance Java. But I still would like to see you continue with C++ and learn it. Knowledge is never a bad thing and it is handy to have in your toolbox. That would also put you in a position so you can clearly see the advantages of the different languages, as well their weaknesses.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

cpolymeris

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
    • Email
Re: General SFML help?
« Reply #5 on: July 15, 2013, 03:57:35 am »
Ok, so the C++ language for me isn't my favourite, but I want to use it. Why? To prove to myself that I use it. I like making games in Java, yet I use Lua from time to time.
I made the opposite development... started with Pascal, C & C++ and only later learned higher-level, garbage-collected, and scripted languages, so I probably have somewhat of a bias towards the former, but I do think knowing C or C++ makes you a better programmer even if you end up coding only, say, Java, because it teaches you about memory managment, pointers and data structures. And, who knows? It might become your favorite language.
Then again, learning C++ is a serious endeavor. I spent about 5 years almost only writing C++, and,  specially now that c++11 was released, couldn't say this about myself:
Quote
The only things I don't really understand in C++ are:
So, yeah, if you decide to go the C++ way, best of luck, but if your priority is to have a game soon, I'd stick to the languages you already know.

Quote
Having Mr. BallGuy as my highest level of game that I can achieve, should I still use SFML?
Sure! I have dabbled in Löve before, and, except for the obvious language difference, it's not *that* different in scope and breadth to SFML.  If you can handle that library, you should, I think, have no problem with this one.

Quote
In games, you'd want achievements. Who wouldn't want achievements, am I right? So, is there an achievement extension for SFML[...]?
Not that I know of. What does such an extension do, anyways? Is it about talking to a centralized server that keeps track of players and their achievements?
« Last Edit: July 15, 2013, 03:59:06 am by cpolymeris »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: General SFML help?
« Reply #6 on: July 15, 2013, 11:30:21 am »
So now that I'm on my PC rather than on my phone, I think I can add some more information and answers! :D

there are loads of things I don't understand about SFML, I don't understand how I'm going to learn it
SFML is a library with just a few functionality for Graphics, Audio, Window Creation, Networking and a some Thread support (see here), it won't answer many of your question, since those are more related to general programming or the programming language.

I feel I should brush up on my C++ a little, I don't know what topics I need to know and don't need to know, etc etc.
Yes! Here's a link to a list of the best recommended books.

Like I said, I want to make a 2D side-scroller. Before making a side scroller, I want to port my Lua game Mr. BallGuy into C++/SFML. It was my first game.
Looks nice, although the .exe doesn't work on my Windows 8 machine and when I start the .love file, I can't collect coins for some reason. But it's definitely something you could try to port over to SFML!
It reminds me quite a bit of Falling Rocks.

Then Xcode refused to load an image. It kept saying it couldn't find it, when I directly specified the path(img/characterSprite.png). Is it looking in some other folder by default? I have the img folder in the same folder as the main.cpp file. I'll have the project at the bottom of the thread.
I don't really know Xcode, but what you could do is changing the working directory at runtime. So before you load anything or try to access any file with a relative path you reset the working directory to the path of you application, so you can be sure where to look from there (see a possible example).

So that's one of my problems. My second one is how will I make the sidescroller? I've never made one before. How will I handle collisions and stuff?
That's basically asking "how to program a game?". Nobody can really answer you that question, since programming isn't a mathematical formula that can be applied to anything in a general fashion.
At best you start somewhere and then move on piece for piece until the "puzzle" starts to for a certain image.

Having Mr. BallGuy as my highest level of game that I can achieve, should I still use SFML?
Definitely! If you manage to port it to SFML, you'll have acquired quite a bit of knowledge, which will help you develop on other projects or improve up on Mr. BallGuy.

SFML is great on it's own, and I plan on using the Thor library for spritesheet animation.

I also plan on using the SFGUI library in some upcoming projects(like the platformer).
It's definitely good to keep an eye out on other useful libraries, it will make your life much easier when you can reuse some code, rather than inventing the whole wheels again.

On the subject of making a platformer/side-scroller, could I load in a Tiled map? How does that work? Is there a guide on it?
If you actually mean Tiled map, then you're lucky enough that some people have already written some loading code for SFML.
Tile maps on the other hand are something rather generic and is widely used for platformers and side-scrollers. But since it's generic there are so many ways to do it. I guess you first want to actually look at what they are and then search a bit around, there are many guides on tile maps, even on the wiki section of SFML. ;)

Is Polymorphism important in game development? Could I maybe find a quick simple guide to it if it is?
It's an important part of C++, thus it's also important for game development with C++, but it's also often used wrongly/not in a modern way.
Instead of some quick and simple guide I'd suggest to take a good look at it in a good C++ book. ;)

I'm coming from LibGDX(which I hate because of the fonts), so do I need to use .fnt font files or can I use .ttf fonts just fine?
SFML uses FreeType, which can handle TrueTypeFonts (ttf) just fine.
sf::Font font;
font.loadFromFile("assets/font/DejaVuSans.ttf");

In games, you'd want achievements. Who wouldn't want achievements, am I right? So, is there an achievement extension for SFML, or would I have to write one myself?
Not really. Personally I don't like achievements, but maybe it's just me that doesn't find it rewarding to get some text pop open every now and then and you know achievements are only there to keep player playing the game. Maybe an advanced highscore list would be nicer, where it doesn't only take into account how many points you collected, but keeps different stats separated.
Anyways this is something very game specific and nothing general about multimedia, thus it's not something that would come with SFML. ;)

Again, I'm not the strongest game developer, but we all have to start somewhere, right?? Right...??
Yes! :)

I mean, Notch...
Sorry you lost me there. :P
Notch is just another person and he was quite lucky to have hit the right people with the right type of game, thus kind of setting of a new era of sandbox games. But it's really sad to see, that people now can only think of Minecraft whenever someone else releases a sandbox game. Also don't forget, Minecraft was/is coded horrible. If it takes weeks or month to implement a very basic feature, then there's something seriously wrong with the codebase and Java...

Weeee long wall of text! :D
Btw I strongly suggest to change your background/text color on your blog. :o
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/