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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Serapth

Pages: 1 ... 4 5 [6] 7
76
General / SFML Complete Game Tutorial
« 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.

77
General / SFML Complete Game Tutorial
« on: October 24, 2011, 07:40:10 pm »
Soon, soon I promise. ;)


I learned a valuable lesson to try and put this chapter together.

I can't teach math.  It simply can't be taught in a tutorial, the subject is too overwhelmingly massive and had I thought about this upfront I would have saved a ton of time! :)


Take for example this method ( from Pang7 )

float GameBall::LinearVelocityX(float angle)
{
   angle -= 90;
   if (angle < 0) angle = 360 + angle;
      return (float)std::cos( angle * ( 3.1415926 / 180.0f ));
}


It is straight forward enough, but seriously how the hell do you explain to someone WHY it works.  In order to do that you need to go waaaaayyyyyyyyyyyy back to early high school math and explain so many concepts.  You need to explain Radians, Cartesian coordinates, then you have to get into Pythagorean's theorem and work your way forward.  Simply put, it is wayyyy beyond the scope of a tutorial and I am frankly not expert enough in mathematics to do the subject justice.

Sadly I went looking for good resources to link on each specific subject ( velocity, rotation, etc... ) but couldn't find a consisive site, anyone have a good recommendation?


Anyways, I attempted to explain the math and well... that was not a very productive end.  The code is written though, just need to polish the much more stripped down blog post to go with it.  Again, soon.  I also took a brief detour to explore Google's recently released PlayN ( not ready for prime time ).  Unfortunately, I am easily distracted by shiny objects.

As I am operating on about 7 hours total sleep from all of last weekend, so soon is not today however. :)

78
General / Ok in debug mode but error in release (w7, 1.6 and vc 2010)
« on: October 12, 2011, 07:55:25 pm »
I wish I knew how to do it.


Disabling precompiled headers is easy.

Right click your project->Properties
Configuration Properties->C/C++->Precompiled Headers
Change from Use to not using.

Then remove stdafx.h/.cpp from your project, including all references.


Not that it really matters if your problem is solved.

79
General / Got a new computer and my program won't work anymore?
« on: October 12, 2011, 07:46:54 pm »
I ran into this as well, and there is a very easy workaround.

Of course, you could go to SFML 2.0 like Laurent suggested.

80
General / SFML Complete Game Tutorial
« on: October 07, 2011, 06:14:12 pm »
I am not actually sure of the status of 2.0 .NET bindings, someone else will have to answer that question.  When just starting out though, I would recommend going with the stable supported version, that is why I based my tutorial around 1.6, although there aren't very many differences.

I don't really get the Visual Studio == bloated comments, but I see them all the time.  I absolutely love Visual Studio, I think it is one of the greatest pieces of software ever written and I am simple staggered by what it can accomplish.  There isn't even an ounce of hyperbole in that comment, I truly think its a wonderful piece of software and when recently using XCode or before that Eclipse it made me realize just how much I do love VS.  Now there is a ton of functionality in there that you don't need, which is why the Express versions are often a good place to start, but I don't really get that bloat part.  It loads in a matter of seconds, will open an exceptionally large project file in seconds, the compile times seem comparable to G++, the generated code is quite tight, the debugger is hands down the best debugger on any platform, ever.  About the only complaint I can think of is the few seconds of pause when running an application, but that's the price you pay for such amazing debugging.  Anyways, thats just my opinion on that subject.  Now the IDE vs text editor approach that has been argued since the first IDEs appeared, thats a different conversation.


But yeah, go ahead and use monodevelop, its a perfectly capable ide with the advantage of being able to work ( and consistently on ) on Windows, Mac and Linux, which is a nice perk.

As to if my tutorial would still be useful, thats a big fat sorta.  The setup portions obviously wouldn't be, but then .NET projects are a hell of a lot easier to configure than C++ so that is a lesser factor anyways.  The structure of my game however could be duplicated in C# and the code would look remarkably similar.  I actually code C++ in a very C#ish way, as that's been my primary language since it was released.  That said, there aren't too many tutorials out there on how to properly lay out a simple game, or design class hierarchies, etc... and that information will still be useful.  Additionally, the SFML calls will be nearly identical as well.  Obviously all the C++ specific bits will be mostly of no value if you go with C#.

Python or Lua are both perfectly valid options, although I would suggest Python over Lua simply because there is more documentation and help available for Python.  Lua was primarily created as a language to embed within other languages, although it has obviously grown beyond that purpose.  If it was me though, I would choose C#, but thats my personal bias again.  C# is the closest (mainstream) language to C++ but worlds more approachable.


