Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Searching for a good tutorial [SFML]


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 Shenzo   Members   -  Reputation: 107

Like
0Likes
Like

Posted 15 April 2014 - 04:34 AM

Hi everyone , i'm searching for a SFML 2.1 tutorial smile.png.
I searched a lot for a complete tutorial to create a 2D platformer with SFML (C++) but i don't find anything i find only some part like load a picture play a music etc ...  but nothing about collision or how a 2D game works :/


Edited by Shenzo, 15 April 2014 - 04:35 AM.


Sponsor:

#2 Álvaro   Crossbones+   -  Reputation: 13933

Like
4Likes
Like

Posted 15 April 2014 - 05:43 AM

Tutorials are a quick method to get you started with a language or a library. Putting together a platformer is probably too complex a project to cover in a tutorial.

There are still some good resources you can use. I would start by reading this guide to implementing 2D platformers. As you will see, you have a lot of decisions to make. You have to decide what "type" of platformer you want to make (as described in the guide), you need to come up with characters, you need to decide on the details of the gameplay (how fast will the player's character move, how quickly will it accelerate, how high will it jump, will it be able to have some control of the movement while it's in the air, etc.).

You should break down the task of building the 2D platformer into smaller steps. Here's one possible plan:
* Put a blue rectangle on top of a floor and allow the user to move it around using the arrow keys.
* Make a scrolling background, which you can control with the left and right arrow.
* Improve the scrolling background to have multiple layers at different distances, with transparency.
* Add some platforms to the scrolling demo.
* Get your blue rectangle to be able to jump onto the platforms.
* Play around with the camera.
* Add some enemies (red rectangles are fine).
* Implement collision detection and response.
* Replace the colored rectangles with animated characters.
* Add music and game noises.
* Think of a format to describe a level in and write code to read that format. You might be able to find a format for which other people have written editors. If not, you may have to roll your own, although you can start by writing the files "by hand" to get started.
* ...

These steps are challenges that should be fairly manageable. If you have no idea how to approach them, perhaps you need to learn a bit more programming before you can tackle your 2D platformer.

Good luck!

#3 foxcode   Members   -  Reputation: 251

Like
2Likes
Like

Posted 15 April 2014 - 05:46 AM

The sfml main website has pretty good documentation and even example code you can copy and compile to see how it works. http://www.sfml-dev.org/tutorials/2.1/

 

I will address 2D collision briefly but it is covered pretty well on gamedev along with everything else you could want to know about making a 2D game

 

The type of 2D collision you need depends on the style of your platformer, one of the easiest is a tile based world, like the original Mario.

 

To check collision between 2 tiles or rectangles for example, a rectangle that is the ground and another that is the player, you can do something like this. This is code I have wrote just now as a guide, it only handles collision detection, it does not do anything based on that aka collision handling. 

struct Rect
{
  float x; //Position, top left corner x pos
  float y; //Position, top left corner y pos
  float w; //Width of rectangle
  float h; //Height of rectangle
};

static bool CheckCollision(Rect _one, Rect _two)
{
  //Check if rectangles overlap on x axis
  if(_one.x + _one.w < _two.x || //Check if rect one is to the left
     _one.x > _two.x + _two.w    //Check if rect one is to the right
  {
    return false; //No overlap on this axis, collision not possible
  }

  //Check if rectangles overlap on y axis
  if(_one.y + _one.h < _two.y || //Check if rect one is above
     _one.y > _two.y + _two.h    //Check if rect one is below
  {
    return false; //No overlap on this axis, collision not possible
  }

  return true; //Both axis have overlap, collision must have occurred

  
}

Hope this helps, gl



#4 BeerNutts   Crossbones+   -  Reputation: 3018

Like
0Likes
Like

Posted 15 April 2014 - 10:44 AM

My Old Blog (in my signature) details making an SFML game using a 2d physics library to handle all movement and collision detection/responses.  You can take a look at it for some ideas.


My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

#5 Shenzo   Members   -  Reputation: 107

Like
0Likes
Like

Posted 16 April 2014 - 07:21 AM

Oh thank's everyone for the help ! smile.png

Btw , i didn't understand this part sir.Alvaro
 

* Improve the scrolling background to have multiple layers at different distances, with transparency.

 


Edited by Shenzo, 16 April 2014 - 07:25 AM.


#6 BitMaster   Crossbones+   -  Reputation: 4436

Like
3Likes
Like

Posted 16 April 2014 - 07:40 AM

He is simply describing parallax scrolling.

#7 Shenzo   Members   -  Reputation: 107

Like
0Likes
Like

Posted 16 April 2014 - 09:21 AM

Oh i see , thank's sir smile.png


Edited by Shenzo, 16 April 2014 - 09:21 AM.


#8 Satharis   Members   -  Reputation: 1268

Like
1Likes
Like

Posted 16 April 2014 - 01:05 PM

Keep in mind a game is a sum of its parts and each tends to be its own field of experience you need to learn. Part of that is the main reason people say to start with something like a very simple Pong clone and then move to more advanced games, you get a basic game working and then you start layering on more complex things. Even making a GUI of any distinction will take quite a lot of reading and practice to really understand.

 

There isn't really any books or tutorials out there on making an entire game, at the very least they usually just describe ways to create certain parts of the game, which you should take advantage of.






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