Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 10 Nov 2009
Offline Last Active Today, 05:14 PM

#5175053 So... C++14 is done :O

Posted by jwezorek on 20 August 2014 - 10:38 AM

Am I the only one that thinks that all those new features makes C++11 look and feel completely different than C++?

Seriously, that's practicality a different language, why keep calling it C++?


I actually feel the opposite.


Before C++11 there was all this cool stuff you could get by #including <algorithm> that was impossible to use without 

  1. sprinkling, often one line, free or static functions, all over the place that either use global state or use no state.
  2. use std algorithms with state using boost::function and boost::bind
  3. sprinkling weird little functor classes all over the place.
  4. use std algorithms with state using a local anonymous struct as a functor (even though this wasn't strictly speaking legal C++ VS would let you do it)

Now you just use lambdas and std::functions. What I am saying is that once <algorithm> was part of the standard library then you pretty much had to have lambdas or an equivalent., so if you are saying the lambdas don't feel like C++ then a lot of the standard library must not feel like C++ either.

#5174775 So... C++14 is done :O

Posted by jwezorek on 19 August 2014 - 11:39 AM

Take 'auto' for example - it's great when used with caution (and very very sparsely). But I saw some programmers who just decided that it would be great to use it as much as possible (even a very experienced one), regardless of minor things like code readability and type safety.


Using "auto" may or may not lead to less readable code (I actually don't think this is true but whatever) but it does not lead to type unsafe code, at least for any reasonable definition of "type safety". The whole point of "auto" is that it is type safe. 


C++ is a statically typed language. It doesn't suddenly stop being statically typed because they added a mechanism to make the compiler deduce types for you.

#5172956 what is a template from c++ intent?

Posted by jwezorek on 11 August 2014 - 05:19 PM

Neither is really correct but 2 is closer to correct; 1 sounds more like a C-style macro.


Basically you can think of templates as type-safe macros. This is not altogether accurate but is a good first approximation.


In other words both macros and templates cause code to get generated. The compiler will do some work for you filling in what you mean. However, in the case macros the way that the preprocessor does this code generation is completely braindead: it doesn't know anything about the types involved it just pastes the arguments into the macro and if what comes out is garbage then so be it.


In the case of templates the compiler is checking types while it is doing the code generation.

#5172133 Does the interface of every graphic adventure game suck?

Posted by jwezorek on 07 August 2014 - 03:08 PM

Some thoughts... (and a description of the Infocom interface for younger readers)


I've been thinking about this for a couple of days and I think the key thing that you would have to do to make a graphical game like this would be get rid of all the guessing. In a graphical game what can be done needs to be explicit.


When you strip away the hype of natural language processing, the Infocom interface was basically the following:


  1. Nouns were marked by the game. (You enter a room once and get the elaborate description, you then start getting the abbreviated description which was a list of the nouns in the room, some of which you could take and some of which were fixed to the room, but all could serve as objects in commands while in the room)
  2. There was a list of common verbs that you knew you could use: get, move, pull, push, insert, give, tie, untie, open, close, cut, destroy, burn and a few more. This list was augmented by a few unknown verbs that were game dependent.
  3. The verbs in 2. could take direct objects as well as indirect objects where applicable. Indirect objects could be entered either as proper indirect objects or via a prepositional phrase e.g. "Give the Chistmas tree monster the coconut" or "Give the coconut to the Christmas tree monster" respectively.
  4. Prepositional phrases worked for modifying some objects if, I think, the object exposed a property for a slot associated with the preposition -- I'm guessing this is how it worked internally anyway; for example in The Hitchhiker's Guide to Galaxy pretty much the whole solution to the Babel Fish puzzle involved prepositional phrases and the object model they induced "Hang dressing gown on hook (so the "hook" has an "on" slot). Cover grating with towel (the grating also has an "on" slot which <cover> <with> knows to map to). Place satchel near door. Place junk mail on satchel. 
  5. There were places in which you could issue commands in the same form to other agents e.g. "Robot, give the coconut to the Christmas tree monster" 

On 1. and 2, I would definitely consider any guessing of words required to be a negative thing. It was mitigated by the fact that after you played a few of these games you pretty much knew which verbs you could expect and relying on the need for a magical verb to solve a puzzle was considered bad form (although it happened. the life raft in Zork I was like this: you had to guess that a pile of plastic was "inflate"-able)


so 1. you could do in graphics in some way. 2. you could also do by way of limiting the list to very few and having some kind of uniform mechanism for engaging one of them -- something that isn't a menu though, I find the menus I've seen ugly, but also more that just an "action" button. Don't know exactly how I will do it but this seems solvable.


It's 3. and 4. where there really seems to be room for innovation. I think that there would need to be a visual language for the slots bound to objects that I am assuming exist invisibly to the user in infocom games. In infocom games you had to guess what you could do to and with an object. In the interface I am envisioning I think you would need to make what you can do to an object explicite via some mechanism.


(and 5. couldn't be done without text ... although in a 3rd person game essentially your avatar is just a special object you are interacting with that follows the commands you are entering in some way so in theory you could have more than one)

#5172067 Does the interface of every graphic adventure game suck?

Posted by jwezorek on 07 August 2014 - 10:49 AM

Do any graphics-based adventure games have an interface as rich as the pseudo natural language interface common to Infocom's games from the 1980s?
If not what would such a game be like?
... and for the purposes of keeping this question specific enough to be answerable without answers devolving into lists of games from the last couple of decades that are good, let's define "graphics-based adventure games" conservatively as the sort of direct descendants of the adventure games of the 1980s; i.e., I am not considering Assassin's Creed to be an adventure game or even L.A. Noire. However, if someone really objects to this definition then answer away and explain why I am wrong to frame the question like this.
Voice/speech-to-text would be an obvious thing to do, but part of me feels like it would be a cop out.
What I am looking for is an interface that is purely graphical but still allows puzzles deeper than the essentially verb-noun type puzzles that SCUMM type games allow. Basically, to me the SCUMM/Lucas Arts games like Monkey Island and so forth are kind of the visual equivalent of Scott Adams games or are like visually richer and 3rd person Sierra Online games, sort of 3rd person Wizard and the Princess. 
What I want to figure out is what the visual equivalent of Zork II would be like, or The Hitchhiker's Guide to the Galaxy. In Zork II, say, you have a puzzle where you slide a place mat under a door, insert a letter opener into a keyhole, pull the place mat back revealing that it now has a key on it, and open the door with the key. I don't see how you could represent a puzzle like that in a Maniac Mansion style game, so I am trying to come up with a 3rd person style graphics adventure game in which you could -- but maybe it isn't possible.

#5171423 Advice on Computational Geometry for games

Posted by jwezorek on 04 August 2014 - 09:39 AM

It's a little hard to answer without you being more specific about which computational geometry algorithms you need to use. It is a big subject.


Saying that you need to "tackle computational geometry" is a bit like saying you need to tackle graphics, or tackle game design, or something equally broad. I mean, it can be as easy or as hard as you want it to be depending on the requirements of what you want to do i.e. tackling graphics for a Tetris clone is different than tackling graphics for a AAA console game.


But even the above is not really a good analogy because videogames need graphics by definition, videogames do not need computational geometry by definition -- even procedurally generated space shooters. So what computational geometry do you need and why do you need it? Because basically you want to not to have to use a heavy-weight library like CGAL; something like that should be a last resort.


Anyway, yeah, I've used CGAL in the past. I did some work with the triangulation routines. It is a solid library. One thing to note is that it is not permissively licensed. CGAL is GPLed I believe with a dual proprietary license for commercial use. I don't know anything about Wykobi... (thanks for mentioning it actually...)

#5170912 STL C++: iterator issue

Posted by jwezorek on 01 August 2014 - 10:58 AM

Hi Chris, can't do that since I need to compile on XCode too...

Xcode has supported lambdas since about version 4.5, see here. However, I believe these and other C++11 features are still not enabled by default -- at least they didn't used to be.


Go to build settings and look for an item called "C++ Language Dialect". You need to select C++11 or greater.

#5170658 Understanding Qt At a Deeper Level

Posted by jwezorek on 31 July 2014 - 12:06 PM

Does Qt rely on some special C++ compiler, or special rules?

Qt relies on code generation. 


Qt applications are written to an extension of C++ and then turned into regular C++ via code generation. This happens behind the scenes if you are using QtCreator. If you are not using QtCreator you would have to explicltly initiate this code generation step yourself as a custom build step or additional call in your build script.


The process that does the code generation is called the "meta object compiler".

#5170617 Your Prototyping Language?

Posted by jwezorek on 31 July 2014 - 09:32 AM

I only really develop 2D abstract puzzle games, and generally what I do is prototype them by writing them with shitty graphics to Win32 using the GDI in C++. So for example, my last game looks like this on iOS (link) but started out looking like this (link). Actually the GDI version of that one doesn't look that bad because I went through the trouble of using sprites with per-pixel alpha but if you want to make things easier you can just use the regular Win32 BitBlt(...) routine and use sprites with solid white (or whatever) backgrounds for everything. 


I find it pretty easy to write a Win32 game if it doesn't have to look good once you have done it once because you can use the shell of the game over and over and if you need any kind of complicated GUI widget (e.g. text boxes), well, you have Win32 at your disposal.


I have tried  doing prototyping in PyGame but it didnt really work for me because

  1. to be honest Python slows me down: I find that I personally can write code faster in a statically-typed language because I will just like lay out all the classes based on the first principles and then start building a game with them and let the compiler work for me. You can't do this when any variable can be any type.
  2. I end up re-using a lot of the code from the prototype as is in the production version. That game above was written to iOS using cocos2d-x which is a C++ framework. My prototype was C++ + Win32. The architecture of the prototype was sufficiently modular that 75% of it, i'd say, could be re-used without changing a line, and another 10 or 15% could be massaged into equivalent cocos2d-x-based code.

Also tried prototyping in Java but this was worse than Python for me. It was basically as complicated as doing a Win32 prototype without me having a lot of background knowledge about it.


That last point is the key thing: I happen to be really comfortable with Win32 because I used to write desktop applications to Win32 professionally in days gone by (i.e. the 1990s) so I think the takeaway from what I am saying is that you should probably prototype in whatever language/platform/environment on which you are most familiar and on which it is possible for you to easily get a sprite on the screen.

#5070462 Binary save files

Posted by jwezorek on 17 June 2013 - 10:51 AM

Vector of classes, each with POD inside them (correct me if i'm wrong but this is just int, char, string. No pointers etc involved), and inside those classes if I want to use inherited classes how are these saved?


By inventing a binary file format and implementing functionality that writes a representation of your objects to this format and functionality that creates your objects from a binary file in the format you invented. There is nothing magical about this. You have functions for writing bytes and functions for reading bytes. Think about how to use these functions to store and retrieve the state you need to be persistent.


Say you have a vector of pointers to instances of Foobar objects, where Foobar is an abstract base class from which a concrete Foo class a concrete Bar class inherit. Say each foo and each bar contains only an integer ID. You could define a file format like this:


[number, n, of Foobars in vector - 4 bytes]

[ type of first Foobar object, Foo or Bar -- 1 byte]

[ id of first  Foobar object -- 4 bytes]

[ type of 2nd Foobar object-- 1 byte]

[ id of 2nd Foobar object -- 4 bytes]


[ type of nth Foobar object-- 1 byte]

[ id of nth Foobar object -- 4 bytes]

#5068692 alternatives to long else if and switch statements

Posted by jwezorek on 10 June 2013 - 10:23 AM

It is hard to suggest solutions without seeing the actual code, but generally:


  1. If the code could possibly be a switch-statement then a switch statement would be better than an if-else chain
  2. The code in the case handlers of the switch statement can be easily broken out into functions and if there is a lot of it this is probably a good idea.
  3. If you can do 1. and 2. then it is also possible to set it up as a hash table mapping from values of whatever you are switching on to instances of some kind of handler object, which could just be function pointers/functors but also could be some object that has state if that makes sense.
  4. If it's possible to do 1, 2, and 3 then you could also probably skip the hash table and do the switch functionality as a polymorphically called method of something like the handler objects in 3. 

#5062102 Breadth vs. Depth?

Posted by jwezorek on 15 May 2013 - 01:33 PM

Stick with Python until you have a solid reason not to.

#5058986 Porting from Visual C++ 6.0 to Visual Studio Tricks and Tips?

Posted by jwezorek on 03 May 2013 - 11:56 AM

You probably have functionality in your codebase that is dependent on "undefined behavior", and the behavior of the compiled code is different between the two compilers. This is similar to what happens when something in works in debug but not in release. 


Also are you doing anything with your own non-STL templates? because templates used to be really broken in VC++6 as I recall, but this was more about casuing compile time errors.


As for what to do about it,


  1. Make a pass through your codebase adding asserts where appropriate and see if you can find asserts that fail.
  2. If you have sufficiently modular design, write unit tests for various modules and see if you can get a unit test to succeed under VC++6 and fail under VS2012.
  3. Otherwise, try to get a minimal version of the application working without exhibiting crashes, and then re-introduce pieces of functionality one-at-a-time until you see a crash. 

#5057792 What software should I use for Sprite Design?

Posted by jwezorek on 29 April 2013 - 10:30 AM

It's still in alpha, but if you're planning on a lot of animation you might be interested in Spriter, which allows for a modular approach to building your animations. smile.png


Wait, so are Spriter and Spine two different things? or did Spine change its name to Spriter?

#5057520 What software should I use for Sprite Design?

Posted by jwezorek on 28 April 2013 - 12:51 PM

It depends on how you work and the style of sprites you need to make.


If you are doing retro-style 8-bit art then basically any raster image editor can do what you need to do; GIMP, etc. and I know of no tools that make this kind of work easier or harder.


If you are doing more of a high resolution cell-shaded/vector style, you can work in a vector editor such as InkScape or Illustrator; some people prefer this. Otherwise, another option for the cellshaded vector look is to work in traditional media (that is, pens and ink). scan at high resolution, clean up and possibly color in GIMP or photoshop, and then scale down to the size you need. This works remarkably well once you get the hang of it.


Also, and I say this a lot on these forums, but I think the main thing anyone doing any kind of 2D game art should invest in is a Wacom tablet. Their entry-level Bamboo line is very affordable.