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

Author Topic: SFML Pong. 24 hour project.  (Read 9271 times)

0 Members and 1 Guest are viewing this topic.

NinjaFishleg

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
SFML Pong. 24 hour project.
« on: March 15, 2014, 04:20:06 pm »
I made a SFML game in 24 hours.

https://www.dropbox.com/sh/s2d4ake0k1gmkbv/DvA1okI5V6
Here is dropbox folder in which there are 3 files:

main - The compiled code.
main.cpp - the source code(if you have to compile it yourself because you can't run main)
font.ttf

 What do you think?

Also I ahve just seen the duplicate. Sorry about that. :/

JuDelCo

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • JuDelCo's Twitter
Re: SFML Pong. 24 hour project.
« Reply #1 on: March 15, 2014, 04:29:46 pm »
The code is well organised but it's very "C" style, no classes or structs (being .cpp ... well...)

You can make a screenshot? :)

NinjaFishleg

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML Pong. 24 hour project.
« Reply #2 on: March 15, 2014, 06:19:48 pm »
]

Here is a screenshot. And yes I agree it is very C like, my origin is C and php. I struggle to get out the "style". :)

My next project will be Space Invaders or Snake.
« Last Edit: March 15, 2014, 06:29:36 pm by NinjaFishleg »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Pong. 24 hour project.
« Reply #3 on: March 15, 2014, 06:43:41 pm »
I recommend reading a good C++ book. The C style may work for simple games like Pong, but as soon as you make something bigger, the project will become hard to maintain and debug, and you'll waste a lot of time.

Better learn C++ from the beginning. Snake is a good opportunity to try out idiomatic and modern C++ ;)

Some keywords that you should definitely have a deep look at: Classes, OOP, STL, RAII.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

NinjaFishleg

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email

JuDelCo

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • JuDelCo's Twitter
Re: SFML Pong. 24 hour project.
« Reply #5 on: March 15, 2014, 07:30:52 pm »
I recommend this:

- http://www.cplusplus.com/doc/tutorial/
- Google
- A LOT of practice

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Pong. 24 hour project.
« Reply #6 on: March 15, 2014, 07:38:01 pm »
NinjaFishleg, is there a reason why you didn't choose a book from the recommended list? I don't know C++: A Beginner's Guide, but with C++ books you have to be very careful. Most of them are badly written and do more harm than good.

Also, from looking at the 1-star Amazon reviews*, it looks like that book has some serious problems, especially from this quote:
Quote
This book does not cover the basics of c++. The exemples often contain errors or memory leaks. Memory management doesn't seem to be a big concern for a big part of the book, though it might one of the tricky part of c/c++ you should learn as soon as you learn c++ basics, especially when more and more people learn programming without this concern.

Please do not underestimate the importance of having a good book, you won't learn C++ with a mediocre one. That's why I posted the link to the list of books with a widely agreed quality.

JuDelCo, it's illusory to learn C++ only from the Internet. Tutorial sites mostly don't cover important background knowledge, and practice alone doesn't help teach modern techniques and idioms.

_______
* With respect to C++, the worst reviews are the most interesting, because a lot of people don't even realize they've learned bad C++ and write good reviews.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

JuDelCo

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • JuDelCo's Twitter
Re: SFML Pong. 24 hour project.
« Reply #7 on: March 15, 2014, 07:45:39 pm »
JuDelCo, it's illusory to learn C++ only from the Internet. Tutorial sites mostly don't cover important background knowledge

Do you know the tutorial i posted ? It starts with the basics (with no knowledge at all at programming) and it explains all with simple examples and clear ways. Obviously it cant be the only source of information, that's why i put google too, to search your extra thoughts

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Pong. 24 hour project.
« Reply #8 on: March 15, 2014, 07:59:28 pm »
The tutorial on cplusplus.com is incomplete and outdated. Templates and most parts of the standard library (especially the STL) are not really covered. Dynamic polymorphism is covered only superficially, topics like multiple or virtual inheritance are omitted. Modern idioms or best practices like RAII are not treated either, let alone advanced topics like overload resolution, ADL or exception safety. On the other side, the tutorial teaches obsolete concepts such as exception specifications.

