Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 05 May 2007
Offline Last Active Yesterday, 02:32 PM

#5221714 Using named POSIX mutexes?

Posted by Bearhugger on 06 April 2015 - 04:39 PM

I'm not sure if pthread defines system-wide named mutexes, but the POSIX standard defines named semaphores, and a mutex is just a special kind of semaphore (that only takes values 1 and 0 and that is initialized to 1) so that should be good enough if not as handy.


Look at the sem_open function for how to use it. You might also want to read that SO question: http://stackoverflow.com/questions/16400820/c-how-to-use-posix-semaphores-on-forked-processes

#5219902 From scratch vs Unity

Posted by Bearhugger on 28 March 2015 - 08:15 PM

Those are a few reasons why I made my game from scratch instead of using Unity.

  1. Unity is way overkill for my project, which is a 2D RPG. If I wanted a premade engine, RPG Maker would be a much better buy than Unity for my needs. (Not that I'd use it because the graphics engine sucks and it's not cross-platform, but I'd sooner use that than Unity or Unreal.)
  2. I have a lot of code already written, including a very good (for my game's needs) editor program, to the point where moving to Unity would be *more* work than actually completing the game.
  3. I like owning the source code of my entire project. When I encounter a bug I don't want to wait for the Unity devs to fix it and even less to code a workaround myself.
  4. This one goes with 3 but just by principle, I don't want to tie my game to someone else's engine if it's not absolutely necessary for the project's success.
  5. I'm a systems and chip programmer and I love low-level programming. I have more fun writing my game from scratch and hand-optimize it than using someone else's work.
  6. The bare pro version is a $1,500 package that you pay upfront. I personally find the Unreal 4 payment model more advantageous, but for that I guess YMMV.
  7. For a "indie-friendly" engine, they buy a lot of stuff that look way overkill for indies such as their Mecanim animation system, yet they took an eternity to get a proper UI system which every game needs.

Now, I'm not an unrealistic daydreamer; I know that if my project was more complex and involved 3D and advanced rendering techniques I would have to seek a premade engine (although it would probably be UE4 instead of Unity) I just can't think of any point for me to switch to a premade engine this far into the project.

#5217536 how to comunicate with diffrent exe files?

Posted by Bearhugger on 18 March 2015 - 09:03 PM

Is there a reason you can't just open sockets at and transfer data that way? It's not as efficient as shared memory but it's much easier to work with, there are cross-platform libraries for sockets, and for I assume that the kernel is optimized enough to not go down all the way to the IP stack before noticing that the packets are for itself.


Shared memory is more efficient but it puts the burden of creating a communication protocol and synchronizing memory reads and writes on your shoulders. So I hope you really need the performance gain if you go that way. It's also less flexible since you can't put the server on a remote machine.

#5209156 Does games that were writen in "c" will be processed faster then...

Posted by Bearhugger on 06 February 2015 - 03:50 PM

C and C++ are not inherently slower than the other. The C++ compiler can write a lot of code for you under the hood, but that's almost always code you would have to write yourself if you were in C. And since it would be boilerplate code written by a human there are chances that it will contain errors, so writing that code on your own is not necessarily the best idea. And if you really want to write that code yourself, well C++ still allows you to do it.


What's really cool and unique about C++ is that it can be as low-level as you want it to be, or as high-level as you want it to be.

#5207726 Comparison of STL list performance

Posted by Bearhugger on 30 January 2015 - 12:54 PM

There's no good reason in 2015 to switch to C from C++. Anyone claiming otherwise is an old-school programmer who hasn't paid much attention to compiler or language technology in the last decade.


Are you talking about game development or general development? Because there are plenty of reasons people use C instead of C++ in 2015, it's just not generally the case in game development because we need to treat a lot of information and resources, and the facilities that C++ has over C are very handy there.


But yeah, people that use C don't do it to outperform std::list because that would be a complete waste of time. Instead of switching to C, I'd rather spend that time doing like EA and making my own version of the STL containers, with the features I find superfluous dropped out...

#5206602 Funniest line of code ever ?

Posted by Bearhugger on 25 January 2015 - 02:31 PM

try {

    // Some Java code that throws a lot of checked exceptions.

} catch (SomeCheckedException e) {
} catch (AnotherCheckedException e) {

#5205405 Porting my game to Linux

Posted by Bearhugger on 19 January 2015 - 04:11 PM

1. Will g++ suffice as my compiler?  My game uses C and C++.  I'm also a bit of a noob to makefiles...


Makefiles are a pain to use and maintain for any reasonably complex project. People use automake and autoconf script to handle them, but even with those I find it annoying to use them.


Personally I use CMake instead of bothering with those and that's what I would recommend. It allows you to describe your project using a simple scripting language, then you can tell it "Generate me a makefile for my project" and then you get your Makefile. What's really cool is that it's not limited to makefiles. If you're on OSX you can have it make you an XCode project, or if you're on Windows a Visual Studio solution. It also works with less popular IDE like Eclipse. Even better: Qt Creator will load directly from CMake scripts so you don't even have to type the commands.


I still have a Visual Studio solution I manually maintain because CMake doesn't seem to fully support C#. (No point since csproj are their own makefiles) so I don't really use CMake on Windows except to test the CMake scripts, but on Linux and OSX I find it very useful.

#5202791 Programming a Level Editor

Posted by Bearhugger on 08 January 2015 - 04:16 AM

I have been learning all on "My own" through video tutorials, C# Tutorials and such, and I am sure many started that way, I would greatly appreciate some guidance on how to get started about programming a Level Editor.

What kind of level editor?


A 3D level editor integrated with the engine (like Unity) is very complex and will have different needs based on how the engine work and what is the pipeline, so you can't really write a tutorial for that.


On the other hand, a tile-based 2D level editor is pretty easy to do. The reason you won't find tutorials for that is because it's just like any other GUI-based desktop application really. You blit tiles to the client area just like how any other app draws stuff in its client area. You make dialog boxes for stuff like map options and entities like you do any other dialog boxes. You put your commands in a menu bar like any other app does. Your maps are your documents and you save them to files, like any other document. And so on. You build it just a normal everyday app with a standard GUI, so I guess any tutorial teaching the techniques for building a document-based GUI application would work for that kind of map editor.

#5200211 2D game library help

Posted by Bearhugger on 27 December 2014 - 12:17 AM

You should absolutely keep using SDL. Even if you're using OpenGL for rendering, you can (and most likely want) use it for all other game-related tasks. Valve use it so this is not some kind of learning dummy, it's a really useful library. I use it in my game, and I get Mac and Linux support for free. smile.png


As for whether you should use SDL for graphics or go to OpenGL, it really depends on how ambitious you want your graphics to be, but since you said you are new to game programming and are posting in the beginner's forums, I'm going to suppose you're going to stick to blitting and simple shapes, and for that SDL's graphics is more than enough.


The reason most 2D games ignore SDL's video API and go for DirectX Graphics or OpenGL is because they want to gain access to advanced rendering technology, which is only available through those APIs. For example, you may want to use a pixel shader to apply special image processing. State-of-the-art 2D rendering engines such as Ubisoft's Ubi-Art Framework (Ray Man, Child of Light, etc.) would not be possible with SDL rendering because there are too many things lacking.


Also, indie 2D games sometimes want a retro look, and this is quite ironic but some old rendering techniques are no longer supported and need to be emulated by newer technologies. The best example of this is palette animations: the color-indexed video modes are no longer supported by modern hardware so to get the same effect you need a pixel shader.


I have to say though that I'm not an expert of SDL's video API because I use OpenGL and DirectX, and SDL2 is recent and might support the retro tech I have mentioned above. A guy at the Steam dev conference called SDL 2.0's video API the most awesome Super Nintendo you've ever seen so if you're into retro stuff you might want to check if 2.0 supports it. (I know that 1.2 didn't.)

#5200168 Should I use std::cout or have using namespace std; ?

Posted by Bearhugger on 26 December 2014 - 05:59 PM

I don't personally agree with avoiding using namespaces in .cpp files I see no problem with that, but yeah in header files it is not very professional. You're going to have source code that randomly includes namespaces, and then if you remove an include you need to add your using clause. It can also lead to strange build problems related to the order of your includes. Say you forgot to add a using clause to your header but the project builds because you always include if after a header that has the clause, but eventually someone removes the other header and it breaks the build. Header files should be independent entities that can be included in any order or any number of times. I know this rule makes things annoying if you have long C#-style namespaces like company::project::component and have to write code in your headers (templates, etc...) but this is in the interest of the other programmers' sanity! smile.png


The only exception I can think of is if say you are implementing a library with a single namespace. I still wouldn't do it but I guess I would tolerate adding a using namespace your_library in a precompiled header of the library since you're going to be using the namespace in all your source files anyway, but not in any other headers, and especially not in the public headers that you will distribute with your library.

#5155777 Choosing c# or c++ for game engine development

Posted by Bearhugger on 24 May 2014 - 09:27 PM

Well if you're not comfortable with C++ then I doubt you will beat the .NET JIT-compiler at writing fast native code in C++, and with Microsoft brewing some native .NET compiler, the speed difference will probably become a lot smaller very soon. (Like compiled VB6 vs C back in the 90s.)


If you want to use C++ because it's your long-term goal to be proficient at it, this is a great opportunity. Using C++ to be able to eventually port to iOS and Android might also be a good idea. If you just want C++ to save a few CPU cycles then I wouldn't bother unless your project is such that it absolutely needs blazing-fast performance. Truth be told, C++ might be a good starting point, but it is not a panacea to slow code. For example, Ogre 3D, which is pure C++, is sluggish and slow, and Runic Games, who are not even making performance-hungry games, had to mod it to improve performance. I wouldn't be surprised if someone could out-perform Ogre3D using XNA.



Also, I'm not sure I'd recommend BinaryFormatter for saving objects during development. I use it in my game editor for saving stuff and I regret it. Whenever I want to refactor something in my code, it breaks binary serialization and I can't fix it by hand, instead I have to use a SerializationBinder, hack some translation code, then load and save ALL my assets, and finally recompile my app without the hack because SerializationBinder slows loading down to a crawl. (It was such a pain that I had to make a library for auto-generating a SerializationBinder.) If I had to code it from scratch again, I'd probably save my levels in XML or JSON and my data in a SQLite database, disk space be damned. I think that binary serialization in .NET is useful for in-process serialization like copy and paste, sending data between AppDomain, and over a network, but not for long-term storage, and especially not during development where stuff can be moved and renamed.

#5149324 DRM protection

Posted by Bearhugger on 25 April 2014 - 01:37 AM

Just make it easier to buy than to pirate. It's not even about the DRM.


I find it much more convenient to spend a few bucks on an online store and not have to worry about viruses, rootkits or trojans, than having to search on torrent sites, looking for a well-seeded torrent, reading the comments, downloading it, and then exposing my machine to viruses, risking getting a crypted zip that you have to pay the pirate to get, follow hacking directive to replace XYZ.dll with a file that will give a heart attack to my AV, or some other crap that is common with pirate site.


On Steam I pay 20$ for a special (I only buy games in promotion) and then that's it, it's really easy. I wouldn't go back to piracy.


Personally, if I ever get to release my game, I will use the DRM of whatever platform I get it on (App Store, Google Play, etc.) because hey it's free, but I'm not going to lose my time trying to lock the game and risk getting false positives on legit users. 

#5102736 Simple attribute/combat system for RPG

Posted by Bearhugger on 19 October 2013 - 05:53 PM

Personally I would change Constitution so that it reduces damage taken instead of increasing health. (Which is actually what I do in my RPG.) As someone who usually picks tanky characters, I'm not too fond of stacking pure health. I know that a lot of old-school RPGs have that kind of system where constitution/vitality/stamina increases health and intend that as THE primary tank stat, but personally I never found the intended way to build a tank to be the best one.


Having a lot of health just delays your character's death, and it makes him or her harder to heal. What do you prefer? Healing a character that has 100 health and 50% damage mitigation, or a character that has 200 health and 0% damage mitigation? Mathematically, they take the same amount of punishment, but the first one needs to be healed half as often as the pure-health tank.


As it is, if I was playing your game, I would probably get just enough health to survive magic attacks, and then put all my attributes into evasion so my tank can get some crazy 90% evade, so that the only thing that can hurt me is magic damage.

#5102582 Final Fantasy VI game - chronological order of building & being challenge...

Posted by Bearhugger on 19 October 2013 - 02:24 AM

I've made my own Final Fantasy VI-alike game engine. (Some screenshots:




Most graphics assets are RPG Maker graphics I borrowed.)


Making a game engine for a 2D RPG is totally doable on your own, however you are going to be working on it for a long time before seeing results. When I built that game engine, it didn't take me an eternity but I had no job, no school and no lover so I could afford to work on that project from 10 AM to 3 AM if I wanted to. And I also had an unending love for old-school Final Fantasy games. I could never afford to do that now at 29. I have stayed away from Final Fantasy since they turned bad, and it gave me an idea for a new battle system that would be (IMHO) a lot more fun and tactical than this ATB that I copied, plus a new skill system, item system, etc. but I just don't have the time to work on it. I wish I had the time to work on it full time. =/


But I disgress...


I would suggest working on a simpler genre. Unlike most other genres, Japanese-style RPGs like that don't have much physics to deal with, which might make them sound easier to make, but the amount of data that is involved in a RPG is absolutely crazy. You have item data, weapon data, armor data, skill data, enemy data, enemy group data, hero data, shop data. And then you have two major and separate game modes to create: the area map mode where you talk to NPC, open chests and show cutscenes, and the battle mode where you, well, fight monsters. If you want the game engine to have features similar to FFVI, you're going to put a lot of work in both. For example, FFVI had a very extensive battle animation system, where you could of course draw sprites, but also generate vectorial stencils that mask parts of the animation, generate trails for character sprites, animate palettes. So a cheap "missile-with-particle-system" 2D animation system just isn't going to cut it. (Again, assuming you want FFVI-level quality.) I could definitely be wrong, but since this is the "For Beginners" forums I'm assuming that you're not ready for that kind of game. A RPG also involves a very large amount of content, and players chew through that content really fast. It can take me 2 hours to make a cutscene of 5 minutes (which is still a joke compared to the time it takes to make a CG 3D cutscene of 5 minutes...) and a player will typically only see a cutscene once, unless it's before a hard boss or something. My RPG took 2 hours to do from start to where I was at when I left it (when I decided to rework it into something that isn't as much of a FFVI ripoff), but I had probably spent 4 months just creating content. (Not programming or drawing.)


I think a simpler genre would be something like a side scroller. You have a lot more physics to deal with, but you only have one game mode instead of two, much less content to do, less music, probably less assets too (although I could be wrong on that one.)

#5100675 2D Oriented Game Engines

Posted by Bearhugger on 11 October 2013 - 07:23 PM

Making a 2D engine is relatively straightforwards so I don't think you'll see a lot of generalist pre-made game engines for 2D like you do for 3D. Normally, the programmer of a 2D game would just hand-pick the libraries she or he needs and stitch them together in his own engine. (For example, could be SFML for graphics, FMOD for music, Box2D for physics, PhysFS for IO, etc.)


There are popular 2D game engines but they're all super high-level engines where you barely have to code anything. Although if those are what you are looking for, those are pretty good ones:

Game Maker.

IG Maker.