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

Author Topic: SFML Complete Game Tutorial  (Read 63678 times)

0 Members and 1 Guest are viewing this topic.

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
SFML Complete Game Tutorial
« Reply #30 on: October 24, 2011, 09:09:44 pm »
Ah, from your tutorial I just need the game framework. I'd like to write the engine myself, as I'm fairly good at maths. In my prior 2d racing project I had all the trigonometry and physics figured out. In fact, that is the most fun part of all, fiddling with the physical equations and then testing the effect it has on the car :D.

I don't know if you should teach maths in your tutorial. You don't teach general programming, do you? I like your tutorial, so far, because it's a missing ingredient of how to wrap SFML libs to make an organized game framework. But if you really wish to teach trigonometry, i think its not all that hard to comprehend. Seriously, what more needs to be said than this little infographic I made? :D



By the way, I managed to compile PySFML2 and I'm overwhelmed by the simplicity of Python. For example, project is not kept in a file, you just open a folder and all files inside that folder are treated as part of the project. I love the language itself. In most cases there is only one right way of doing stuff, which is cool beacause understanding the code  is easier that way. The syntax is clean. I downloaded a PySFML asteroids game called Multitroids and the code looks really nice, I think the structure is similar to yours. I only hope that Python won't be too slow for the game I'm planning to make.

Serapth

  • Full Member
  • ***
  • Posts: 105
    • View Profile
SFML Complete Game Tutorial
« Reply #31 on: October 27, 2011, 05:46:02 pm »
Ok, so I took my sweet time about it, but the next chapter is online.  The game ball is now animated and the game performs collisions and proper ricochets.  The chapter also discusses the topic of, and various types, of casts in C++.

Pang chapter 7


Or if you are just starting out, start at the table of contents.

I promise the next chapter will be significantly quicker to be released! In fact a good portion of it is already done.

ActionBoy

  • Newbie
  • *
  • Posts: 36
    • View Profile
SFML Complete Game Tutorial
« Reply #32 on: October 28, 2011, 08:58:34 pm »
A great tutorial. Wish I found something like this 10 years ago. Keep up the great work and good luck to everything you do.

Serapth

  • Full Member
  • ***
  • Posts: 105
    • View Profile
SFML Complete Game Tutorial
« Reply #33 on: October 31, 2011, 05:53:43 pm »
Oops, but of a bug crept in in PlayerPaddle, at the end change the "Bounce" test to :

Code: [Select]
if(pos.x  <= GetSprite().GetSize().x/2
|| pos.x >= (Game::SCREEN_WIDTH - GetSprite().GetSize().x/2))
{
_velocity = -_velocity; // Bounce by current velocity in opposite direction
}


It should have be <= and >=, otherwise on the condition of == 0, the paddle can get stuck to the wall.  Oops.[/code]

sec_goat

  • Newbie
  • *
  • Posts: 17
    • View Profile
I just wanted to say thank you.
« Reply #34 on: November 10, 2011, 08:29:50 pm »
This is an amazing tutorial that introduces the nuances of SFML as well as some really good (IMO) programming practices that I  have been trying to figure out for quite a while.

I am really learning a lot form this and have been looking for something like this for a long time. Can't wait for the next installments of this tutorial.

Jany

  • Newbie
  • *
  • Posts: 9
    • View Profile
SFML Complete Game Tutorial
« Reply #35 on: November 11, 2011, 11:01:01 am »
a really good tutorial! it helped me much to get into the SFML Library, and also i had fun reading and coding with it. =)

Waiting for Part 8 :)

Greetings Jany

Serapth

  • Full Member
  • ***
  • Posts: 105
    • View Profile
SFML Complete Game Tutorial
« Reply #36 on: November 11, 2011, 02:40:02 pm »
Thanks for the kind words, they are very much appreciated.

The next two chapters are very much in the works and should be released soon.  To be completely honest I am not really sure how well the next chapter will be taken, as it goes off slightly into unexplored territory, which is why I am releasing two chapters at once... don't like it, skip it! ;)

I would have been done a while ago, but I got a bit distracted by PlayN, shiny new toys are always a major distraction for me!  All said though, I should have them up in the next couple days.  I have to, my Skyrim order arrives today...  ooooh Shiny!

Serapth

  • Full Member
  • ***
  • Posts: 105
    • View Profile