As to the language differences, what you mentioned are some of the differences, but mostly as applied to Python/Lua vs C++.  C# is a strongly typed language, just like C++, although C# moved more towards weak typing with C# 4.  I personally think dynamic was a step in the wrong direction, but that's a argument well beyond the scope of this conversation.


The advantages to C# over C++ for a beginner are well beyond the scope of this conversation and a lot of it doesn't isn't necessarily core language features.  The C# build and configuration process is a world simpler than C++, there are no header files or preprocessor and the errors are a world easier to comprehend.  The first time you have to decode a C++ template error or warning, you will understand exactly what I mean.

Plus frankly the C# syntax, especially when dealing with templates vs generics, is a bunch easier to comprehend.  Plus the standard libraries are far superior, I don't think even the biggest C++ zealot would argue against that.  It also has a vastly run time support ( an advantage of running in a VM ), which benefits a developer in a number of ways, but the explanation of why are a bit premature.


I don't mean to make this into a C++ vs C# thread, by these are the reasons I think a programmer is better off learning with C#, especially if the syntax bothers you.

81
General / SFML Complete Game Tutorial
« on: October 06, 2011, 04:24:40 pm »
Thanks for the excellent feedback Nexus!

I really wish you'd mentioned some earlier as some are a nightmare to change at this point! :)

I can and will edit in a blurb about the possible perils of globals, that is a very good idea.

The _ thing, I know I shouldn't do it, I really really really know I shouldn't do it, but I can't help myself :)  It's a coding habit I picked up a long time back and although its frowned upon I really find it intuitive, especially because it groups all private members together in intellisense which is handy.  I know prefixing with m would have the same effect, but I personally at least think the prefix alphabet soup makes things more difficult to read.  Granted, in a tutorial I really should have coded to the established norm, but in this case I couldn't help it.

On the coding changes, I will see what I can do about addressing each mistake in code.  In some cases it makes a massive amount of work because of the way my blogging software does code samples in the posts.  




The choice to use asserts was one of those things I went back and forth on, and made a point of addressing that it was just one option in the comment.  As much as anything, I wanted to present the concept of asserts because they aren't mentioned nearly enough.  I think I will go back and add a bit further detail about the behavior of asserts during release mode.  I still feel they are a valuable concept to introduce.


Instead of if(x) return true; else return false; you can write return x;
Where did I do this?





As to struct/class, when I started with C++, I was coming from C and I seem to remember there being some arcane rule that a C++ to be compatible with a C struct under certain circumstances  ( perhaps composed of entirely POCO types ) would not contain a v-table.  This is a very old and very vague memory, so I decided to cover my ass and use
"biggest difference" :)

82
General / SFML Complete Game Tutorial
« on: October 05, 2011, 08:58:57 pm »
Bindings are usally just an interface layer that makes a library available to other languages.  Languages are able to call code written in other languages, they just require a bit of translation in the middle, this is essentially what a binding provides.  In the end you are still using SFML, just through a translation layer that makes it work in another language.  Your friend did you a disservice, but his (bad) advice is all to common, generally among younger/newer developers sadly.

As to me, I was a professional developer, even worked in games when I first graduated, but now I created a start up and work for myself while raising my 3 year old.  Now that pretty much all the coding is complete on my other project, I am getting back into games and writing.  Now is perhaps the greatest time to be an indie developer, so I am rather enjoying it.

83
General / SFML Complete Game Tutorial
« on: October 05, 2011, 06:55:11 pm »
Hi kolofsson,

One thing to keep in mind, my tutorial is just one way of doing things and in many cases I absolutely overkill and that is on purpose.  There is nothing wrong with writing your code along the style of the SFML examples, doing things in that manner is much easier to get your head around.  

The problem is the examples are just that, examples.  They are meant to showcase how something works, not how to actually create a full game.  What you will find is once you start adding complexity to your game things are going to start turning into a mess really fast.  There aren't too many tutorials out there on actually laying out a game, so when I see beginners code it's often all in a single file with hundreds or thousands of lines of code all often in a single function.  Then again, this is a perfectly valid way to start.

This is what my tutorial is attempting to address.  There is a very good reason why there aren't many such tutorials and first off is they take a hell of a lot of space and time, look how long it is already and it's not even a functional game yet.  There often isn't space within a book, or in the case of SFML, it's well outside the scope of what should be documented. Again though, I am just showing one possible way of doing things and I am (hopefully) doing it in such a way that people walk away with a better concept of how to lay out a game and how OO programming works.  I am also over doing things, so although this is a simple pong game, you cant take the knowledge and some of the classes and apply them to any kind of game you wish to create.

