Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Hey I've learned C++ and SFML, but I can't find a book or tutorial


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 turquoiseptato   Members   -  Reputation: 128

Like
0Likes
Like

Posted 12 March 2013 - 07:11 PM

Okay I've beedn doing some c++ for some time ago, so now I don't really got problem for c++. Then I have learned SFML! Then I wanted to learn some stuff like tile-mapping all the collison stuff or sprite animation...

 

But then I discovored something there's no book using SFML or only a tiny amount of tutorial on this topic which use SFML.

 

I'm basically a noob,...I'm 16 year old.

 

So does anyone know where I can learn all those thing?



Sponsor:

#2 Dragonsoulj   Crossbones+   -  Reputation: 1011

Like
1Likes
Like

Posted 12 March 2013 - 07:32 PM

If you don't have a problem with C++, you should be okay using SFML.

 

For your concerns:

To display everything, you should create a window you can draw on. Look at the tutorial for creating an sf::RenderWindow.

 

To draw your tiles (the tile-mapping you mentioned), load each of your tile images (or your entire tile sheet if that was the way you wanted to go) as an sf::Image (if you use the tile sheet option -- think sprite sheet -- then you will have one sf::Image, but if you load each one individually, you will have several sf::Images). Then for each tile you need to draw, create an sf::Sprite that has the position on the screen you want. You can use your sf::Images multiple times without having to load an image for each square/tile.

 

For collision detection, you can do a number of options. You can keep track of the positions on your own and compare them against boundaries, for instance a "player" colliding with a wall or the edge of the screen you compare the player's position with the edge or the wall's position and if they are touching or the "player" would move past the boundary if the "player" was moved, you simply do not move the "player". A second option is using the sf::Sprite's position and using the sf::Rect's Contains function to see if the "player's" sf::Sprite would be contained within whatever boundary/object/other sf::Sprite the "player" is being tested against. If the Contains function returns true then you have a collision and should not move the "player".

* Substitute player with whatever element you want, such as a bullet, a character the player controls, an enemy, etc.

 

Also, look up collision detection on its own. This is not something particular to SFML, or even C++. There are various methods of detecting collision.

 

If you have any questions, particularly where you get stuck, let me know. I believe the user "serapth" on this forum has a tutorial for making a game with C++ and SFML if you wish to look up his profile. The link should be in his signature. I know the SFML site gives you a basic tutorial to get started (and I do mean basic), and lists the functions that are available.

 

EDIT: Forgot to mention with sprite animation you can just reassign the sf::Image that the sf::Sprite uses at a specific interval. SFML has timers that I use to see when a new frame needs to be drawn. At the interval I want, I can swap the image and redraw the sprite/screen. If I keep switching images and redrawing, I have an animation.


Edited by Dragonsoulj, 12 March 2013 - 09:05 PM.


#3 Serapth   Members   -  Reputation: 3283

Like
6Likes
Like

Posted 12 March 2013 - 08:31 PM

Give the tutorial in my sig a shot, it covers creating a full game using SFML.  It assumes prior C++ experience, so you should be good to go.



#4 Khaiy   Members   -  Reputation: 821

Like
1Likes
Like

Posted 12 March 2013 - 08:37 PM

Dragonsoulj's information is good, but I would expand it slightly to suggest that you look up all of the things you want to learn (tile mapping, collision detection, animation, etc.) individually. The more specific your combination of tools is, the less likely it is that there will be detailed tutorials, including books, that do everything you want with exactly the tools you've chosen.

 

Also bear in mind that SFML exists to do things like handle input and push pixels to the screen. It does not exist to do things like tile mapping and animation. Those types of capabilities are mostly independent of the things SFML does for you, and once you've written a tile mapping system it's fairly trivial to have SFML blit the result to the screen. SFML function calls will be involved in your specific implementation of those features, but the concepts will be the same regardless of the API you use.

 

If you look around for information on tile mapping, collision detection, sprite animation, etc., in C++ and drop the SFML requirement you'll find tons and tons of helpful information.

 

EDIT: Serapth, I can't believe I forgot your tutorial series! I tried to upvote you, but the site wouldn't let me.


Edited by Khaiy, 12 March 2013 - 08:39 PM.


#5 Dragonsoulj   Crossbones+   -  Reputation: 1011

Like
0Likes
Like

Posted 12 March 2013 - 09:10 PM

EDIT: Serapth, I can't believe I forgot your tutorial series! I tried to upvote you, but the site wouldn't let me.

 

I didn't forget. tongue.png I did, however, spell his name wrong, which I fixed.

Khaiy is right. I wasn't trying to say SFML is needed for the topics turquoiseptato wanted to learn, just trying to explain it a bit in terms of using SFML.

 

I also fully agree with looking up the topics with just C++ and then applying what you find using C++ and SFML for the various inputs, screen draws, and the like.



#6 Serapth   Members   -  Reputation: 3283

Like
4Likes
Like

Posted 12 March 2013 - 09:34 PM

That's ultimately the catch...

 

As you get more specialized, the less likely you are to find a tutorial for what you want to do.  Frankly a lot of this is to do with the fact, once you get to such a point, you really shouldn't require a tutorial any more, instead you should be looking simply for reference materials/examples.

 

My tutorial isn't really all that much about SFML, it actually barely touches on the subject.  Instead its about how to structure a non-beginner game and just happens to use SFML.  Other than that, what you should be looking at is SFML documentation on how to actually implement certain features you may require ( blitting, sprites, tiles, etc... ), and at generalist tutorials about tile mapping, collision detection, etc...  At this point in time, those higher level concepts, it really shouldn't matter all that much what language they are written in.  For example, when I put together my math tutorials I actually wrote them all in JavaScript.  This is because most developers should rather easily be able to grok JavaScript code and adapt it to their language of choice... plus of course, getting C++ or C# code to run in the browser is a bit of a trick. ;)

 

 

So as others have said, don't look for such a specific tutorial, you generally wont find it.  Instead, learn the basics, then focus on the design, not the implementation, then your knowledge starts to transcend the language or library you work in.

 

 

As you are at this profession longer and longer, you will find first language, then libraries, become less and less of a commitment as time goes on.  You will be able to move between them with relative ease, and as such, gain knowledge from a wide variety of sources.



#7 turquoiseptato   Members   -  Reputation: 128

Like
0Likes
Like

Posted 13 March 2013 - 01:26 PM

Well Thank you everyone! I might go well with this! I'm gonna take a look to this tutorial and scratch on a sheet of paper many ways to do collision or whatever until I found one which make sens!



#8 Dragonsoulj   Crossbones+   -  Reputation: 1011

Like
0Likes
Like

Posted 13 March 2013 - 06:06 PM

Collision detection in an image:

 

Gui_example_1_dot_1.png

 

Since you are doing tiles, this may be the easiest/fastest option.


Edited by Dragonsoulj, 13 March 2013 - 06:07 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS