Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon
14. June 2012

 

Set to be published in August, this new book Unity 3.x Scripting has been added to the Unity book193D book round up.

 

In the publishers own words:

  • Make your characters interact with buttons and program triggered action sequences
  • Create custom characters and code dynamic objects and players’ interaction with them
  • Synchronize movement of character and environmental objects
  • Add and control animations to new and existing characters
  • Written in simple and step-by-step format with real life examples, this book is the only one in the market to focus on Unity Scripting

 

As I aim to keep the round-up of books as accurate as possible, if I have missed a book, please let me know!

General


9. June 2012

 

As I have been working with Cocos2D-html ( and PlayStation GameEngine2D which is based on cocos2D ) lately, I decided to take a look at what the cocos2D book situation was like.  While about half as large as my Unity 3D book round-up there is still a nice, growing collection of cocos2D related books.

 

The cocos2D book round-up is a collection of every currently published book on the subject of cocos2D.  It contains all of the details you may want to know when selecting a book ( author, page count, rating, links to Amazon, Safari Books Online and the publisher, publish date, table of contents, publisher description, etc ) all on a single page.  So if you are in the market for a book on cocos2D, or just want to see what all is available, start here.

 

I am to be as comprehensive as possible, so if I’ve missed a book on the subject, or made a mistake, please let me know!

General


7. June 2012

 

After spending so many years as a Windows/Visual Studio developer, Intellisense is a simple must have in my arsenal.  In fact, I believe my repeated use of Intellisense actually severedWebStormAndCocos2d the part of my brain that remembers functions and variables!

 

As I’ve been doing a lot of JavaScript development recently ( between Node.js and now Cocos2D ), I needed to recreate the Visual Studio experience.  I am an avid Notepad++ fan, but I never did get autocomplete working to my liking.  Then I discovered JetBrain’s WebStorm IDE and everything was right with the world.  If you want a full blown IDE for HTML and JavaScript development, you really can’t beat WebStorm ( it is however, not free software ).  Working with Node, auto-competition worked right out of the box.  With Cocos2D-html, there is a bit more work to do.

 

Here, we are going to cover that configuration process.  This process actually applies to configuring any JavaScript library to work with WebStorm, not just Cocos2D.

 

First things first, we need a project.  I am going to create one out of the code I created in the second Cocos2d tutorial. A WebStorm project is simply a directory full of code.  Let’s create one now.

 

Load up WebStorm ( I’m using 4.0.1 ).  Select File->New Project:

image

 

In the Create New Project dialog, under the location select the folder containing your project’s code, then in the Project name field enter your app directory name.  You may have to fight a bit with the UI to get it to work right, it really wants to create a new directory.  If you are creating a completely new project, you can ignore this bit.

 

image

 

Now it will prompt  you:

 

image

 

This is what we want, click yes.  This will simply create a .idea folder within your directory with the project data.  If all went well, you should now have a project like this:

 

image

 

Now the we have a working project, we can adjust the settings on it.  In the menu, select File->Settings:

image

 

Now scroll down and expand JavaScript and select Libraries:

image

 

On the right had side of the screen, locate and click the Add button:

image

 

Name it Cocos2D and click the Attach button:

image

 

Navigate to and select the Cocos2d folder, then click OK:

image

 

You may want to repeat the process for box2d and CocosDenshion ( audio library ) if you wish to use them as well.  Click OK when done.

 

Back in the settings menu, Click the Apply then OK button.

image

 

Now, when you are editing your JavaScript code, you will now have complete auto-completion data for the entire Cocos2D library:

 

image

 

 

Ahhhh, just like being back in Visual Studio with full Intellisense support. My brain can happily go back to forgetting all about functions and member variables! Smile

 

 

If you are looking for a solid JavaSript IDE, you really should check out WebStorm.  If you are looking for a great HTML5 based game library, you should check out Cocos2d-html. As you can see, they work well together.

 

The eagle-eyed viewer may have noticed the Sublime text project files. This is another great IDE (sorta) option that is worth checking out.  I switch back and forth between the two.

General


31. May 2012

 

 

Alright I admit it, something shiny and new came along and of course I am attracted to it!  As I mentioned a few days back, the Cocos2d-x team released Cocos2d-html, an HTML5 port of theCocos2dHTML5 popular Cocos2D iPhone game library.

 

I have never worked with a Cocos2D library yet, although Sony’s GameEngine2D is based heavily on it.  So I jumped in to the HTML5 version and I have to say I am extremely impressed so far.  Therefore I am going to do a (simple?) tutorial series on using Cocos2D-x to create HTML5 games.  I am not sure exactly how much detail I am going into but it should be kind of fun.  Expect a setup and Hello World tutorial post anytime.

 

Don’t worry though, I am still working on new PlayStation Suite tutorials, still intend to do an HTML5/RPG tutorial ( although whether I use HTML5, or a library like Cocos2D-x is up in the air, working with a library is so much nicer! ) in the near future and yes, I am going to finish my C++ game tutorial too.  What can I say, I love juggling projects.

 

So, if you are interested in developing 2D games targeting HTML5 web browsers be sure to keep an eye on this space, something will be coming soon!

 

If on the other hand, you are a Cocos2D veteran and you seem me doing something stupid, please let me know!

 

Smile

General


18. May 2012

 

 

You often hear people say things like “It’s memory management that makes C++ difficult”, this is patently false.  What makes C++ so incredibly difficult for new users ( and experienced ones! ) is the complexity.  Note, I didn’t say difficulty, I said complexity.

 