SFML Complete Game Tutorial
« Reply #37 on: November 14, 2011, 09:39:14 pm »
Chapter 8 is now live and can be accessed here and the post summary is available here.


This chapter is a bit... different.  So far as I have ever seen, I have never really seen another game tutorial post like this one.  It covers using audio ( poorly ) and in fact shows how to use a library other than SFML ( sorry Laurent :) ) for audio, as an option anyways.  Most importantly, almost all of the code is absolute garbage.

Sound interesting? ;)


This chapter is more about design than code and if you are fairly new to programming in an OO style, I hope it is enlightening.

On the other hand, you may absoluely hate this chapter and want me to never go off track like this again.  Please read it and let me know which way you lean!


There is another post, one that shows how to more properly use SFML audio, so don't worry about that part.  It is nearly complete and should be live very shortly.

P@u1

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
SFML Complete Game Tutorial
« Reply #38 on: November 14, 2011, 11:13:29 pm »
I really like your tutorials.

In the last one I found a thing you should change:
Code: [Select]
#include <string.h>
should be
Code: [Select]
#include <string> instead.

If you include it with the .h it is not placed in the std:: namespace afaik.

Serapth

  • Full Member
  • ***
  • Posts: 105
    • View Profile
SFML Complete Game Tutorial
« Reply #39 on: November 15, 2011, 12:03:08 am »
Quote from: "P@u1"
I really like your tutorials.

In the last one I found a thing you should change:
Code: [Select]
#include <string.h>
should be
Code: [Select]
#include <string> instead.

If you include it with the .h it is not placed in the std:: namespace afaik.




You are right, it should have been <string>, more to the matter, it shouldn't even be there.  I think its merely left overs from some code I was messing about with or possibly a code completion mistake...  I am a bit haphazard with my includes...  

Either way, its been updated.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML Complete Game Tutorial
« Reply #40 on: November 15, 2011, 07:30:22 am »
Quote
If you include it with the .h it is not placed in the std:: namespace afaik.

The C++ equivalent of a C header <xxx.h> is <cxxx>. So here, the C++ equivalent would be <cstring>, which includes functions such as memcpy, strcmp, strlen, etc.
<string> is totally different, it defines the std::string class.
Laurent Gomila - SFML developer

P@u1

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
SFML Complete Game Tutorial
« Reply #41 on: November 15, 2011, 05:17:23 pm »
I know this, but in this case he wanted <string> and not <cstring>:
Code: [Select]

#pragma once

#include "stdafx.h"
#include <string.h>  //<----
#include "IAudioProvider.h"

class SFMLSoundProvider : public IAudioProvider
{
public:

  SFMLSoundProvider();

  void PlaySound(std::string filename);  //<----- here std::string is used
  void PlaySong(std::string filename, bool looping = false); //<----- here std::string is used
  ...
};


With <string.h> you probably get the completely wrong things (c-string utility function without std namespace, whereas you want std::string in std namespace), so you should #include <string>
It probably works anyway, because somewhere <string> is included, maybe even <string.h> includes it with msvc, although this would be quite strange.

Serapth

  • Full Member
  • ***
  • Posts: 105
    • View Profile
SFML Complete Game Tutorial
« Reply #42 on: January 01, 2012, 02:02:53 am »
Part 9 is now online


This part of the tutorial deals with playing sf::Music and sf::Sound objects using a (simple) caching system.  In addition it implements the AI paddle with some exceedingly stupid AI, although no collision detection.  Along the way it explores the C++ topics of exception handling and templates.



Next chapter we will be polishing things up a bit. fixing a flaw or two, adding a score board and will be much closer to a full game.  As always, any and all feedback appreciated.[/url]

Neomex

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
SFML Complete Game Tutorial
« Reply #43 on: January 01, 2012, 12:01:56 pm »
Really nice job! I like it alot! :)

Lee R

  • Jr. Member
  • **
  • Posts: 86
    • View Profile
SFML Complete Game Tutorial
« Reply #44 on: January 02, 2012, 12:47:27 am »
Quote from: "Serapth"
Part 9 is now online


I haven't looked at your code in any detail, but a quick look revealed at least four memory leaks. You're new'ing up exceptions (why?) but attempt to catch them by reference.

 

anything