It's always the same, I don't know a single tutorial that teaches C++ in a meaningful way. There's a reason why the good books like C++ Primer have around 1000 pages: C++ is an extremely complex language. And that's only the language and library features; how to use them is explained in further books such as Effective C++ or Exceptional C++. It doesn't pay off to learn it half-way, C++ is very unforgiving if you don't know it well. If quick learning time is a criterion, one might also consider more beginner-friendly languages such as C# or Java.

Now it might be worthwhile look for a C++11 book, since several things have changed meanwhile. Some fundamental approaches are different from before and affect daily programming (type inference, move semantics, range-based for loop, uniform initialization...).
« Last Edit: March 15, 2014, 08:03:34 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

JuDelCo

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • JuDelCo's Twitter
Re: SFML Pong. 24 hour project.
« Reply #9 on: March 15, 2014, 08:12:44 pm »
At the end all can be reduced to


Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: SFML Pong. 24 hour project.
« Reply #10 on: March 15, 2014, 09:44:48 pm »
Personally I started to learn with the java language. (Which is easier than c++ to learn because of memory management abstraction and I confirm that's the best way to begin, it'll help you to understand c++ idioms further.)
So I would recommend you to learn it just for the basis.
But java has his limitations and sometimes there are incompatibilities or thread concurrency problems with 2D and 3D api's and it becomes very difficult to debug because many functionalities are already integrated into the language.
The C# has his limitations too, the microsoft language was invented to work only on microsoft palteforms. (It doens't work well on linux plateforms but it's a good way to start)

It's the reason why I started to learn c++, I wanted to made games which work also on linux plateform, and I wanted to be independant from the jvm.

And then you have just to learn how the c++ pointers works and the memory management idioms like RAII for exemple, the move semantic, etc...

If you start by the c++ directly it'll be difficult.

Finally, my own project, ODFAEG is just a set of advanced language and api's functionalities but by keeping the interdependency offered by the c++ language. (Really interesting if threads cause problems)

And I don't have problems anymore like I had in the past.
This is all what I've learned until today. (And I'm sure I'll still learn until I didn't have finish to develop my first game with my own framework)

But it seems to work well with 2D apis.

Qt is a nice framework but it doesn't provide abstraction over opengl like the SFML classes does, SFML doesn't provide the 3D so I had to invent a new framework.

And I also had problems with Qt network classes, so...
I think the best way to learn is like I've just say before.
« Last Edit: March 15, 2014, 09:55:17 pm by Lolilolight »

NinjaFishleg

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML Pong. 24 hour project.
« Reply #11 on: March 16, 2014, 01:29:18 am »
Ok, thanks for the intrest, can you recommend a good, free, resource to start learning Java? Before I invest in a book? (and I must say this is much nicer than stack overflow ;) )
« Last Edit: March 16, 2014, 01:35:46 am by NinjaFishleg »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Pong. 24 hour project.
« Reply #12 on: March 16, 2014, 10:32:39 am »
For Java, you could start with the official tutorials on the Oracle homepage. In comparison to C++, Java has the "advantage" that you can't make that many mistakes, since you have fewer control and a lot of things are done automatically for you. Sometimes this may also be a severe limitation.

By the way, I don't want to persuade you out of C++ -- it's a very powerful programming language with various paradigms and abstraction mechanisms (many more than Java, which focuses on OOP). But if you start to learn C++, you should learn it correctly and not underestimate the complexity...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: SFML Pong. 24 hour project.
« Reply #13 on: March 16, 2014, 10:54:54 am »
Speaking of simple games, SFML and C++ :  http://isocpp.org/blog/2013/11/arkanoid

JuDelCo

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • JuDelCo's Twitter