Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 05 May 2007
Offline Last Active Today, 03:48 PM

#5206602 Funniest line of code ever ?

Posted by Bearhugger on Today, 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.

#5100312 Installshield LE not working

Posted by Bearhugger on 10 October 2013 - 02:59 PM

I don't think this is compatible with Visual Studio Express. I don't even know if you're allowed by the EULA to release software with it, so supporting an install tool for pre-release doesn't make a lot of sense to me.


You could always use the free NSIS. Personally, I use that professionally to create setup projects for my jobs, and it works great. You have to use a (very simple) scripting language instead of having a point-and-click interface, but unless you have a very complex project to install, it is pretty straightforwards.

#5096011 Who has implemented a licensing API/SDK

Posted by Bearhugger on 22 September 2013 - 02:49 PM

I'd just leave it to my distribution platform (Steam, Apple App Store, Windows Store, etc.) to handle the DRM and focus on making a good game. I would not lose time with it myself, it's just not worth the effort and I don't care to play that cat-and-mouse game with hackers. People who will crack your game are usually not going to buy it anyway. I'm guilty of having pirated games in the past but those were either games I was never going to buy, or games that I wanted to try before buying. I have never pirated a game from developers I trust to not make cheap cash grab games. I have never pirated a Blizzard game, for example.


More importantly, sometimes DRM itself might be the reason why people don't want to buy your game. Don't make it safer and easier to pirate the game than to buy it legit. Mass Effect 3 has been massively pirated, and I bet that one of the reason was that people didn't want to install EA's Origin's DRM/spyware/cloud on their computer. I decided to just not play the game (rumors about the ending cooled my excitement anyway) but those I know that have played it on the PC have all pirated it. Although unless you're called Ubisoft or EA you probably don't have the means to invest into draconian DRMs like Origin or Uplay so you can probably ignore this issue.


You might want to go the always-online way, but if you do so you need to ADD VALUE to the always online factor so that it's not just an annoyance for the players. A lot of people have complained against Diablo III's always-online feature (and who am I to tell them that they're wrong) but personally I grew a large friend list by playing World of Warcraft, so being able to chat with my friends while playing any Blizzard game makes always-online awesome for me. I wouldn't play the game offline even if I could.


On a side note, I have once successfully used a protection scheme to force the customer to pay the full price of a software when I was working for a company that made industrial machines. I hid the lock/unlock flag into the machine's RAM on a chip. Of course he could have "easily" hacked it, but when you're buying hardware that is one-of-a-kind and costs 5M$, you don't want to risk breaking it (plus voiding your warranty) by hacking the chips for the 5k$ software add-on... Of course, games are all software, so you can't do anything like that. 

#5085896 How does a “Build” button in game engine editor window works?

Posted by Bearhugger on 14 August 2013 - 01:40 PM

How these executables access those assets and scripts if they are packed into single archive?


It's quite simple, actually.


Archive formats store some sort of look-up table somewhere in the file. In a very basic archive format, each entry in your table will contain the name of the file, the offset of that file in the archive (ie: where to fseek to), the compressed size of the file, and the size of the file when decompressed. It could also store flags such as whether the file is compressed, which can be useful if you're storing files that are already compressed (such as PNG images) because there's no point in compressing a file twice.


Typically, how it works is that your code will tell your I/O module to include an archive in the search path. Then, the first thing your I/O module will do (well, after maybe file-mapping the archive) when you give it that archive is to read that table and put it in somewhere in memory, probably in a dictionary or a hash table, so it knows where to find all the files. Later, when your program requests a file from that archive, your I/O code can quickly determine whether that file is contained in the archive, and it already knows where to find it. (In what archive and at what offset.)


For a very simple real-life example, here's the archive format of good old FFVII's LGP files: http://wiki.qhimm.com/view/FF7/LGP_format. It's obviously a very simple archive format. A lot of companies want additional features such as encryption or formats that make it easy to update, remove or insert files without rebuilding the whole archive.


Also, sorry if I'm stating the obvious, but Archive formats, including generalist ones like ZIP, don't compress all files together. Rather, each file is compressed (and optionally encrypted) separately, AND THEN concatenated into one single (or several) archive. Otherwise you would have to decompress the entire file to reach a file stored at the end of the archive, which is obviously not optimal.


Shameless plug but since this is related to the topic, I'm actively working on an archive format partly inspired by Blizzard's MPQ format which I am a fan of, with an easy to use C++ 11 API library to access those archives. It has/is going to have features like built-in localization support, platform-based include/exclude of files, first-class support for modding and patching, high performance file reading, multi-threaded access, etc. I wonder if there would be any interest in that kind of library because I wouldn't mind releasing it to the public if it's something that could help developers.

#5085311 How does a “Build” button in game engine editor window works?

Posted by Bearhugger on 12 August 2013 - 04:59 PM

When you hit "build" it probably converts your assets into file formats that are optimized to be read very fast (assuming the editor doesn't do it as soon as you import it into the project), then it takes all those assets and packs them all into an archive for the purpose of blazing-fast access, compression and weak obfuscation. Each big developer has its own archive file format: id Software has .PAK archives, Square-Enix has .LGP archives, Valve has .VPK archives, Blizzard has .MPQ archives (IMHO the best ones featurewise), etc, etc, etc.


In the case of Unity it probably also compiles all your C# code with maxed performance flags and pre-parse your JavaScript as well.

#5082611 JRPG: Average Number of Pieces of Dialog?

Posted by Bearhugger on 02 August 2013 - 05:35 PM

It depends on the JRPG. It's been a while since I made Final Fantasy VI (SNES) mods, but on top of my head, the game had dialog indexes that went up to around 0xE00, which brings us around 3,584 dialog units. However I say "units" because those dialogs could include multiple pages. (As long as you could hit A without the dialog closing, it was the same dialog ID.) If you want to count each dialog reply as one unit, it probably goes upwards to somewhere between 5,000 to 7,000.


Keep in mind that this is a 1994 JRPG with tons of "generic" dialog lines that any of your party members could say. It didn't matter whether you had little Relm, the big muscular Sabin, or Cyan with his Old English accent, there are dialog that would be said the same way regardless of the character.


The next big JRPG that Squaresoft built was Chrono Trigger, and it had customized dialog lines for every character that could ever join you, and on top of that the game really didn't pack as many dialog replies in a single dialog unit like in FF6 because the devs wanted to slip sprite animations between many replies (ie: Marle shaking her head before saying "NO"), so the amount of dialog units probably went way up, to around 10,000 dialog units, and it should be much closer to the actual number of dialog replies. I don't know the exact numbers because I didn't mod Chrono Trigger nearly enough.


For the PlayStation JRPGs there's no easy way to tell with one glance though. The dialogs are all stored in the map files for each individual area instead of being stored in one huge region of a ROM image like the NES and SNES games. You'd have to open every single map in the game in a mod editor and sum the amount of dialogs in them.