Today was one of those perfect examples, one of those experiences that I want to point at and say “THIS IS WHY YOU SHOULD LEARN WITH A DIFFERENT LANGUAGE!”.  Yes, that was shouting. 

 

 

Here’s the story.  Today I had a reader request guidance on how to make a release build of my C++ tutorial.  This was a really good request, so I put it together in tutorial form.  Something quickly dawned on me… I’ve never built this tutorial in release mode.  It was pretty obvious that I hadn’t because, well, it didn’t work!   Oops, my bad.

 

 

Let’s take a look at what happened, I want to see if you can guess what the problem is.  A gold star to whoever gets it before I reveal the answer at the end of this post.  That gold star offer applies to C++ veterans and new developers alike, this is a somewhat tricky one, especially considering the starting point!

 

 

So, I was building Pang 9 ( my Pong tutorial ) in release mode.  I downloaded the project files from here if you want to follow along at home.  I simply extracted the project, then I downloaded the full SFML 1.6 SDK, imported the Visual Studio 2008 project into Visual Studio 2010 and compiled the DLLs for multithreaded release mode, and copied those DLLs into my release directory.  Code compiles just fine under release, so then I run it ( within Visual Studio ) and:

 

 

image 

 

Uhoh… this can’t be good!  The offending line of code is right here:

 

sf::Music* SoundFileCache::GetSong(std::string soundName) const { std::map<std::string,sf::Music *>::iterator itr = _music.find(soundName); if(itr == _music.end()) { sf::Music * song = new sf::Music(); if(!song->OpenFromFile(soundName)) <----- EXCEPTION IS HERE { delete song; throw SoundNotFoundExeception( soundName + " was not found in call to SoundFileCache::GetSong"); } ..... SNIP ......

Well, there is a big bad pointer right above the line, that seems an obvious candidate doesn’t it?   Well don’t waste your time on that train of thought, the pointer isn’t the issue.  The .find call seems a likely candidate too, it isn’t though.

 

Hmm, lets start looking there, ill set a breakpoint and trace into the _music.find() call.  Oh yeah, this a release mode only bug, so our hands our tied on the debugging side of things… great.  Alright, lets take a closer look.

 

image

 

 

<Bad Ptr>.  Oooh, that’s not good.  Obviously I’ve done a bad allocation here somewhere, but that just doesn’t make sense, not with the way this data type works.  In fact, the only place these pointers are even allocated is in this actual method, and we haven’t even got to that code yet!

 

For some reason, our empty map ( it hasn’t been used yet, this is the first call ), is returning a Bad Ptr instead of working as expected.  This can’t be right?  But wait… that’s a red herring anyways, isn’t it, after all our exception has nothing to do with the Bad Ptr or the std::map at all, this is just the IDE sending us on a wild goose chase. We can literally boil it down to exactly two lines of code:

 

sf::Music * song = new sf::Music(); if(!song->OpenFromFile(soundName))

 

Now we are getting somewhere, we have isolated our reproduce case down to exactly a two line program!  Hmmm, both are just standard SFML calls.  Short of being out of memory, nothing here should be able to fail.  So then, what the hell is causing this problem???

 

 

// ANSWER TIME, got your guess yet?  Did you get it right and I owe you a gold star?  Let’s find out!

 

 

Well, long story short, it’s our SFML dlls built for Visual Studio 2010.  See, this is our first method call into any SFML DLL and it’s causing an explosion… but, why the heck is that???

 

 

Well, lets take a trip over to the SFML 1.6 project and check out how I built them.  All I did was download the SFML 1.6 project for Visual Studio 2008, delete all the examples and set my build mode to Release DLL and compiled everything.  Hidden between the various warnings was one very very very important but cryptic message:

 

image

 

A bunch of warnings as a side effect of the import process, and one extremely important warning… the ahah moment if you will:

 

Warning    8    warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library    C:\temp\t\SFML-1.6\build\vc2008\LINK    sfml-graphics

 

Say what?

 

 

Now here is the thing, with C++ libraries need to be IDENTICAL.  You link debug to debug, multithread to multithread, etc…  At the same time, you have to link Visual Studio 2010 binaries to Visual Studio 2010 binaries ( although not all versions are binary incompatible, VS 2005 and 2008 could share libraries I believe ), and this here is the source of all the trouble!

 

The sfml-graphics graphics library statically links to a lib called freetype, and this library isn’t compatible with Visual Studio 2010.  Download the newest version, extract it into the extlibs folder, recompile and PRESTO, problem solved.

 

 

 

So there you go, an unhandled exception in a call to open an audio file ended up actually being caused by a statically linked font library in a 3rd party graphics dll!

 

 

Still think it’s memory management that makes C++ tricky for beginners?  The biggest problem is, new developers run into this stuff almost immediately.  You need to conquer so much to get up and running with C++, the linker being one of the earliest and most daunting obstacles.  I honestly don’t expect anyone with a few months of programming experience to have been able to puzzle this one out.  It’s exactly these kinds of things that make people throw up their hands saying “Oh screw it, programming is too hard!”.  I don’t like a quitter, but frankly in this case… they are right!

 

 

Of course, this is by no means limited to C++.  I have had very similar experiences with Java where some XML file feeding another XML file feeding a code generator called by Maven puked out a message code like “Error, unknown problem”.  Thing is, with no other programming languages do you encounter this kind of problem until you are ready to deal with the complexity.  In C++, you start dealing with this crap on day 1.

 

So this, is one such reason why I say C++ isn’t a beginner friendly language!

General


AppGameKit Studio

See More Tutorials on DevGa.me!

Month List