However, there is nothing to say you need to make your game object oriented.  A great many games aren't programmed using objects, take a look sometime at the Doom/Quake source code that John Carmack released for an alternative approach.  It is simply one way to approach the problem of code complexity and there is no single "right" way.

All that said, judging by the comment  "Public/ protected/ private/ virtual/ constructor/ destructor/ static class, put a tilde here, an asterisk there and a colon" C++ is probably not the language for you, as these things are the bread and butter of C++ programming.  Compared to many other procedural programming langauges ( C#, Java, Python, Lua, Ruby, etc ) C++ has a downright byzantine syntax.

In all honesty, I don't really recommend C++ as a starter language, especially if you are approaching it from a hobbyist perspective.  If you are willing to do yet more reading this is my advice for beginning developers that want to get into game programming.  It is a very long read and I tried to keep bias to a minimum, but a number of new game developers have told me they found it extremely useful, hopefully you will too.  At the very least when you are done reading you should be a little bit more knowledgeable! :)  If you are doing this as a hobby, it is something you should have fun doing!

One other thing though, what looks like a foreign language will in time become natural.  In some cases it is simply a matter of time and effort and what initially makes your head want to explode will eventually become second nature to you.  We all go through it to a certain degree.  I do however find many languages are much more intuitive than C++, which should make your learning process much cleaner.

Fortunately, SFML has bindings for just about every programming language you might consider working with.  It is a clean, well designed and mostly intuitive library which is very good for a beginner.  Therefore whatever language you go with, SFML is a very good choice to stick with.

84
General / SFML Complete Game Tutorial
« on: October 04, 2011, 12:19:17 am »
Soon (tm). :)


A bad case of the flu ripped its way through the Serapth household and I am just now regaining the ability to string a cognitive sentence together.

The code is written, just need to finish the write up.

85
General / SFML Complete Game Tutorial
« on: September 29, 2011, 05:18:44 pm »
I covered off the virtual keyword in part 4 and mention it briefly ( about it's absence ) in part 5.  The series is meant to build off the previous part, or each part would go from being long to being enormously overwhelmingly hugely long!

86
General / Input won't work
« on: September 28, 2011, 08:20:06 pm »
You need to call getEvent in your loop.

Code: [Select]

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <iostream>

int main()
{
    sf::RenderWindow App(sf::VideoMode(512, 512, 32), "WHY!");
    while(App.IsOpened())
    {
sf::Event ignoreMe;
App.GetEvent(ignoreMe);
        if(App.GetInput().IsKeyDown(sf::Key::Escape))
        {
        std::cout << "dddd";

        }

        App.Display();
    }
}

87
General / SFML Complete Game Tutorial
« on: September 25, 2011, 01:38:41 am »
Took way longer than expected, but Part 6 is live


We are still in sub-game territory, but we are getting closer and closer!   In this part, we added a player controllable paddle and the game ball. Again, if you encounter and mistakes or have any questions, please let me know!

Next up, we will get the ball rolling ( sorry, bad pun ) and cover off collision detection.

88
General / Slow Rendering in SFML
« on: September 18, 2011, 08:23:17 pm »
cout is not buffered on Windows.


Add:

char buf[1024];
setvbuf(stdout, buf, _IOLBF, 1024);


in your main() and you will see an order of magnitude increase in speed.  In my test, it went from 200FPS to 7-800FPS.

89
General / SFML Complete Game Tutorial
« on: September 14, 2011, 06:55:50 pm »
Sorry for the delay, but Part Five is now completed.


In this part we put together a very simple game object manager, it might be overkill in a pong clone, but if your game becomes any larger, a class like this is almost essential.  To a degree the complexity level of the code ramped up a bit from Part 4, so if I did a poor job explaining something or you see an error, please let me know!


Alright, off to work on Part 6.

90
General / SFML Complete Game Tutorial
« on: September 11, 2011, 10:23:28 pm »
Yeah, my bad.  It should have been sfml-main-d.lib not sfml-main.dll, fixed now.

As to the two other things, the double colour call was a cut and paste error that survived to live, while the fully resolved enum is the C# developer in me expressing himself! :)  I've fixed both now, thanks for the catch.

I actually allowed a ton of little errors to pop up between projects that I should have caught but didn't because I wrote the 5 source projects, then wrote the blogs to go with them, but in writing the blogs I found little glitches and errors, or decided I didn't like the way it was put together, resulting in a change having to be propagated across 5 separate projects.  

This...  was stupid. :)  Now, I am working to get everything at parity, then will keep the posts in closer sync to the code to prevent such problems.

Pages: 1 ... 4 5 [6] 7