Why C++ and Not ?

People have asked me this question many times over the years when I say I like to develop in C++. Usually followed by a statement about a single advantage for their language of choice.

The advantage is usually about easier/quicker to code, don’t have to worry about memory management/exceptions, or it uses some form of coding style they think advantageous.

My reasons for liking/using c++ are the following:

1) Familiarity

I originally learnt C++ back in TAFE and University (2003) and while I have worked with many languages over the years, many of them have been derivatives of C or very similar in many ways or syntax (C#, Objective C, Java, Javascript).

2) Flexibility

Many programming languages will force you to use either Procedural, Object Orientated or Functional programming paradigms and while they will have some support for another, they usually don’t support  all three.

C++ on the other hand is built on top of C and maintains the support for procedural programming from there while also adding in Object Oriented programming. Modern C++ has also added in many Functional programming features and many other things making it a very flexible language.

3) Functionality

C++ and C are have been around for a long time and are still a basis for many libraries to perform many different functionalities. While these libraries are available to other languages, its ofter just a wrapper around the original.

4) Fast

C++ is fairly low level and is often a very performant language. Compilers for c++ have been around for a long time too and many optimisations have been made to speed up resulting code.

5) F IDE Support?

Again since C++ has been around for a long time, there are many IDE’s that are fully featured. And while an IDE is not required, it can help greatly especially when coding against an unknown library or in an unfamiliar new language like <Language of the Month>

That’s pretty much it, and as much as I wouldn’t mind trying out some of the newer languages, I don’t have the time or patience these days to learn them without the help of a good IDE.

Long time no blog?

It’s been a long time since the last update and I thought I would just give a quick status update.

Currently I am working on a framework I call NinjaFramework made up of many small libraries with very specific purposes that can be used individually or together.

While not specifically for game development I do plan to use them together as part of a game engine to help me develop games.

Progress is slow as I find myself without much spare time to code these days but I will continue to work on it when I can.

The framework can be found here: https://github.com/nbollom/NinjaFramework

Python vs Speed

So after a few days playing around with python I noticed a few interesting things:

1) PyPy is not always the fastest!

PyPy is an version of Python with a JIT compiler that is supposed to speed-up python code dramatically. It especially is good at optimising loops but has trouble with python modules that are not pure python, but have C/C++ backend libs.

Unfortunately in my case both PyGLET and PyMunk are backed by C/C++ and the event loop of my game is handled by PyGLET and calls events on the python code.

This causes PyPy to not perform as well as CPython in my case.

2) CPython performance is weird???

With my very simple early prototype I am getting weirdly inconsistent frame-rates between runs of the exact same code.

While I usually get a nice smooth 60fps, every now and then it will only run at 20fps for no apparent reason.

This raises the possibility that the finished game will not perform as well as I would like and makes me consider dropping python in general.

Of course that has its own set of problems, while the chipmunk code can be fairly easily ported to c++, changing the windowing/graphics library to something like SDL will be a bit of a pain.

Here we go again!

After a fairly substantial break that started off with an attempt to make a compiler for a custom language, I have decided to come back to the #1GAM competition and have another go.

The theme for this month is Resolution.

The game idea that I have come up with is a platformer game where your character starts off as a single pixel (scaled up so its visible) with no memory of who you are and what happened to you.

By collecting pixels throughout the levels you will gain “resolution” and recover your memories.

This time I will be using python as the language and the pyglet window/graphics/sound library.

I am also considering the pymunk wrapper for the chipmunk physics library.

I recorded a video of a little test that I did with the sprites that I am going to use (full resolution) you can find here:

#1GAM Game 2?

So 13 days have passed in this month and I have not posted anything. Does this mean that there is no game this month?

Well the answer to that is no, there is a game this month, I just haven’t got around to writing about it.

This is partially because I’m not that happy with what I chose to do and partially because other projects have demanded more attention.

What is this months game?

The theme for this month was “Doctor”, meaning it the game just needs to reference a doctor of some kind (whether medical or some other doctor).

This month I have chosen to follow that theme and since last month I had a lot of troubles with porting the game and was only in the end able to get it done for Mac OSX Mavericks, I have chosen to go in a much simpler direction.

And so Click Hospital was born.

Click Hospital couldn’t be any more different from Space Shooter, HTML+Javascript instead of C, no physics, no graphics, and very little game logic (relatively).

Click Hospital is what you would call an idle clicker game.

Basically clicking a button earns money which then can be used to purchase things and upgrades that make more money.

There is no end-game so there are no states such as winning or loosing it just continues on, although you could consider it the end when all the possible items and upgrade and achievements are purchased (although there is no limit on the amount of each item that you can purchase, and future updates can unlock more items/upgrades/achievements).

So while the game is inherently pointless, there is something about idle clicking games that is extremely addictive.

Advantages over Space Shooter

So while Click Hospital is much simpler the Space Shooter it also has quite a few advantages.

Because it is written in HTML and Javascript, it is inherently cross platform as you can run it on any system through a web-browser.

Also because only a limited amount of logic is needed for the game to be considered playable, I can make the game available for playing earlier in the month and then expand on the content for the rest of the month.

So where is it?

Ok while I said not much is needed to be considered playable, I have not yet made it to that stage.

There is a little bit of work remaining to get it into that state, but I am quite close.

I expect to have it ready for the initial launch in the next few days so pay attention to the Games section of my website.