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

Author Topic: SFML Game Development -- A book on SFML  (Read 283900 times)

0 Members and 6 Guests are viewing this topic.

MrUnlucky

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #180 on: January 11, 2014, 12:25:10 am »
In Chapter 3 on page 59 it says "The window class internally calls our draw() function. No other classes need access to it, so we can make it private."

I got a little confused by this so I looked at class declaration for sf::Drawable and I noticed that it is friends with sf::RenderTarget. Is this why the window class is allowed to call our private draw() method? I have never used friends before so I'm just trying to make some sense out of this.

e: vvv Okay, thank you.
« Last Edit: January 11, 2014, 01:44:19 am by MrUnlucky »

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #181 on: January 11, 2014, 01:25:38 am »
Is this why the window class is allowed to call our private draw() method?

Yes, friend classes are allow to access the private and protected fields of the class. It's not often used and should be only used in rare cases (e.g. in this case).


AlexAUT

Tommas

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: SFML Game Development -- A book on SFML
« Reply #182 on: January 12, 2014, 06:28:40 am »
I just finished chapter 7, and my missiles are behaving weirdly. They only appear if an enemy is on the screen- if there are no enemies, a missile is "expended" (the missile total goes down by 1), but no graphic is put on the screen. No missile goes firing off. If an enemy is on the screen, the missile jumps forward super fast ( either that, or it appears at the same y coordinate as the  enemy, but with my x coordinate.) It is just suddenly at the same height as the enemy, but as far over in the x direction as I am. If I am directly below the enemy, it is instantly dead. If I am to the side and below the enemy, the missile jumps to the enemy's height and slowly turns until it is facing the enemy and tries to slowly move to the enemy. It usually fails.

Is anyone else getting this behavior? I wasn't able to get the CMake to work for me, so I haven't yet tried running the github files, but I have checked over my work carefully. I have even copy and pasted the contests of Aircraft.hpp, Aircraft.cpp, World.hpp, World.cpp, Projectile.hpp, Projectile.cpp, Entity.hpp, and Entity.cpp, just to be sure (those seemed to be the ones that might be effecting the missiles). If no one else is getting that behavior, any idea as to where to look to fix it in my code? I've been scratching my head over it all evening. Any insight you have would be greatly appreciated, and thanks in advance!

halate

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: SFML Game Development -- A book on SFML
« Reply #183 on: January 12, 2014, 06:35:04 am »
Not entirely sure this is the best place to ask, but I will anyway to start.

SFML looks great from what I can tell, and would love to start with this, as I've made a decision to get into game programming. It was probably 8 or 9 years ago I last used C++, and it was at a basic level. So I decided to start over.

This book looks to be a good start:
http://www.amazon.com/Beginning-C-Through-Game-Programming/dp/1435457420

My question is, could I go from that book, directly to the "SFML Game Development" book. If not, does anyone have any suggestions for books in between?

Thanks so much,

H

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: SFML Game Development -- A book on SFML
« Reply #184 on: January 12, 2014, 07:08:48 am »
I can't say anything about that book in particular, but you may want to check out the following list.  ;)

http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list

These are known to be good books.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

halate

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: SFML Game Development -- A book on SFML
« Reply #185 on: January 12, 2014, 07:22:54 am »
@zsbzsb, awesome thanks! :D  Much appreciated.

H

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Game Development -- A book on SFML
« Reply #186 on: January 12, 2014, 01:47:51 pm »
Is anyone else getting this behavior? I wasn't able to get the CMake to work for me, so I haven't yet tried running the github files, but I have checked over my work carefully.
You're the first to report this, so it's probably an issue with your build. But you need CMake for both the GitHub and original files, so how did you build it?

If I were you, I would try to get CMake running, I don't think it makes sense to search for bugs when it might be a simple configuration problem. Have you read the ReadMe.txt on GitHub? What doesn't work?


My question is, could I go from that book, directly to the "SFML Game Development" book.
It's a very good idea to have a look at advanced C++ books before starting with game development. A mistake that a lot of game developers make is underestimating the complexity of C++ and the importance of modern idioms and clean, structured code. Books like Effective C++ or Exceptional C++ address this issue, and there might even be updated versions for C++11.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Tommas

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: SFML Game Development -- A book on SFML
« Reply #187 on: January 12, 2014, 05:03:59 pm »
You're the first to report this, so it's probably an issue with your build. But you need CMake for both the GitHub and original files, so how did you build it?

If I were you, I would try to get CMake running, I don't think it makes sense to search for bugs when it might be a simple configuration problem. Have you read the ReadMe.txt on GitHub? What doesn't work?


Thanks for the quick reply! I did read the ReadMe.txt, and followed it. I am using Visual Studio 2012 Express (Visual Studio 11), so I chose that as my compiler, found the SFML directory, chose static, and generated. When I try to run the release build, I  get the error shown in the attachment. "Unable to start the program 'C:\<filepath>\07_Gameplay\Source\Release\ALL_BUILD'.   The system cannot find the file specified."

Any ideas?

I built my project originally by creating a new project in Visual Studio 11 so I could get practice linking SFML and coding the project myself. To make sure I got the code correct, I would open up the code I downloaded from the github and compare across.

I've really been enjoying the book, by the way!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Game Development -- A book on SFML
« Reply #188 on: January 12, 2014, 05:30:20 pm »
As stated in the ReadMe.txt, you have to build the INSTALL project. You're not supposed to run the game directly from the Visual Studio solution.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Tommas

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: SFML Game Development -- A book on SFML
« Reply #189 on: January 12, 2014, 05:59:55 pm »
That fixed it! Not sure how I missed that. Now I know there is a problem with my code somewhere, and I will track it down. Thanks!

halate

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: SFML Game Development -- A book on SFML
« Reply #190 on: January 12, 2014, 07:45:21 pm »

My question is, could I go from that book, directly to the "SFML Game Development" book.
It's a very good idea to have a look at advanced C++ books before starting with game development. A mistake that a lot of game developers make is underestimating the complexity of C++ and the importance of modern idioms and clean, structured code. Books like Effective C++ or Exceptional C++ address this issue, and there might even be updated versions for C++11.
[/quote]

@Nexus, thanks! I will definitely read up with these books as well.   

Cheers,

H

gabrieljt

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: SFML Game Development -- A book on SFML
« Reply #191 on: January 28, 2014, 07:08:32 pm »
Hi there,

I am currently at chapter 7 and I am having a problem...

I've already implemented the spawning enemies and their movements, along with the HP display.

Now I am at the projectiles part, and they are not being created...
At this point, the game should be firing bullets and missiles (without homing feature).

The fire() method is being called by the player and the enemies, and the flag is changing.
When the flag is active, the mFireCommand created at the Aircraft Constructor is being pushed in the CommandQueue in the checkProjectileLaunch() method.
Analogous with the launchMissile() method.

But while debugging I've noticed, the createBullets() and createProjectile() methods are never executed, so no Projectile is being created.

What could be the problem? I followed the code from GitHub, must have missed something, but I've been checking and rechecking for hours and couldn't find whats wrong :/

Any hints?

Everything else is working as espected, and the application compiles just fine.

// Edit

As i tought, it was something to do with the Command delivery to the SceneNode by its Category...
but i was looking at the wrong place all the time, rechecking the Categories of the Entities.

I spent 3h+ to find out that i was missing this line in the World::buildScene()

Quote
Category::Type category = (i == Air) ? Category::SceneAirLayer : Category::None;

Now it is working o/

// New edit

Just finished Chapter 7... it was a tough one ;)

But I am really excited with this book, SFML and game development.
It is the first time I have the feeling that I'm programming a game that is not so hardcoded and coupled.

The simple, yet enlightener architecture provided is perfect for newcomers to the game development area who likes to program and don't want to learn how to use a game engine before creating something simple and concise.
« Last Edit: January 29, 2014, 03:57:39 am by gabrieljt »

bcvz

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #192 on: March 04, 2014, 01:27:00 pm »
Hello,
Thanks for this awesome book

Question to authors:
How many years of experience you guys have ?
Did you design the all SceneNode/Game system yourself or you get inspired from other existing structures ?

I just can't imagine a similar structure myself, I've always have to copy your code in all my games... :(


sorry for my english

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Game Development -- A book on SFML
« Reply #193 on: March 04, 2014, 01:35:20 pm »
Of course we did not invent everything anew. A lot of concepts are common practice in game development, for example the scene graphs. Others such as the command system are less widespread. It takes some experience to develop your own ideas and designs; I think the best way is to experiment as much as possible and to question existing approaches, instead of blindly adopting them. When you're aware of the advantages and disadvantages of a certain technique, you'll also be able to look for alternatives with different trade-offs.

I have been working with SFML for 6 years now, and with C++ a bit longer.
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: SFML Game Development -- A book on SFML
« Reply #194 on: March 05, 2014, 04:43:43 pm »
We were trying to give a broad view of structures and patterns that you use and have a kind of exercise to use them. Like Nexus said, instead of just blindly adopting something we showed the strengths and weaknesses of everything.

You don't have to imagine a similar structure, there is no need to reinvent the wheel when it comes to stuff like this. Most often if you conform with a design pattern or similar the code will end up much better and cleaner.

I have been using SFML since I went to Highschool, so I guess that is about 6 years as well for me I think. C++ for much, much longer. Though I have to honest to say that Nexus skill in the new standards of C++11 were completely new to me and I loved that he actually pushed forward that we used that because I learned so much.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

 

anything